/* ===========================
   Schema Diff Viewer - Styles
   Dark Indigo Deep Palette
   =========================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Tokens ─────────────────────────────────────── */
:root {
    --bg: #0F0F24;
    --bg2: #16162f;
    --bg3: #1e1e3f;
    --surface: rgba(30, 30, 63, 0.7);
    --border: rgba(99, 102, 241, 0.2);
    --border-h: rgba(99, 102, 241, 0.5);
    --primary: #6366F1;
    --primary-h: #4F46E5;
    --secondary: #818CF8;
    --accent: #FCD34D;
    --added: #10B981;
    --removed: #EF4444;
    --modified: #F59E0B;
    --unchanged: #6B7280;
    --text: #E2E8F0;
    --text-muted: #94A3B8;
    --radius: 12px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --glow: 0 0 20px rgba(99, 102, 241, 0.25);
}

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

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

/* Animated mesh bg */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 0%, rgba(99, 102, 241, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 100%, rgba(129, 140, 248, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ── Layout ─────────────────────────────────────────── */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

/* ── Header ─────────────────────────────────────────── */
header {
    padding: 28px 0 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

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

.logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: var(--glow);
}

.logo h1 {
    font-size: 1.35rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--text), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo .subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    -webkit-text-fill-color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-h));
    color: #fff;
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

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

.btn-secondary:hover {
    border-color: var(--border-h);
    background: var(--surface);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--border-h);
}

.btn-accent {
    background: linear-gradient(135deg, #F59E0B, var(--accent));
    color: #0F0F24;
    font-weight: 600;
}

.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(252, 211, 77, 0.3);
}

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

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

.schema-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    backdrop-filter: blur(12px);
    transition: border-color 0.2s;
}

.schema-panel:focus-within {
    border-color: var(--border-h);
    box-shadow: var(--glow);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.panel-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.panel-label .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot-a {
    background: var(--secondary);
}

.dot-b {
    background: var(--accent);
}

.schema-textarea {
    width: 100%;
    height: 260px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.7;
    padding: 14px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.schema-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.schema-textarea:focus {
    border-color: var(--primary);
}

/* ── Controls Bar ───────────────────────────────────── */
.controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 28px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(12px);
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.dialect-select {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.875rem;
    padding: 8px 12px;
    cursor: pointer;
    outline: none;
}

.dialect-select:focus {
    border-color: var(--primary);
}

.filter-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pill {
    padding: 5px 13px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.18s ease;
    background: var(--bg3);
    color: var(--text-muted);
}

.pill:hover {
    color: var(--text);
}

.pill.active-added {
    background: rgba(16, 185, 129, 0.15);
    color: var(--added);
    border-color: rgba(16, 185, 129, 0.4);
}

.pill.active-removed {
    background: rgba(239, 68, 68, 0.15);
    color: var(--removed);
    border-color: rgba(239, 68, 68, 0.4);
}

.pill.active-modified {
    background: rgba(245, 158, 11, 0.15);
    color: var(--modified);
    border-color: rgba(245, 158, 11, 0.4);
}

.pill.active-all {
    background: rgba(99, 102, 241, 0.15);
    color: var(--secondary);
    border-color: var(--border-h);
}

/* ── Summary Stats ──────────────────────────────────── */
.stats-bar {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.stat-card {
    flex: 1;
    min-width: 120px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(12px);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-added {
    color: var(--added);
    border-top: 3px solid var(--added);
}

.stat-removed {
    color: var(--removed);
    border-top: 3px solid var(--removed);
}

.stat-modified {
    color: var(--modified);
    border-top: 3px solid var(--modified);
}

.stat-total {
    color: var(--secondary);
    border-top: 3px solid var(--primary);
}

/* ── Tabs ───────────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    padding: 4px;
    background: var(--bg3);
    border-radius: var(--radius-sm);
    width: fit-content;
}

.tab-btn {
    padding: 8px 20px;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.tab-btn:hover:not(.active) {
    color: var(--text);
}

/* ── Diff Results ───────────────────────────────────── */
.diff-view {
    display: none;
}

.diff-view.active {
    display: block;
}

.diff-table-section {
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    backdrop-filter: blur(12px);
    transition: box-shadow 0.2s;
}

.diff-table-section:hover {
    box-shadow: var(--glow);
}

.table-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--bg3);
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
}

.table-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.95rem;
}

.change-badge {
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.badge-added {
    background: rgba(16, 185, 129, 0.2);
    color: var(--added);
}

.badge-removed {
    background: rgba(239, 68, 68, 0.2);
    color: var(--removed);
}

.badge-modified {
    background: rgba(245, 158, 11, 0.2);
    color: var(--modified);
}

.badge-unchanged {
    background: rgba(107, 114, 128, 0.2);
    color: var(--unchanged);
}

.collapse-icon {
    color: var(--text-muted);
    transition: transform 0.2s;
    font-size: 0.75rem;
}

.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.table-section-body {
    padding: 16px 20px;
}

.table-section-body.hidden {
    display: none;
}

/* ── Column Diff ────────────────────────────────────── */
.diff-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

@media (max-width: 640px) {
    .diff-grid {
        grid-template-columns: 1fr;
    }
}

.diff-column-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.diff-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.diff-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.4;
}

.diff-row.added {
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid var(--added);
}

.diff-row.removed {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--removed);
}

