/* ============================================
   Text Diff Tool - Styles
   ============================================ */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f172a;
    --bg-surface: #1e293b;
    --bg-elevated: #273548;
    --accent: #60a5fa;
    --accent-solid: #3b82f6;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-dim: #64748b;
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --diff-add-bg: rgba(34, 197, 94, 0.12);
    --diff-add-text: #4ade80;
    --diff-add-border: rgba(34, 197, 94, 0.25);
    --diff-del-bg: rgba(239, 68, 68, 0.12);
    --diff-del-text: #f87171;
    --diff-del-border: rgba(239, 68, 68, 0.25);
    --diff-mod-bg: rgba(250, 204, 21, 0.10);
    --diff-mod-text: #fbbf24;
    --diff-mod-border: rgba(250, 204, 21, 0.25);
    --diff-word-add: rgba(34, 197, 94, 0.30);
    --diff-word-del: rgba(239, 68, 68, 0.30);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ---- Header ---- */
.header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #7c3aed 100%);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    backdrop-filter: blur(8px);
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.01em;
}

.header-subtitle {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ---- Mode Toggle ---- */
.mode-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--radius);
    padding: 3px;
    gap: 2px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.65);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.mode-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ---- Options Bar ---- */
.options-bar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.options-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.options-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.options-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Toggle Switch ---- */
.toggle-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.toggle-option input {
    display: none;
}

.toggle-switch {
    width: 34px;
    height: 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 9px;
    position: relative;
    transition: all 0.2s ease;
}

.toggle-switch::after {
    content: '';
    width: 12px;
    height: 12px;
    background: var(--text-dim);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: all 0.2s ease;
}

.toggle-option input:checked + .toggle-switch {
    background: var(--accent-solid);
    border-color: var(--accent-solid);
}

.toggle-option input:checked + .toggle-switch::after {
    left: 18px;
    background: white;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-solid);
    color: white;
    border-color: var(--accent-solid);
}

.btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

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

.btn-small {
    padding: 5px 10px;
    font-size: 0.75rem;
}

/* ---- Main Content ---- */
.main-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 24px 40px;
}

/* ---- Input Section ---- */
.input-section {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.input-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.panel-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.textarea-wrapper {
    display: flex;
    flex: 1;
    min-height: 280px;
}

.line-numbers {
    width: 44px;
    padding: 12px 8px 12px 4px;
    background: rgba(0, 0, 0, 0.15);
    border-right: 1px solid var(--border);
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.65;
    color: var(--text-dim);
    text-align: right;
    user-select: none;
    overflow: hidden;
    white-space: pre-line;
}

.input-panel textarea {
    flex: 1;
    padding: 12px 14px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.65;
    resize: none;
    tab-size: 4;
}

.input-panel textarea::placeholder {
    color: var(--text-dim);
}

.input-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 4px;
}

.btn-compare {
    padding: 12px 24px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius);
}

.btn-swap {
    padding: 8px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Stats Bar ---- */
.stats-bar {
    margin-top: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.stats-inner {
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.stat-additions {
    color: var(--diff-add-text);
}

.stat-deletions {
    color: var(--diff-del-text);
}

.stat-modifications {
    color: var(--diff-mod-text);
}

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

.stat-item span {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stat-spacer {
    flex: 1;
}

.nav-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-indicator {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    text-align: center;
}

.export-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    border-left: 1px solid var(--border);
    padding-left: 16px;
    margin-left: 4px;
}

/* ---- Diff Output ---- */
.diff-output {
    margin-top: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.diff-container {
    overflow-x: auto;
}

/* Side-by-side view */
.diff-side-by-side {
    display: flex;
    width: 100%;
}

.diff-pane {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
}

.diff-pane:first-child {
    border-right: 1px solid var(--border);
}

.diff-pane-header {
    padding: 8px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.1);
}

.diff-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.6;
}

.diff-table td {
    padding: 1px 10px;
    vertical-align: top;
    white-space: pre;
}

.diff-line-num {
    width: 44px;
    min-width: 44px;
    text-align: right;
    color: var(--text-dim);
    user-select: none;
    padding-right: 10px !important;
    border-right: 1px solid var(--border);
    font-size: 0.72rem;
}

.diff-line-content {
    padding-left: 12px !important;
}

/* Line type highlighting */
.diff-line-add {
    background: var(--diff-add-bg);
}

.diff-line-add .diff-line-num {
    color: var(--diff-add-text);
    border-right-color: var(--diff-add-border);
}

.diff-line-add .diff-line-content {
    color: var(--diff-add-text);
}

.diff-line-del {
    background: var(--diff-del-bg);
}

.diff-line-del .diff-line-num {
    color: var(--diff-del-text);
    border-right-color: var(--diff-del-border);
}

.diff-line-del .diff-line-content {
    color: var(--diff-del-text);
}

.diff-line-mod {
    background: var(--diff-mod-bg);
}

.diff-line-mod .diff-line-num {
    color: var(--diff-mod-text);
    border-right-color: var(--diff-mod-border);
}

.diff-line-mod .diff-line-content {
    color: var(--diff-mod-text);
}

.diff-line-empty {
    background: rgba(0, 0, 0, 0.15);
}

.diff-line-empty .diff-line-num {
    color: transparent;
}

.diff-line-separator {
    background: rgba(96, 165, 250, 0.06);
    border-top: 1px solid rgba(96, 165, 250, 0.12);
    border-bottom: 1px solid rgba(96, 165, 250, 0.12);
}

.diff-line-separator td {
    padding: 4px 10px;
    color: var(--accent);
    font-size: 0.72rem;
}

/* Unified view */
.diff-unified {
    width: 100%;
}

.diff-unified .diff-table {
    width: 100%;
}

.diff-unified .diff-line-prefix {
    width: 20px;
    min-width: 20px;
    text-align: center;
    user-select: none;
    font-weight: 600;
}

.diff-line-add .diff-line-prefix {
    color: var(--diff-add-text);
}

.diff-line-del .diff-line-prefix {
    color: var(--diff-del-text);
}

/* Inline word diff */
.word-add {
    background: var(--diff-word-add);
    border-radius: 2px;
    padding: 0 1px;
}

.word-del {
    background: var(--diff-word-del);
    border-radius: 2px;
    padding: 0 1px;
    text-decoration: line-through;
    opacity: 0.8;
}

/* Change highlight for navigation */
.diff-change-group {
    scroll-margin-top: 120px;
}

.diff-change-highlight {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* ---- Toast notification ---- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 10px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    font-size: 0.82rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    opacity: 0;
    transform: translateY(12px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .input-section {
        flex-direction: column;
    }

    .input-divider {
        flex-direction: row;
        padding: 8px 0;
    }

    .diff-side-by-side {
        flex-direction: column;
    }

    .diff-pane:first-child {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .stats-inner {
        gap: 12px;
    }

    .export-buttons {
        border-left: none;
        padding-left: 0;
        margin-left: 0;
    }

    .mode-toggle {
        flex-wrap: wrap;
    }

    .options-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}
