/* ================================================================= */
/* HYDRATION STATION — Dark Theme                                    */
/* ================================================================= */

:root {
    --bg-dark: #1e1e1e;
    --bg-sidebar: #252526;
    --bg-card: #2d2d30;
    --bg-input: #3c3c3c;
    --bg-hover: #37373d;
    --bg-selected: #094771;
    --border: #3e3e42;
    --border-light: #4e4e52;
    --primary: #4ec9b0;
    --primary-dark: #3ba892;
    --primary-glow: rgba(78, 201, 176, 0.15);
    --text-primary: #cccccc;
    --text-secondary: #969696;
    --text-bright: #e0e0e0;
    --text-muted: #6a6a6a;
    --accent-blue: #569cd6;
    --accent-yellow: #dcdcaa;
    --danger: #f14c4c;
    --danger-bg: rgba(241, 76, 76, 0.1);
    --success: #4ec9b0;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    --radius: 6px;
    --radius-sm: 4px;
}

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

body {
    font-family: var(--font);
    background: var(--bg-dark);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ================================================================= */
/* SIDEBAR                                                           */
/* ================================================================= */

#sidebar {
    width: 240px;
    min-width: 180px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

#sidebar-header h1 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 12px;
    letter-spacing: 0.3px;
}

#btn-get-data {
    width: 100%;
    padding: 8px 12px;
    background: var(--primary);
    color: #1e1e1e;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    transition: background 0.15s;
}

#btn-get-data:hover {
    background: var(--primary-dark);
}

.btn-icon {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}

#sidebar-section-label {
    padding: 10px 16px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.8px;
}

#query-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

#query-list li {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
    position: relative;
}

#query-list li:hover {
    background: var(--bg-hover);
}

#query-list li.active {
    background: var(--bg-selected);
    color: var(--text-bright);
}

#query-list li .query-icon {
    color: var(--primary);
    font-size: 11px;
    flex-shrink: 0;
}

#query-list li .query-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#query-list li .query-delete {
    opacity: 0;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 3px;
    transition: opacity 0.1s, color 0.1s;
}

#query-list li:hover .query-delete {
    opacity: 1;
}

#query-list li .query-delete:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

#query-list li.empty-state {
    color: var(--text-muted);
    font-size: 12px;
    cursor: default;
    padding: 16px 10px;
    line-height: 1.5;
}

#query-list li.empty-state:hover {
    background: none;
}

/* ================================================================= */
/* SPLIT GUTTER                                                      */
/* ================================================================= */

.gutter {
    background: var(--border);
    cursor: col-resize;
}

.gutter.gutter-horizontal {
    cursor: col-resize;
}

.gutter.gutter-vertical {
    cursor: row-resize;
}

/* ================================================================= */
/* MAIN CONTENT                                                      */
/* ================================================================= */

#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Grid Pane */
#grid-pane {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

#data-grid {
    width: 100%;
    height: 100%;
}

.pane-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 8px;
}

.pane-empty .empty-icon {
    font-size: 48px;
    opacity: 0.3;
}

.pane-empty p {
    font-size: 14px;
}

/* Editor Pane */
#editor-pane {
    height: 200px;
    min-height: 80px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#editor-header {
    height: 34px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    flex-shrink: 0;
}

.editor-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#btn-hydrate {
    padding: 4px 14px;
    background: var(--primary);
    color: #1e1e1e;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

#btn-hydrate:hover {
    background: var(--primary-dark);
}

#editor-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

#sql-editor {
    flex: 1;
    overflow: hidden;
}

/* ================================================================= */
/* SCHEDULE PANEL                                                    */
/* ================================================================= */

#schedule-panel {
    width: 220px;
    min-width: 180px;
    border-left: 1px solid var(--border);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
}

.schedule-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 10px 14px 8px;
    border-bottom: 1px solid var(--border);
}

.schedule-notice {
    padding: 14px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.schedule-notice.hidden {
    display: none;
}

#schedule-controls {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#schedule-controls.hidden {
    display: none;
}

.schedule-label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

#schedule-select {
    background: var(--bg-input);
    color: var(--text-bright);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    font-family: var(--font);
    font-size: 12px;
    outline: none;
    cursor: pointer;
}

#schedule-select:focus {
    border-color: var(--primary);
}

#schedule-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.schedule-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.schedule-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.schedule-key {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
}

.schedule-val {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    word-break: break-all;
}

/* CodeMirror overrides for dark theme */
.CodeMirror {
    height: 100% !important;
    background: var(--bg-dark) !important;
    font-family: var(--font-mono) !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
}

