/* styles.css */
:root {
    /* Coral Reef Palette */
    --primary: #E17055;
    --primary-hover: #d26046;
    --secondary: #FAB1A0;
    --accent: #00CEC9;
    --accent-hover: #00b5b1;
    --bg-main: #2D1B16;
    --bg-panel: rgba(58, 38, 33, 0.6); /* Glassmorphism base */
    --bg-panel-hover: rgba(58, 38, 33, 0.8);
    --border-color: rgba(250, 177, 160, 0.15);
    
    --text-primary: #fdf6f5;
    --text-secondary: #e0bbae;
    --text-muted: #a38278;
    
    --danger: #ff7675;
    --success: #55efc4;
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(225, 112, 85, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(0, 206, 201, 0.08), transparent 25%);
    min-height: 100vh;
    overflow: hidden; /* App-like feel, no global scroll */
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
}

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
    padding: 1rem;
    gap: 1rem;
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        overflow-y: auto;
    }
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.input-section {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-section h3, .section-header h3, .panel-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Tabs */
.tabs {
    display: flex;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
}

.tabs.small {
    background: transparent;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.5rem;
    color: var(--text-muted);
    font-family: inherit;
    font-weight: 500;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn.active {
    background: var(--bg-panel-hover);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.tab-content {
    display: none;
    flex-direction: column;
    gap: 1rem;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.input-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

input[type="text"], textarea {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    transition: var(--transition);
}

input[type="text"]:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(225, 112, 85, 0.2);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* File Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 2rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--secondary);
    background: rgba(250, 177, 160, 0.05);
}

.upload-area i {
    font-size: 2rem;
    color: var(--text-muted);
}

.upload-area p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

input[type="file"] {
    display: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(225, 112, 85, 0.3);
}

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

.btn-secondary:hover {
    background: rgba(255,255,255,0.1);
}

.btn-danger {
    background: rgba(255, 118, 117, 0.1);
    color: var(--danger);
    border: 1px solid rgba(255, 118, 117, 0.2);
}

.btn-danger:hover {
    background: rgba(255, 118, 117, 0.2);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.w-full {
    width: 100%;
}

/* Migrations List */
.migrations-list-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section-header {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.migrations-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.migration-item {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    animation: fadeIn 0.3s ease;
}

.migration-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.migration-name {
    font-weight: 500;
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', monospace;
    word-break: break-all;
}

.migration-deps {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Workspace */
.workspace {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}

/* Toolbar */
.toolbar {
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0,0,0,0.2);
    padding: 0.4rem 0.75rem;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

.stat-badge.success i { color: var(--success); }
.stat-badge.danger { border-color: rgba(255, 118, 117, 0.3); }
.stat-badge.danger i { color: var(--danger); }

/* Dropdown menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.5rem;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    min-width: 160px;
    z-index: 100;
    overflow: hidden;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu button {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-menu button:hover {
    background: rgba(255,255,255,0.05);
}

/* Network Canvas */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 300px;
}

/* Prevent Vis.js canvas outline */
.vis-network:focus {
    outline: none;
}

.empty-state, .empty-state-large, .empty-timeline {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    justify-content: center;
    height: 100%;
}

.empty-state-large i {
    font-size: 3rem;
    color: var(--border-color);
}

/* Timeline Panel */
.timeline-panel {
    height: 200px;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeline-content {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1rem 1.5rem;
}

.timeline-view {
    display: none;
    white-space: nowrap;
    height: 100%;
    align-items: center;
    gap: 1.5rem;
}

.timeline-view.active {
    display: flex;
}

.timeline-step {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.timeline-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 1rem;
    left: calc(100% + 0.2rem);
    width: 1.1rem;
    height: 2px;
    background: var(--border-color);
}

.step-node {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    background: var(--bg-panel-hover);
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    z-index: 2;
}

.step-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay:not(.hidden) .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    word-break: break-all;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.meta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background: rgba(0,0,0,0.3);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.modal-body pre {
    background: rgba(0,0,0,0.3);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #e2e8f0;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

/* Tooltip */
.tooltip {
    position: relative;
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: max-content;
    background-color: #1e293b;
    color: #fff;
    text-align: center;
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    position: absolute;
    z-index: 10;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Toast Container */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.9rem;
    transform: translateY(50px);
    opacity: 0;
    animation: toastSlideIn 0.3s forwards, toastSlideOut 0.3s forwards 3s;
}

.toast.error { border-left: 4px solid var(--danger); }
.toast.success { border-left: 4px solid var(--success); }
.toast.info { border-left: 4px solid var(--accent); }

.toast i { font-size: 1.2rem; }
.toast.error i { color: var(--danger); }
.toast.success i { color: var(--success); }
.toast.info i { color: var(--accent); }

@keyframes toastSlideIn {
    to { transform: translateY(0); opacity: 1; }
}
@keyframes toastSlideOut {
    to { transform: translateY(-20px); opacity: 0; }
}

/* Helper utility for text colors */
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
