:root {
    --primary: #0EA5E9;
    --primary-hover: #0284C7;
    --secondary: #38BDF8;
    --accent: #A78BFA;
    --bg-dark: #0C1222;
    --bg-panel: rgba(15, 23, 42, 0.7);
    --bg-surface: rgba(30, 41, 59, 0.5);
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --border-color: rgba(14, 165, 233, 0.2);
    --radius: 12px;

    /* Semantic Colors */
    --color-added: #10B981;
    --color-removed: #EF4444;
    --color-modified: #F59E0B;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(14, 165, 233, 0.1), transparent 30%),
        radial-gradient(circle at 100% 100%, rgba(167, 139, 250, 0.05), transparent 30%);
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.btn {
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.3);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.secondary-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
}

.text-btn {
    background: transparent;
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
}

.text-btn:hover:not(:disabled) {
    color: var(--color-removed);
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 0.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover:not(:disabled) {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(14, 165, 233, 0.1);
}

.icon-btn.active {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(14, 165, 233, 0.1);
}

.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.main-layout {
    display: flex;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
}

/* Sidebar Styles */
.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.control-group {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.control-group h2 {
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.file-upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    position: relative;
    transition: all 0.2s;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.file-upload-zone:hover,
.file-upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(14, 165, 233, 0.05);
    color: var(--primary);
}

.file-upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.or-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1rem 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.or-divider::before,
.or-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.or-divider span {
    padding: 0 0.5rem;
}

textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    padding: 0.75rem;
    font-family: 'Fira Code', ui-monospace, SFMono-Regular, monospace;
    font-size: 0.8rem;
    resize: none;
    outline: none;
    transition: all 0.2s;
    margin-bottom: 1rem;
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

.options-row {
    display: flex;
    gap: 0.5rem;
}

.form-select {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    padding: 0.5rem;
    outline: none;
    font-size: 0.85rem;
}

.timeline-list-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.timeline-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.timeline-item {
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--primary);
    padding: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    padding-left: 2rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.timeline-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.timeline-item.active {
    background: rgba(14, 165, 233, 0.1);
    border-color: rgba(14, 165, 233, 0.3);
}

.timeline-item-title {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-item-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'Fira Code', monospace;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
    padding: 1.5rem 0;
}

/* Visualization Space */
.visualization {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    padding: 1.5rem;
}

.viz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    z-index: 10;
}

.viz-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

.viz-controls {
    display: flex;
    gap: 0.5rem;
}

.viz-container {
    flex: 1;
    overflow: auto;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: none;
    padding: 1.5rem;
}

.viz-container.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.empty-viz {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

/* Diagram Components */
.schema-table {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 260px;
    position: absolute;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    animation: slideUpFade 0.4s forwards;
}

.schema-table.modified {
    border-color: var(--color-modified);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

.schema-table.added {
    border-color: var(--color-added);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.table-header {
    background: rgba(14, 165, 233, 0.15);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
}

.table-header.modified {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
}

.table-header.added {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
}

.column-list {
    list-style: none;
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    padding: 0.5rem 0;
}

.column-item {
    padding: 0.25rem 0.75rem;
    display: flex;
    justify-content: space-between;
    transition: background 0.2s;
}

.column-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.column-item.added {
    color: var(--color-added);
}

.column-item.removed {
    color: var(--color-removed);
    text-decoration: line-through;
    opacity: 0.7;
}

.column-item.modified {
    color: var(--color-modified);
}

.col-name {
    font-weight: 500;
}

.col-type {
    color: var(--text-muted);
}

.column-item.added .col-type {
    color: var(--color-added);
    opacity: 0.8;
}

.column-item.modified .col-type {
    color: var(--color-modified);
    opacity: 0.8;
}

.pk-icon {
    color: var(--secondary);
    margin-right: 4px;
    font-size: 0.7rem;
}

/* Diff View */
.diff-content {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
}

.diff-table {
    margin-bottom: 1.5rem;
    background: var(--bg-surface);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.diff-table-name {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-family: 'Inter', sans-serif;
}

.diff-row {
    padding: 0.25rem 1rem;
    display: flex;
}

.diff-row.add {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-added);
}

.diff-row.add::before {
    content: '+ ';
    margin-right: 0.5rem;
}

.diff-row.remove {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-removed);
}

.diff-row.remove::before {
    content: '- ';
    margin-right: 0.5rem;
}

.diff-row.modify {
    background: rgba(245, 158, 11, 0.1);
    color: var(--color-modified);
}

.diff-row.modify::before {
    content: '~ ';
    margin-right: 0.5rem;
}


/* Timeline Controls */
.timeline-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-surface);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0 0 12px 12px;
    margin-top: 1rem;
}

.timeline-controls.hidden {
    display: none;
}

.slider-wrapper {
    flex: 1;
    position: relative;
    padding: 10px 0;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    position: relative;
    z-index: 2;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 0 10px rgba(14, 165, 233, 0.5);
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

input[type=range]:focus {
    outline: none;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive */
@media (max-width: 900px) {
    .main-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 300px;
    }
}