/* Applied Steps */
#applied-steps {
    height: 32px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 6px;
    flex-shrink: 0;
    overflow-x: auto;
}

.steps-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    margin-right: 4px;
}

.step {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--bg-input);
    color: var(--text-secondary);
    white-space: nowrap;
}

.step.active {
    background: var(--primary-glow);
    color: var(--primary);
    font-weight: 500;
}

.step-arrow {
    color: var(--text-muted);
    font-size: 12px;
    flex-shrink: 0;
}

/* ================================================================= */
/* AG GRID DARK OVERRIDES                                            */
/* ================================================================= */

.ag-theme-alpine-dark {
    --ag-background-color: var(--bg-dark);
    --ag-header-background-color: var(--bg-card);
    --ag-odd-row-background-color: #232323;
    --ag-row-hover-color: var(--bg-hover);
    --ag-border-color: var(--border);
    --ag-header-foreground-color: var(--text-bright);
    --ag-foreground-color: var(--text-primary);
    --ag-font-family: var(--font);
    --ag-font-size: 13px;
    --ag-row-height: 32px;
    --ag-header-height: 36px;
}

/* Custom header component styles */
.custom-header {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    height: 100%;
    padding: 0 4px;
}

.custom-header .type-icon {
    font-size: 10px;
    color: var(--primary);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.1s, background 0.1s;
}

.custom-header .type-icon:hover {
    opacity: 1;
    background: var(--bg-hover);
}

.custom-header .header-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
    font-weight: 500;
}

.custom-header .header-edit-input {
    flex: 1;
    background: var(--bg-input);
    color: var(--text-bright);
    border: 1px solid var(--primary);
    border-radius: 3px;
    padding: 2px 6px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    outline: none;
}

/* ================================================================= */
/* MODAL                                                             */
/* ================================================================= */

#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

#modal-overlay.hidden {
    display: none;
}

#get-data-modal {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: 520px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-bright);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: color 0.1s, background 0.1s;
}

.modal-close:hover {
    color: var(--text-bright);
    background: var(--bg-hover);
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    padding: 0 20px;
    gap: 0;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 13px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

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

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 20px;
}

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

.tab-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* File drop zone */
.file-drop-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.file-drop-zone:hover,
.file-drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.file-drop-zone .drop-icon {
    font-size: 36px;
    margin-bottom: 8px;
    opacity: 0.5;
}

.file-drop-zone p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.file-drop-zone .file-types {
    font-size: 11px;
    color: var(--text-muted);
}

/* Form grid */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.form-grid label:has(textarea),
.form-grid label:has(.checkbox-label),
.form-grid label:nth-last-child(1):nth-child(odd) {
    grid-column: 1 / -1;
}

.checkbox-label {
    grid-column: 1 / -1;
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
}

.form-grid input[type="text"],
.form-grid input[type="password"],
.form-grid textarea {
    background: var(--bg-input);
    color: var(--text-bright);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-family: var(--font);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}

.form-grid input:focus,
.form-grid textarea:focus {
    border-color: var(--primary);
}

.form-grid textarea {
    font-family: var(--font-mono);
    font-size: 12px;
    resize: vertical;
}

.btn-connect {
    width: 100%;
    padding: 10px;
    background: var(--primary);
    color: #1e1e1e;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-connect:hover {
    background: var(--primary-dark);
}

/* Modal loading / error */
#modal-loading {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

#modal-loading.hidden,
#modal-error.hidden {
    display: none;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

#modal-error {
    margin: 0 20px 16px;
    padding: 10px 14px;
    background: var(--danger-bg);
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 12px;
    font-family: var(--font-mono);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ================================================================= */
/* TYPE CHANGE CONTEXT MENU                                          */
/* ================================================================= */

#type-menu {
    position: fixed;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    min-width: 160px;
}

#type-menu.hidden {
    display: none;
}

.type-menu-item {
    padding: 7px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.1s;
}

.type-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-bright);
}

/* ================================================================= */
/* SCROLLBAR                                                         */
/* ================================================================= */

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

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

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

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

/* ================================================================= */
/* TOAST NOTIFICATIONS                                               */
/* ================================================================= */

#toast-container {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-bright);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.2s ease;
    max-width: 360px;
}

.toast.success { background: #1a3a2a; border: 1px solid var(--success); }
.toast.error { background: #3a1a1a; border: 1px solid var(--danger); }
.toast.info { background: #1a2a3a; border: 1px solid var(--accent-blue); }

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