.diff-row.modified {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid var(--modified);
}

.diff-row.unchanged {
    background: rgba(30, 30, 63, 0.4);
    border-left: 3px solid transparent;
}

.diff-sign {
    font-weight: 700;
    font-size: 0.9rem;
    min-width: 14px;
    text-align: center;
}

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

.diff-row.removed .diff-sign {
    color: var(--removed);
}

.diff-row.modified .diff-sign {
    color: var(--modified);
}

.col-name {
    font-weight: 500;
    color: var(--text);
}

.col-type {
    color: var(--secondary);
    margin-left: 6px;
}

.col-constraints {
    color: var(--text-muted);
    font-size: 0.72rem;
}

/* ── Index / Constraint Diff ───────────────────────── */
.section-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 14px 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Migration SQL ──────────────────────────────────── */
.migration-view pre {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.8;
    overflow-x: auto;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.sql-keyword {
    color: var(--primary);
    font-weight: 600;
}

.sql-table {
    color: var(--accent);
}

.sql-type {
    color: var(--secondary);
}

.sql-comment {
    color: var(--text-muted);
    font-style: italic;
}

.sql-op-add {
    color: var(--added);
}

.sql-op-drop {
    color: var(--removed);
}

/* ── ER Diagram ──────────────────────────────────────  */
.er-view {
    position: relative;
    overflow: auto;
    min-height: 300px;
}

#er-canvas {
    display: block;
    margin: 0 auto;
    border-radius: var(--radius-sm);
}

/* ── Empty / Placeholder ────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p {
    font-size: 0.875rem;
    max-width: 400px;
    margin: 0 auto;
}

/* ── Toast ──────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
}

.toast {
    padding: 12px 20px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    box-shadow: var(--shadow);
    animation: slide-in 0.25s ease;
    max-width: 320px;
}

.toast.success {
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--added);
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--removed);
}

@keyframes slide-in {
    from {
        transform: translateX(40px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ── Loading spinner ────────────────────────────────── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(99, 102, 241, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
    display: none;
}

.loading .spinner {
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

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

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

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

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 600px) {
    .stats-bar {
        gap: 8px;
    }

    .stat-card {
        min-width: 80px;
        padding: 12px;
    }

    .stat-number {
        font-size: 1.4rem;
    }

    .controls-bar {
        padding: 12px;
    }

    header {
        padding: 20px 0 16px;
    }
}