/* DaiBai GUI - Modern AI Chat Interface */

:root {
    /* Colors - Dark Theme */
    --bg-primary: #0d0d0d;
    --bg-secondary: #171717;
    --bg-tertiary: #212121;
    --bg-hover: #2a2a2a;
    --bg-active: #343434;
    
    --text-primary: #ececec;
    --text-secondary: #a1a1a1;
    --text-muted: #6b6b6b;
    
    --accent: #10a37f;
    --accent-hover: #0d8a6a;
    --accent-light: rgba(16, 163, 127, 0.1);
    
    --border: #2e2e2e;
    --border-light: #3a3a3a;
    
    --error: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --playground-purple: #7c3aed;
    --playground-purple-hover: #6d28d9;
    --playground-purple-light: rgba(124, 58, 237, 0.15);
    
    /* Spacing */
    --sidebar-width: 260px;
    --inspector-width: 25vw;
    --inspector-min-width: 320px;
    --topnav-height: 56px;
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
}


/* Guest Mode Banner */
.guest-banner {
    margin: 12px;
    padding: 14px 16px;
    background: var(--bg-tertiary, #1e2130);
    border: 1px solid var(--border-color, #2d3250);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.guest-banner p {
    margin: 0 0 6px;
}

.guest-banner p:last-of-type {
    margin-bottom: 10px;
}

.guest-signin-btn {
    width: 100%;
    padding: 8px 0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* App Container */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Top Navigation */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topnav-height);
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

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

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.logo img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

.nav-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.nav-dropdowns {
    display: flex;
    gap: 16px;
}

.dropdown {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown select {
    padding: 6px 28px 6px 12px;
    font-size: 13px;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23a1a1a1' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: var(--transition-fast);
}

.dropdown select:hover {
    border-color: var(--border-light);
}

.dropdown select:focus {
    outline: none;
    border-color: var(--accent);
}

.nav-checkbox {
    display: flex;
    align-items: center;
    padding-left: 16px;
    border-left: 1px solid var(--border);
    margin-left: 8px;
}

.checkbox-label-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.checkbox-label-nav input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
}

.checkbox-label-nav:hover {
    color: var(--text-primary);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Authenticated user identity strip */
.user-identity {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-display-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-sign-in-prompt {
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    cursor: pointer;
    margin-right: 6px;
    background: none;
    border: none;
    padding: 0;
}
.nav-sign-in-prompt:hover { color: var(--accent-light); text-decoration: underline; }

/* Profile avatar button */
.profile-menu {
    position: relative;
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    padding: 0;
    overflow: hidden;
}

.profile-avatar:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Guest mode: Lucide circle-user icon */
.avatar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: color 0.15s;
}

.avatar-icon svg {
    width: 26px;
    height: 26px;
    stroke-width: 1.5;
}

.profile-avatar:hover .avatar-icon {
    color: var(--text-primary);
}

/* Authenticated mode: green-gradient circle with initials */
.avatar-initials {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #0e7f63);
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
    pointer-events: none;
    font-family: var(--font-sans);
}

/* Profile dropdown */
.profile-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 240px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    overflow: hidden;
}

.profile-dropdown.open {
    display: block;
    animation: dropdownFadeIn 0.15s ease;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.profile-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
}

.avatar-lg {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #0e7f63);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    font-family: var(--font-sans);
}

.profile-dropdown-info {
    min-width: 0;
}

.profile-dropdown-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-dropdown-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.profile-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0;
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    font-size: 13px;
    font-family: var(--font-sans);
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: left;
}

.profile-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.profile-dropdown-item--danger {
    color: var(--error);
}

.profile-dropdown-item--danger:hover {
    background: rgba(239, 68, 68, 0.08);
    color: var(--error);
}

.profile-dropdown-item--signin {
    color: var(--accent);
    font-weight: 500;
}

.profile-dropdown-item--signin:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.profile-dropdown-group {
    padding: 0;
}

.profile-dropdown-group-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-dropdown-group-label .lucide {
    width: 14px;
    height: 14px;
}

/* ── Test Database Modal ──────────────────────────────────────────────────── */

.test-database-modal-content {
    max-width: 420px;
}

.test-database-form .form-group {
    margin-bottom: 16px;
}

.test-database-form .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.test-database-form .form-group input,
.test-database-form .form-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    font-family: var(--font-mono);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
}

