/*
   SQL FORMATTER & BEAUTIFIER — EXPERT WEB TOOLS
*/

/* Core Variables & Typography */
@font-face { font-family: 'Inter'; src: url('/fonts/inter-v20-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/jetbrains-mono-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
    /* Dark Theme (Default) */
    --bg-base: #0b0d10;
    --bg-surface: #14171d;
    --bg-surface-hover: #1f232b;
    --border-color: #272c36;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --success: #10b981;
    --error-bg: rgba(239, 68, 68, 0.1);
    --error-text: #ef4444;
    --editor-bg: #0f1115;
    --editor-text: #cbd5e1;
    --editor-out-bg: #000000;
    --input-bg: rgba(255, 255, 255, 0.05);
    
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* Light Theme Variables (Synchronized Architecture) */
html.light-theme {
    --bg-base: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --error-bg: rgba(239, 68, 68, 0.1);
    --error-text: #dc2626;
    --editor-bg: #ffffff;
    --editor-text: #334155;
    --editor-out-bg: #f8fafc;
    --input-bg: #f1f5f9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* STRICT CHROMIUM BUG FIX: transition background-color only */
html, body {
    background-color: var(--bg-base);
    transition: background-color 0.2s ease;
}

body { 
    color: var(--text-primary); 
    font-family: var(--font-ui); line-height: 1.6; 
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.hidden { display: none !important; }
.hide-desktop { display: none !important; }

/* Layout Architecture */
.studio-wrapper { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

.studio-header { 
    height: 60px; display: flex; justify-content: space-between; align-items: center; 
    padding: 0 1.5rem; background: var(--bg-surface); border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 15px; }
.back-link { color: var(--text-secondary); font-size: 1.2rem; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 6px; text-decoration: none; transition: 0.2s; }
.back-link:hover { color: var(--text-primary); background: var(--bg-surface-hover); }
.logo { font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.logo i { color: var(--accent-primary); }
.logo span { color: var(--text-primary); }
.header-actions { display: flex; align-items: center; gap: 15px; }

.privacy-badge { font-size: 0.8rem; padding: 4px 10px; border-radius: 999px; background: rgba(16, 185, 129, 0.1); color: var(--success); display: flex; align-items: center; gap: 6px; border: 1px solid rgba(16, 185, 129, 0.2); }

/* Sync'd Theme Toggle Button */
.theme-toggle-btn { 
    background: transparent; border: 1px solid var(--border-color); 
    color: var(--text-primary); width: 36px; height: 36px; border-radius: 8px; 
    cursor: pointer; display: flex; align-items: center; justify-content: center; 
    transition: all 0.2s ease; 
}
.theme-toggle-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); }

/* Buttons & Selects */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0.6rem 1.4rem; border-radius: 9999px; font-weight: 500; cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); border: none; font-family: var(--font-ui); min-height: 44px; }
.btn-primary { background: linear-gradient(180deg, var(--accent-primary) 0%, #1d4ed8 100%); color: #ffffff; box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #5b9af8 0%, #2563eb 100%); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-surface-hover); }
.btn-sm { min-height: 32px; padding: 0.3rem 0.85rem; font-size: 0.85rem; }

.format-select { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-color); padding: 6px 12px; border-radius: 6px; font-family: var(--font-ui); font-size: 0.9rem; font-weight: 500; outline: none; cursor: pointer; transition: 0.2s; }
.format-select:focus { border-color: var(--accent-primary); }

.config-toggles { display: flex; gap: 15px; align-items: center; flex-wrap: wrap; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-secondary); cursor: pointer; user-select: none; }
.checkbox-label input { accent-color: var(--accent-primary); width: 16px; height: 16px; cursor: pointer; }

/* Layout Architecture */
.split-layout { display: flex; min-height: 600px; height: calc(100vh - 60px); overflow: hidden; position: relative; }
.pane { flex: 1; display: flex; flex-direction: column; padding: 1.5rem; overflow: hidden; position: relative; }
.pane-left { background: var(--bg-base); border-right: 1px solid var(--border-color); }
.pane-right { background: var(--bg-surface); }
.pane-header { margin-bottom: 1rem; display: flex; flex-direction: column; flex-shrink: 0; }
.pane-title-row { display: flex; justify-content: space-between; align-items: center; min-height: 32px; }
.pane-title-row h2 { font-size: 1rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }

/* Editors */
.editor-wrapper { flex: 1; display: flex; position: relative; min-height: 250px; }
.code-editor { 
    width: 100%; height: 100%; resize: none; font-family: var(--font-mono); font-size: 0.95rem;
    background: var(--editor-bg); color: var(--editor-text); border: 1px solid var(--border-color); 
    border-radius: 8px; padding: 1rem; outline: none; transition: border-color 0.2s;
    line-height: 1.6; white-space: pre; overflow-wrap: normal; overflow-x: auto;
    position: relative; z-index: 2; 
}
.code-editor:focus { border-color: var(--accent-primary); }
.output-editor { background: var(--editor-out-bg); }

/* Overlays */
.empty-overlay, .loading-overlay { 
    position: absolute; inset: 0; display: flex; flex-direction: column; 
    align-items: center; justify-content: center; background: rgba(11,13,16,0.6);
    backdrop-filter: blur(4px); border-radius: 8px; color: var(--text-secondary);
    transition: opacity 0.2s; z-index: 3; pointer-events: none;
}
html.light-theme .empty-overlay, html.light-theme .loading-overlay { background: rgba(255,255,255,0.7); }
.empty-overlay i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.editor-wrapper.dragover .empty-overlay { background: rgba(59, 130, 246, 0.1); color: var(--accent-primary); border: 2px dashed var(--accent-primary); }

.code-editor:focus + .empty-overlay,
.editor-wrapper.has-content .empty-overlay { opacity: 0; pointer-events: none; }

/* Error Banner */
.error-banner {
    background: var(--error-bg); color: var(--error-text);
    padding: 10px 15px; border-radius: 6px; margin-top: 10px;
    font-size: 0.85rem; font-family: var(--font-mono); font-weight: 500;
    display: none; align-items: flex-start; gap: 10px;
    border: 1px solid rgba(239, 68, 68, 0.3); word-break: break-word;
}
.error-banner.show { display: flex; }
.error-banner i { margin-top: 2px; }

/* Desktop Action Area */
.desktop-action-area { display: flex; gap: 12px; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border-color); justify-content: flex-end; flex-shrink: 0; }

/* SEO Content */
.seo-content { background: var(--bg-base); padding: 4rem 1.5rem; border-top: 1px solid var(--border-color); }
.seo-container { max-width: 800px; margin: 0 auto; }
.seo-container h2 { font-size: 1.8rem; margin-bottom: 1rem; color: var(--text-primary); margin-top: 2.5rem; }
.seo-container h2:first-child { margin-top: 0; }
.seo-container p { color: var(--text-secondary); margin-bottom: 1.5rem; font-size: 1.05rem; }
.seo-container code { background: var(--bg-surface-hover); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.9em; color: var(--accent-primary); border: 1px solid var(--border-color); }
html.light-theme .seo-container code { background: rgba(0,0,0,0.05); }

.faq-grid { display: grid; gap: 20px; margin-top: 1.5rem; }
.faq-item { background: var(--bg-surface); padding: 1.5rem; border-radius: 8px; border: 1px solid var(--border-color); }
.faq-item h3 { font-size: 1.2rem; margin-bottom: 0.8rem; }
.faq-item p { margin-bottom: 0; font-size: 0.95rem; }

/* Toast */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translate(-50%, 100px); background: var(--text-primary); color: var(--bg-base); padding: 12px 24px; border-radius: 8px; font-weight: 600; box-shadow: 0 10px 25px rgba(0,0,0,0.5); opacity: 0; transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55); z-index: 1000; pointer-events: none; }
html.light-theme .toast { background: #1e1e24; color: #fff; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.mobile-bottom-nav { display: none; }

/* Mobile Strict Tabbed Viewport */
@media (max-width: 900px) {
    .hide-mobile { display: none !important; }
    .hide-desktop { display: flex !important; } 

    .studio-wrapper { height: auto; }
    .split-layout { height: calc(100vh - 60px - 70px); min-height: 400px; } /* header - nav */
    
    .pane { padding: 1rem; border: none; }
    
    /* Tab Logic */
    .pane:not(.active-tab) { display: none !important; }

    .editor-wrapper { min-height: 200px; }
    .code-editor { font-size: 0.85rem; padding: 0.75rem; }
    
    .pane-title-row { flex-direction: column; align-items: flex-start; gap: 10px; }
    .config-toggles { width: 100%; justify-content: space-between; border-top: 1px solid var(--border-color); padding-top: 10px; }

    /* Native Bottom Nav */
    .mobile-bottom-nav { 
        position: fixed; bottom: 0; left: 0; right: 0; height: 70px;
        background: var(--bg-surface);
        display: flex; border-top: 1px solid var(--border-color); z-index: 900; 
        padding-bottom: env(safe-area-inset-bottom);
    }
    .nav-divider { width: 1px; background: var(--border-color); margin: 10px 0; }
    .nav-btn {
        flex: 1; background: transparent; border: none; color: var(--text-secondary);
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        font-size: 0.7rem; font-family: var(--font-ui); cursor: pointer; gap: 4px; transition: color 0.2s;
    }
    .nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
    .nav-btn.active { color: var(--accent-primary); }
    .nav-btn i { font-size: 1.2rem; }
}