/* ══════════════════════════════════════════════════════════════
   Table Diff Viewer — Premium Dark Mode
   ══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --primary: #8B5CF6;
    --primary-light: #A78BFA;
    --primary-dim: rgba(139, 92, 246, 0.15);
    --added: #10B981;
    --added-dim: rgba(16, 185, 129, 0.12);
    --added-bg: rgba(16, 185, 129, 0.08);
    --removed: #EF4444;
    --removed-dim: rgba(239, 68, 68, 0.12);
    --removed-bg: rgba(239, 68, 68, 0.08);
    --modified: #F59E0B;
    --modified-dim: rgba(245, 158, 11, 0.12);
    --modified-bg: rgba(245, 158, 11, 0.08);
    --bg: #0F172A;
    --bg-card: rgba(30, 41, 59, 0.6);
    --bg-input: rgba(15, 23, 42, 0.9);
    --border: rgba(139, 92, 246, 0.12);
    --border-focus: rgba(139, 92, 246, 0.5);
    --text: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-dim: #64748B;
    --glass: rgba(255, 255, 255, 0.04);
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

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

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 20% 10%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 90%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
    pointer-events: none;
}

.app {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0 20px;
    flex-wrap: wrap;
    gap: 12px;
}

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

.header__icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--added));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
}

.header__title {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header__subtitle {
    font-size: 13px;
    color: var(--text-dim);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn--primary {
    background: linear-gradient(135deg, var(--primary), #7C3AED);
    color: #fff;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
}

.btn--secondary {
    background: var(--glass);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.btn--small {
    padding: 7px 14px;
    font-size: 12px;
}

/* Input Section */
.input-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.input-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    backdrop-filter: blur(16px);
}

.input-panel__title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-panel__title span {
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 400;
}

.input-panel textarea {
    width: 100%;
    height: 160px;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    resize: vertical;
    transition: var(--transition);
}

.input-panel textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

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

/* Key Column Selector */
.config-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.config-bar label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.config-bar select {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.stat-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.stat-chip--added {
    background: var(--added-dim);
    color: var(--added);
}

.stat-chip--removed {
    background: var(--removed-dim);
    color: var(--removed);
}

.stat-chip--modified {
    background: var(--modified-dim);
    color: var(--modified);
}

.stat-chip--total {
    background: var(--primary-dim);
    color: var(--primary-light);
}

/* Diff Table */
.diff-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.diff-table-wrapper {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.diff-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

.diff-table th {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 2px solid var(--border);
}

.diff-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.06);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.diff-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Row states */
.diff-row--added {
    background: var(--added-bg);
}

.diff-row--added td {
    color: var(--added);
}

.diff-row--removed {
    background: var(--removed-bg);
}

.diff-row--removed td {
    color: var(--removed);
    text-decoration: line-through;
    opacity: 0.75;
}

.diff-row--modified {
    background: var(--modified-bg);
}

/* Cell states */
.diff-cell--changed {
    background: var(--modified-dim);
    color: var(--modified);
    font-weight: 600;
    position: relative;
}

.diff-cell--old {
    text-decoration: line-through;
    opacity: 0.6;
    font-size: 10px;
    display: block;
    color: var(--removed);
}

/* Status indicator */
.diff-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
}

.diff-status--added {
    background: var(--added);
}

.diff-status--removed {
    background: var(--removed);
}

.diff-status--modified {
    background: var(--modified);
}

.diff-status--unchanged {
    background: var(--text-dim);
    opacity: 0.3;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}

.empty-state__icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state__title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-state__text {
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    box-shadow: var(--shadow);
}

.toast--success {
    background: rgba(16, 185, 129, 0.9);
}

.toast--error {
    background: rgba(239, 68, 68, 0.9);
}

@keyframes toastIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes toastOut {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .input-section {
        grid-template-columns: 1fr;
    }

    .stats-bar {
        gap: 8px;
    }

    .stat-chip {
        padding: 4px 10px;
        font-size: 12px;
    }
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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