.test-database-form .form-group input:read-only,
.test-database-form .form-group select {
    cursor: default;
}

.test-database-form .form-group input::placeholder {
    color: var(--text-muted);
}

.test-database-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.test-database-result {
    font-size: 13px;
    font-family: var(--font-mono);
}

.test-database-result.success {
    color: var(--accent);
}

.test-database-result.error {
    color: var(--error);
}

/* ── Lucide icon defaults ───────────────────────────────────────────────── */
/* All <i data-lucide> elements are replaced by <svg> at runtime.           */

.lucide {
    display: block;
    flex-shrink: 0;
}

/* Standard nav icon size */
.sidebar-toggle .lucide,
.icon-btn .lucide {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* Sidebar footer settings icon */
.sidebar-icon .lucide {
    width: 22px;
    height: 22px;
    stroke-width: 1.75;
}

/* New Chat button plus icon */
.new-chat-btn .lucide {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
}

/* Attach + Send buttons in the chat input */
.attach-btn .lucide,
.send-btn .lucide {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* Profile dropdown menu items */
.profile-dropdown-item .lucide {
    width: 15px;
    height: 15px;
    stroke-width: 2;
    flex-shrink: 0;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Main Container — 3-column: sidebar | chat-area | inspector-pane */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-height: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
    transition: var(--transition-normal);
}

.sidebar.collapsed {
    width: 0;
    border-right: none;
    overflow: hidden;
}

.sidebar.collapsed .nav-footer {
    display: none;
}

.sidebar .nav-top {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sidebar .nav-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid var(--border);
}

.powered-by {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
    padding-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.powered-by img {
    height: 16px;
    width: auto;
    object-fit: contain;
}

.powered-by-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

.powered-by-welcome img {
    height: 20px;
    width: auto;
    object-fit: contain;
}

.sidebar-icon {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    appearance: none;
    -webkit-appearance: none;
}

.sidebar-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-signin { color: var(--accent); }
.sidebar-signin:hover { color: var(--accent-light); }

.sidebar-icon svg {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    opacity: 0.85;
}

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

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.new-chat-btn:hover {
    background: var(--bg-hover);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    min-height: 0;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.conversation-item:hover {
    background: var(--bg-hover);
}

.conversation-item.active {
    background: var(--bg-active);
}

.conversation-item .title {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item .delete-btn {
    display: none;
    padding: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
}

.conversation-item:hover .delete-btn {
    display: block;
}

.prompts-section {
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 8px;
}

.prompts-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 0 12px 6px;
}

.prompts-list {
    max-height: 200px;
    overflow-y: auto;
}

.prompt-item {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    margin: 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.prompt-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.prompt-item.active {
    background: var(--bg-active);
    color: var(--accent);
}

.conversation-item .delete-btn:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

/* Chat Area */
.chat-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Inspector Pane (right column) */
.inspector-pane {
    --inspector-w: var(--inspector-width);
    width: var(--inspector-w);
    min-width: var(--inspector-min-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    overflow: hidden;
    transition: transform var(--transition-normal), width var(--transition-normal), min-width var(--transition-normal);
}

.inspector-pane.collapsed {
    width: 0;
    min-width: 0;
    overflow: hidden;
    border-left: none;
}

.prompt-inspector {
    flex: 0 0 25%;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.prompt-inspector h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 0 0 8px;
}

.prompt-inspector textarea {
    flex: 1;
    min-height: 60px;
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    resize: none;
}

.prompt-inspector textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.execution-trace-log {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    min-height: 0;
}

/* ── Trace Card (Execution Trace in Inspector) ───────────────────────────────── */

.trace-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.trace-card:last-child {
    margin-bottom: 0;
}

.trace-card-info {
    border-color: var(--accent);
}

.trace-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    min-height: 40px;
}

.trace-header:hover {
    background: var(--bg-hover);
}

.trace-header .trace-status-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.trace-header .trace-status-icon.success {
    color: var(--success);
}

.trace-header .trace-status-icon.error {
    color: var(--error);
}

.trace-header .trace-status-icon.running {
    animation: trace-spinner 0.8s linear infinite;
}

@keyframes trace-spinner {
    to { transform: rotate(360deg); }
}

.trace-action-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.trace-tech-label {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.trace-time-metrics {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.trace-payloads {
    border-top: 1px solid var(--border);
}

.trace-payloads details {
    border: none;
}

.trace-payloads summary {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    cursor: pointer;
    background: var(--bg-secondary);
}

.trace-payloads summary:hover {
    background: var(--bg-hover);
}

.trace-payload-content {
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-secondary);
    background: var(--bg-primary);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Layout toggles (top nav) */
.layout-toggles-group {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-right: 12px;
}

.layout-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.layout-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.layout-toggle-btn.active {
    background: var(--accent-light);
    color: var(--accent);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

/* Welcome Message */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    max-width: 600px;
    margin: 0 auto;
}

.welcome-logo {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.welcome-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 16px;
}

.welcome-message h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.welcome-message p {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.example-prompts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.example-prompt {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-fast);
}

.example-prompt:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

/* Messages */
.message {
    display: flex;
    gap: 16px;
    padding: 24px;
    margin-bottom: 8px;
    border-radius: 12px;
}

.message.user {
    background: var(--bg-tertiary);
}

.message.assistant {
    background: transparent;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
}

.message.user .message-avatar {
    background: #6366f1;
    color: white;
}

.message.assistant .message-avatar {
    background: var(--accent);
    color: white;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.message-role {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.message-time {
    font-size: 12px;
    color: var(--text-muted);
}

.message-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* SQL Code Block */
.sql-block {
    margin-top: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.sql-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.sql-header span {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
}

.sql-modifiers {
    display: flex;
    gap: 12px;
    font-size: 12px;
    margin-left: auto;
    margin-right: 16px;
    align-items: center;
}

.sql-modifiers label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    white-space: nowrap;
}

.sql-modifiers input[type="checkbox"] {
    cursor: pointer;
}

.sql-actions {
    display: flex;
    gap: 8px;
}

.sql-actions button {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.sql-actions button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sql-actions button.run-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.sql-code {
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    overflow-x: auto;
}

/* Results Table */
.results-container {
    margin-top: 16px;
    overflow-x: auto;
}

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

.results-header {
    gap: 12px;
}

.results-header span {
    font-size: 13px;
    color: var(--text-secondary);
}

.export-csv-btn {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.export-csv-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.results-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
}

.results-table td {
    padding: 10px 12px;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.results-table tr:hover td {
    background: var(--bg-hover);
}

/* Input Area */
.input-area {
    padding: 16px 24px 24px;
    background: linear-gradient(transparent, var(--bg-primary) 20%);
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
}

.input-options {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.attach-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.attach-btn:hover {
    color: var(--accent);
    background: var(--bg-hover);
}

.attached-files {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px 0;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    font-size: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
}

.file-chip-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-chip-remove {
    padding: 0;
    width: 18px;
    height: 18px;
    font-size: 14px;
    line-height: 1;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
}

.file-chip-remove:hover {
    color: var(--error);
    background: var(--bg-hover);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
}

.input-wrapper textarea {
    flex: 1;
    min-height: 24px;
    max-height: 200px;
    padding: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    color: var(--text-primary);
    background: transparent;
    border: none;
    resize: none;
    outline: none;
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: var(--transition-fast);
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.send-btn:disabled {
    background: var(--bg-active);
    color: var(--text-muted);
    cursor: not-allowed;
}

.stop-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-active);
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.stop-btn:hover {
    background: var(--bg-hover);
    color: var(--error);
}

.stop-btn .lucide {
    width: 14px;
    height: 14px;
}

.input-footer {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* System Health modal */
.health-results {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.health-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
}
.health-result-item.health-ok {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success, #22c55e);
}
.health-result-item.health-fail {
    background: rgba(239, 68, 68, 0.12);
    color: var(--error, #ef4444);
}
.health-icon {
    font-weight: bold;
    font-size: 16px;
    min-width: 20px;
}
.health-name {
    font-weight: 500;
    min-width: 90px;
}
.health-msg {
    flex: 1;
    font-size: 13px;
    opacity: 0.95;
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    color: var(--text-secondary);
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

.loading-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    letter-spacing: 0.01em;
    transition: opacity 0.2s ease;
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.modal-content.modal-large {
    max-width: 800px;
}

.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;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 140px);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

/* ── Email Verification Modal ─────────────────────────────────────────────── */

.verification-modal {
    /* Override default modal backdrop to be slightly darker — this is blocking */
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000; /* above everything else */
}

.verification-modal-content {
    width: 90%;
    max-width: 440px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 32px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0;
}

.verification-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #16a34a, #15803d);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(22, 163, 74, 0.3);
}

.verification-icon svg {
    width: 36px;
    height: 36px;
    stroke: #fff;
    stroke-width: 2;
}

.verification-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 12px;
}

.verification-body {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 8px;
}

.verification-body strong {
    color: var(--text-primary);
    font-weight: 600;
}

.verification-hint {
    font-size: 0.8125rem;
    color: var(--text-muted, var(--text-secondary));
    line-height: 1.6;
    margin: 0 0 24px;
    opacity: 0.8;
}

.verification-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-bottom: 16px;
}

.verification-actions .btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s, transform 0.1s;
}

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

.verification-actions .btn:active:not(:disabled) {
    transform: scale(0.98);
}

.verification-actions .btn-primary {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #fff;
}

.verification-actions .btn-primary:hover:not(:disabled) {
    opacity: 0.9;
}

.verification-actions .btn-secondary {
    background: var(--bg-tertiary, #2a2a2a);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.verification-actions .btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover, #333);
}

.verification-actions svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.verification-status {
    font-size: 0.8125rem;
    min-height: 1.2em;
    margin: 0 0 16px;
    transition: color 0.2s;
}

.verification-status.loading { color: var(--text-secondary); }
.verification-status.success { color: #16a34a; font-weight: 600; }
.verification-status.error   { color: #dc2626; }

.verification-cancel {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 4px;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.verification-cancel:hover { opacity: 1; }

/* ── Playground Guest Quota Modal ────────────────────────────────────────── */

.quota-modal {
    background: rgba(0, 0, 0, 0.80);
}

.quota-modal-content {
    width: 90%;
    max-width: 400px;
    padding: 40px 32px 36px;
    border-radius: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.quota-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    color: var(--playground-purple, #8b5cf6);
}

.quota-icon svg {
    width: 30px;
    height: 30px;
    stroke: currentColor;
}

.quota-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--text-primary);
}

.quota-body {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 28px;
}

.quota-body strong {
    color: var(--playground-purple, #8b5cf6);
}

.quota-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.quota-btn--signup {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: var(--playground-purple, #8b5cf6);
    border-color: var(--playground-purple, #8b5cf6);
}

.quota-btn--signup:hover {
    background: var(--playground-purple-hover, #7c3aed);
    border-color: var(--playground-purple-hover, #7c3aed);
}

.quota-btn--signup svg {
    width: 15px;
    height: 15px;
}

.quota-btn--return {
    width: 100%;
}

.btn-primary {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.btn-secondary {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-danger {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: white;
    background: var(--error);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-danger:hover {
    background: #dc2626;
}

/* ── Keyboard Shortcuts Modal ───────────────────────────────────────────────── */

.kb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.kb-table td {
    padding: 7px 4px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.kb-table td:first-child {
    width: 44%;
    white-space: nowrap;
}

.kb-table tr:last-child td {
    border-bottom: none;
}

.kb-section {
    padding-top: 16px !important;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted) !important;
}

kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    box-shadow: 0 1px 0 var(--border-light);
}

/* ── Profile Modal ─────────────────────────────────────────────────────────── */

.profile-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 10px;
}

.pf-badge {
    font-size: 10px;
    font-weight: 500;
    padding: 2px 7px;
    border-radius: 20px;
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    text-transform: none;
    letter-spacing: 0;
}

.pf-divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

.pf-field {
    margin-bottom: 12px;
}

.pf-field--row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.pf-input {
    width: 100%;
    padding: 9px 12px;
    font-size: 13px;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: var(--transition-fast);
    box-sizing: border-box;
}

.pf-input:focus {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.pf-btn {
    font-family: var(--font-sans);
    white-space: nowrap;
}

.pf-btn--inline {
    flex-shrink: 0;
    padding: 9px 14px;
    font-size: 13px;
}

.pf-status {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.pf-status--success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.pf-status--error {
    background: rgba(239, 68, 68, 0.10);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.pf-status--loading {
    background: rgba(161, 161, 161, 0.10);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* Settings Modal */
.settings-tabs {
    display: flex;
    gap: 4px;
    padding: 0 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.settings-tab {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
}

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

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

.settings-loading {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.settings-group {
    margin-bottom: 24px;
}

.settings-group:last-child {
    margin-bottom: 0;
}

.settings-group-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.settings-field {
    margin-bottom: 16px;
}

.settings-field:last-child {
    margin-bottom: 0;
}

.settings-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.settings-field input[type="text"],
.settings-field input[type="password"],
.settings-field input[type="url"],
.settings-field select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.settings-field input:focus,
.settings-field select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Model fetch: input + Get Models button inline */
.model-fetch-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.model-fetch-container input {
    flex: 1;
    min-width: 0;
}

.model-fetch-container .btn-fetch-models {
    flex-shrink: 0;
    white-space: nowrap;
}

.model-fetch-container .btn-fetch-models:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.settings-toggle label {
    margin-bottom: 0;
}

.settings-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Settings split layout (DBeaver-style) */
.settings-split {
    display: flex;
    min-height: 320px;
}

.settings-nav {
    width: 180px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    padding: 12px 0;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-fast);
}

.settings-nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.settings-nav-item.active {
    background: var(--bg-hover);
    color: var(--accent);
    border-left-color: var(--accent);
}

.settings-nav-item .status-dot {
    flex-shrink: 0;
    font-size: 10px;
}

.settings-nav-item .status-dot.populated {
    color: var(--success);
}

.settings-nav-item .status-dot.empty {
    color: var(--text-muted);
}

.settings-main {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.schema-content {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    color: var(--text-secondary);
}

/* 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);
}

/* ── Explore Nav Group ──────────────────────────────────────────────────── */

.nav-explore {
    flex-shrink: 0;
    padding: 4px 0 6px;
    border-top: 1px solid var(--border);
}

.nav-group {
    padding: 0 6px;
}

.nav-group-label {
    padding: 10px 10px 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-transform: uppercase;
    user-select: none;
}

/* Collapsible nav item header */
.nav-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: 7px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    text-align: left;
}

.nav-item-header:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item-header.open {
    color: var(--text-primary);
}

.nav-item-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.nav-item-label {
    flex: 1;
}

.nav-chevron {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    transition: transform 200ms ease;
}

.nav-item-header[aria-expanded="true"] .nav-chevron {
    transform: rotate(90deg);
}

/* Submenu collapse animation */
.nav-submenu {
    overflow: hidden;
    max-height: 0;
    transition: max-height 220ms ease;
}

.nav-submenu.open {
    max-height: 200px;
}

.nav-subitem {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px 7px 32px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    text-align: left;
}

.nav-subitem:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-subitem svg {
    flex-shrink: 0;
    width: 13px;
    height: 13px;
}

/* Reset button gets a subtle warning tint on hover */
.nav-subitem--reset:hover {
    background: rgba(239, 68, 68, 0.08);
    color: #f87171;
}

/* Active state when a sub-item is selected */
.nav-subitem.active {
    background: var(--playground-purple-light);
    color: var(--playground-purple);
    font-weight: 600;
}

/* ── Active-Playground theme override ───────────────────────────────────── */

/* When playground mode is active, switch accent to Sandbox Purple. */
.sidebar.active-playground .nav-item-header.open {
    color: var(--playground-purple);
}

.sidebar.active-playground #queryChinookBtn.active {
    background: var(--playground-purple-light);
    color: var(--playground-purple);
}

/* Query Chinook DB — loading state (Firebase sign-in + WebSocket) */
#queryChinookBtn.loading {
    cursor: wait;
}
#queryChinookBtn.loading .nav-subitem-loading {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
}
#queryChinookBtn .nav-subitem-loading .loading-dots span {
    width: 5px;
    height: 5px;
}

/* Conversation items keep the normal accent; the purple lives only in the
   Explore section so existing UI isn't jarring. */
.sidebar.active-playground .nav-item-header:hover {
    background: var(--playground-purple-light);
    color: var(--playground-purple);
}

/* Playground mode indicator badge on the Playground header button */
.sidebar.active-playground .nav-item-header .nav-item-icon {
    color: var(--playground-purple);
}

/* ── Sandbox Reset Confirmation Toast ───────────────────────────────────── */

.sandbox-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    pointer-events: none;
    z-index: 3000;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 340px;
    max-width: 440px;
    padding: 16px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--playground-purple);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transition: opacity 200ms ease, transform 200ms ease;
}

.sandbox-toast.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.sandbox-toast-icon {
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--warning);
}

.sandbox-toast-icon svg {
    width: 20px;
    height: 20px;
}

.sandbox-toast-body {
    flex: 1;
}

.sandbox-toast-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.sandbox-toast-msg {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0 0 12px;
}

.sandbox-toast-msg code {
    font-family: var(--font-mono);
    font-size: 0.8em;
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--playground-purple);
}

.sandbox-toast-actions {
    display: flex;
    gap: 8px;
}

.sandbox-toast-btn {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s;
}

.sandbox-toast-btn:hover { opacity: 0.85; }
.sandbox-toast-btn:active { transform: scale(0.97); }

.sandbox-toast-btn--confirm {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--playground-purple);
    color: #fff;
}

.sandbox-toast-btn--confirm svg {
    width: 13px;
    height: 13px;
}

.sandbox-toast-btn--cancel {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.sandbox-toast-close {
    flex-shrink: 0;
    align-self: flex-start;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    margin: -2px -4px 0 0;
    transition: color var(--transition-fast);
}

.sandbox-toast-close:hover { color: var(--text-primary); }

.sandbox-toast-close svg {
    width: 15px;
    height: 15px;
}

/* Brief status toasts (success / error after reset) */
.sandbox-status-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    pointer-events: none;
    z-index: 3000;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transition: opacity 200ms ease, transform 200ms ease;
}

.sandbox-status-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.sandbox-status-toast.success {
    background: var(--playground-purple);
    color: #fff;
}

.sandbox-status-toast.error {
    background: var(--error);
    color: #fff;
}

/* ── DB Status Dot ─────────────────────────────────────────────────────────── */

.db-status-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

.db-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    vertical-align: middle;
    border-radius: 50%;
    margin-left: 5px;
    flex-shrink: 0;
    transition: background 0.3s, border-color 0.3s;
    /* Default/unknown: muted grey so the dot is always visible */
    background: var(--text-muted);
    opacity: 0.5;
}

.db-status-dot.status-green {
    background: #28a745;
    border: none;
    opacity: 1;
}

.db-status-dot.status-red {
    background: transparent;
    border: 1.5px solid #dc3545;
    opacity: 1;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.45; transform: scale(0.85); }
}

.db-status-label {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 4px;
    vertical-align: middle;
}
.db-status-dot.status-green + .db-status-label { color: #28a745; }
.db-status-dot.status-red + .db-status-label { color: #dc3545; }
.db-status-dot.status-pulse + .db-status-label { color: var(--warning); }

.db-refresh-btn {
    display: inline-block;
    margin-left: 4px;
    padding: 0 4px;
    font-size: 12px;
    line-height: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 2px;
    vertical-align: middle;
}
.db-refresh-btn:hover {
    color: var(--accent);
    background: var(--accent-light);
}

.db-status-dot.status-pulse {
    background: var(--warning);
    border: none;
    opacity: 1;
    animation: status-pulse 1s ease-in-out infinite;
}

/* ── DB Index Nudge ─────────────────────────────────────────────────────────── */

.nav-center {
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.db-index-nudge {
    display: none;         /* shown by JS when status-red */
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: 20px;
    background: rgba(220, 53, 69, 0.12);
    border: 1px solid rgba(220, 53, 69, 0.35);
    font-size: 0.72rem;
    color: #e55;
    margin-top: 4px;
    animation: nudge-fadein 0.25s ease;
}

@keyframes nudge-fadein {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.db-index-nudge svg {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
}

.db-index-btn {
    padding: 2px 9px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.db-index-btn:hover { background: var(--accent-hover); }

/* ── Schema Indexing Progress Modal ─────────────────────────────────────────── */

.indexing-modal {
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000; /* above chat, dropdowns, settings gear during startup indexing */
    pointer-events: auto; /* block all interaction underneath */
}

.indexing-modal-content {
    width: 90%;
    max-width: 400px;
    text-align: center;
    padding: 40px 36px 36px;
    border-radius: 18px;
}

/* Spinner speeds up over time; glow pulses */
.indexing-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-light);
    border: 1.5px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    animation: indexing-spin-glow 2.5s ease-in-out infinite;
}

@keyframes indexing-spin-glow {
    0%, 100% { box-shadow: 0 0 0   0px rgba(16,163,127,0.0); }
    50%      { box-shadow: 0 0 18px 4px rgba(16,163,127,0.35); }
}

/* Icon spins with acceleration over 12s cycle so user sees ongoing progress */
.indexing-icon svg {
    width: 28px;
    height: 28px;
    color: var(--accent);
    animation: indexing-icon-spin 12s linear infinite;
}

@keyframes indexing-icon-spin {
    0%   { transform: rotate(0deg); }
    10%  { transform: rotate(360deg); }
    20%  { transform: rotate(900deg); }
    30%  { transform: rotate(1620deg); }
    40%  { transform: rotate(2700deg); }
    50%  { transform: rotate(4140deg); }
    60%  { transform: rotate(5940deg); }
    70%  { transform: rotate(8100deg); }
    80%  { transform: rotate(10620deg); }
    90%  { transform: rotate(13500deg); }
    100% { transform: rotate(16740deg); }
}

/* Processing area: dots animate; overall brightness shifts over time so user sees ongoing activity */
.indexing-processing {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 24px 0 14px;
    animation: indexing-processing-breathe 8s ease-in-out infinite;
}

@keyframes indexing-processing-breathe {
    0%, 100% { opacity: 1; filter: brightness(1); }
    50%      { opacity: 0.92; filter: brightness(1.08); }
}

.indexing-dots {
    display: inline-flex;
    gap: 6px;
}

.indexing-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    animation: indexing-dot-pulse 1.4s ease-in-out infinite both;
}

.indexing-dot:nth-child(1) { animation-delay: 0s; }
.indexing-dot:nth-child(2) { animation-delay: 0.2s; }
.indexing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Dots cycle: fade in, color shift, scale up; evolves over time */
@keyframes indexing-dot-pulse {
    0%, 100% {
        opacity: 0.35;
        transform: scale(0.85);
        background: var(--accent);
    }
    50% {
        opacity: 1;
        transform: scale(1.15);
        background: #06d6a0;
    }
}

.indexing-processing-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.indexing-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 6px;
}

.indexing-db-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0 0 8px;
}

.indexing-status-line {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    min-height: 1.5em;
    word-break: break-all;
}

/* ── Playground-active body overrides ──────────────────────────────────────── */

/* Tint the Database label purple while locked */
body.playground-active .nav-dropdowns .dropdown:first-child > label {
    color: var(--playground-purple);
}

/* Give locked selects a subtle purple border so users notice the override */
body.playground-active .nav-dropdowns select:disabled {
    border-color: rgba(111, 66, 193, 0.45);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 1;               /* override browser default dim */
}

/* Tooltip hint that appears via the native `title` on hover — reinforce with a
   small lock icon injected by CSS next to the disabled Database label */
body.playground-active .nav-dropdowns .dropdown:first-child > label::after {
    content: ' 🔒';
    font-size: 0.65em;
    opacity: 0.6;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        top: var(--topnav-height);
        left: 0;
        bottom: 0;
        z-index: 100;
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    .nav-dropdowns {
        gap: 8px;
    }
    
    .dropdown label {
        display: none;
    }
}
