/* ===== CSS Variables ===== */
:root {
    --bg-primary: #0d0d0f;
    --bg-secondary: #16161a;
    --bg-tertiary: #1e1e24;
    --bg-elevated: #242429;
    --bg-input: #1a1a1f;
    
    --text-primary: #fffffe;
    --text-secondary: #94a1b2;
    --text-muted: #72757e;
    
    --accent-primary: #7f5af0;
    --accent-secondary: #2cb67d;
    --accent-gradient: linear-gradient(135deg, #7f5af0 0%, #2cb67d 100%);
    
    --removed-bg: rgba(255, 107, 107, 0.15);
    --removed-border: rgba(255, 107, 107, 0.4);
    --removed-text: #ff6b6b;
    
    --added-bg: rgba(44, 182, 125, 0.15);
    --added-border: rgba(44, 182, 125, 0.4);
    --added-text: #2cb67d;
    
    --border-color: #2e2e35;
    --border-subtle: #232328;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(127, 90, 240, 0.2);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --transition: all 0.2s ease;
}

/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 40px;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
}

.logo-title {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    height: 48px;
    width: 48px;
    border-radius: var(--radius-md);
}

.title-group h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.author {
    color: var(--text-secondary);
}

/* ===== Main Content ===== */
main {
    flex: 1;
    padding: 30px 40px;
    max-width: 1500px;
    width: 100%;
    margin: 0 auto;
}

/* ===== Mode Toggle ===== */
.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 30px;
    background: var(--bg-tertiary);
    padding: 6px;
    border-radius: var(--radius-lg);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.mode-btn:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.mode-btn.active {
    background: var(--accent-gradient);
    color: var(--text-primary);
    box-shadow: var(--shadow-glow);
}

.mode-icon {
    font-size: 1.1rem;
}

/* ===== Section Container ===== */
.section-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ===== Editor Container ===== */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.editor-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.panel-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.panel-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

textarea {
    width: 100%;
    height: 350px;
    padding: 20px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-input);
    border: none;
    resize: vertical;
}

textarea::placeholder {
    color: var(--text-muted);
}

textarea:focus {
    outline: none;
    background: var(--bg-secondary);
}

/* ===== Action Bar ===== */
.action-bar {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.btn-primary {
    padding: 14px 40px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-secondary {
    padding: 14px 32px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* ===== Result Container ===== */
.result-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.output-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: 200px;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.output-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-copy {
    padding: 6px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-copy:hover {
    background: var(--accent-primary);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.output-content {
    padding: 20px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    white-space: pre-wrap;
    max-height: 500px;
    overflow-y: auto;
}

/* ===== Diff Highlighting ===== */
.removed {
    background: var(--removed-bg);
    color: var(--removed-text);
    padding: 1px 4px;
    border-radius: 3px;
}

.added {
    background: var(--added-bg);
    color: var(--added-text);
    padding: 1px 4px;
    border-radius: 3px;
}

.output-header-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.header-stats {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.header-stats span {
    font-weight: 500;
}

/* ===== PDF Upload ===== */
.pdf-upload-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.pdf-upload-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.pdf-input {
    display: none;
}

.pdf-upload-label {
    cursor: pointer;
    width: 100%;
}

.pdf-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 40px 30px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    transition: var(--transition);
}

.pdf-upload-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.upload-icon {
    font-size: 1.5rem;
}

.pdf-filename {
    font-size: 0.85rem;
    color: var(--accent-secondary);
    font-weight: 500;
}

/* ===== PDF Stats ===== */
.pdf-stats-container {
    display: flex;
    justify-content: center;
}

.pdf-stats {
    display: flex;
    gap: 30px;
    padding: 14px 30px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
}

.stat-removed {
    color: var(--removed-text);
}

.stat-added {
    color: var(--added-text);
}

/* ===== PDF Navigation ===== */
.pdf-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    width: fit-content;
    margin: 0 auto;
}

.btn-nav {
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-nav:hover:not(:disabled) {
    background: var(--accent-primary);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.btn-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#pageInfo {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 100px;
    text-align: center;
}

/* ===== PDF Viewer ===== */
.pdf-viewer-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.pdf-viewer-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.pdf-panel-header {
    padding: 14px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
}

.pdf-viewer {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 600px;
    background: var(--bg-tertiary);
    overflow: hidden;
    padding: 20px;
}

.pdf-canvas-wrapper {
    position: relative;
    display: inline-block;
    overflow: hidden;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.pdf-viewer canvas {
    display: block;
}

/* ===== PDF Annotation Layer ===== */
.pdf-annotation-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.pdf-highlight {
    position: absolute;
    pointer-events: none;
    border-radius: 2px;
}

.pdf-highlight.removed {
    background-color: rgba(255, 107, 107, 0.35);
    border: 1px solid rgba(255, 107, 107, 0.6);
}

.pdf-highlight.added {
    background-color: rgba(44, 182, 125, 0.35);
    border: 1px solid rgba(44, 182, 125, 0.6);
}

/* ===== Footer ===== */
footer {
    padding: 20px 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .editor-container,
    .result-container,
    .pdf-upload-container,
    .pdf-viewer-container {
        grid-template-columns: 1fr;
    }
    
    main {
        padding: 20px;
    }
    
    header {
        padding: 16px 20px;
    }
}

@media (max-width: 600px) {
    .mode-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .title-group h1 {
        font-size: 1.2rem;
    }
    
    textarea {
        height: 250px;
    }
    
    .pdf-viewer {
        min-height: 400px;
    }
}
