/* ============================================================
   NL2SQL Assistant — Clean Light Theme
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
    /* Brand */
    --primary:          #6d28d9;
    --primary-hover:    #5b21b6;
    --primary-light:    #8b5cf6;
    --primary-pale:     #ede9fe;
    --primary-border:   #c4b5fd;
    --primary-glow:     rgba(109, 40, 217, 0.18);
  
    /* Backgrounds */
    --bg-page:          #f5f3ff;
    --bg-white:         #ffffff;
    --bg-sidebar:       #faf9ff;
    --bg-header:        #ffffff;
    --bg-input:         #ffffff;
    --bg-code:          #1e1b4b;
  
    /* Borders */
    --border-light:     #e8e4f9;
    --border-mid:       #c4b5fd;
    --border-strong:    #8b5cf6;
  
    /* Text */
    --text-dark:        #1e1b4b;
    --text-body:        #374151;
    --text-muted:       #6b7280;
    --text-faint:       #9ca3af;
    --text-accent:      #6d28d9;
  
    /* SQL colors (on dark code bg) */
    --sql-keyword:      #c084fc;
    --sql-fn:           #67e8f9;
    --sql-string:       #6ee7b7;
    --sql-number:       #fcd34d;
  
    /* Status */
    --success:          #059669;
    --success-bg:       #d1fae5;
    --success-border:   #6ee7b7;
    --danger:           #dc2626;
    --danger-bg:        #fee2e2;
    --danger-border:    #fca5a5;
  
    /* Radii */
    --r-sm:   8px;
    --r-md:   12px;
    --r-lg:   18px;
    --r-xl:   24px;
    --r-full: 9999px;
  
    /* Shadows */
    --shadow-sm:   0 1px 4px rgba(109,40,217,.08);
    --shadow-md:   0 4px 16px rgba(109,40,217,.10);
    --shadow-lg:   0 8px 32px rgba(109,40,217,.13);
  
    --transition: 0.2s ease;
  }
  
  /* ---------- Reset ---------- */
  *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
  html, body { height: 100%; }
  
  body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-page);
    color: var(--text-body);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
  }
  
  /* ---------- Scrollbar ---------- */
  ::-webkit-scrollbar { width: 5px; height: 5px; }
  ::-webkit-scrollbar-track { background: #f3f4f6; }
  ::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 99px; }
  
  /* ============================================================
     LAYOUT
     ============================================================ */
  
  .app {
    display: flex;
    height: 100vh;
  }
  
  /* ============================================================
     SIDEBAR
     ============================================================ */
  
  .sidebar {
    width: 288px;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1.5px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  
  /* Sidebar Header */
  .sidebar-header {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-white);
    flex-shrink: 0;
  }
  
  .sidebar-logo {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--primary);
  }
  
  .sidebar-logo h2 {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-dark);
  }
  
  .schema-badge {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-pale);
    border: 1px solid var(--primary-border);
    padding: 3px 9px;
    border-radius: var(--r-full);
  }
  
  /* Sidebar Search */
  .sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 12px;
    padding: 8px 12px;
    background: var(--bg-white);
    border: 1.5px solid var(--border-light);
    border-radius: var(--r-sm);
    transition: border-color var(--transition);
    flex-shrink: 0;
  }
  
  .sidebar-search:focus-within {
    border-color: var(--primary-border);
    box-shadow: 0 0 0 3px var(--primary-pale);
  }
  
  .sidebar-search svg { color: var(--text-faint); flex-shrink: 0; }
  
  .sidebar-search input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    color: var(--text-body);
    font-family: 'Inter', sans-serif;
    width: 100%;
  }
  
  .sidebar-search input::placeholder { color: var(--text-faint); }
  
  /* Schema Container */
  .schema-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px 16px;
  }
  
  /* Schema Card — flat accordion list */
  .schema-card {
    background: var(--bg-white);
    border: 1.5px solid var(--border-light);
    border-radius: var(--r-md);
    margin-bottom: 6px;
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
  }
  
  .schema-card:hover {
    border-color: var(--primary-border);
    box-shadow: var(--shadow-sm);
  }
  
  /* Table name row — clickable */
  .schema-card-header {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 13px;
    background: #fff;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
  }
  
  .schema-card-header:hover {
    background: var(--primary-pale);
  }
  
  /* Open/active state */
  .schema-card-header.open {
    background: var(--primary-pale);
    border-bottom: 1.5px solid var(--primary-border);
  }
  
  .schema-card-header .table-icon { color: var(--primary); flex-shrink: 0; }
  
  .schema-card-header h3 {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .schema-card-header.open h3 { color: var(--primary); }
  
  .schema-col-count {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-pale);
    border: 1px solid var(--primary-border);
    padding: 2px 7px;
    border-radius: var(--r-full);
    flex-shrink: 0;
  }
  
  /* Chevron icon */
  .chevron {
    color: var(--text-faint);
    flex-shrink: 0;
    transition: transform 0.22s ease;
  }
  
  .schema-card-header.open .chevron { color: var(--primary); }
  
  /* Column list (hidden by default, toggled via JS) */
  .schema-columns {
    padding: 4px 0;
    border-top: 1px solid var(--border-light);
    background: #faf9ff;
  }
  
  .column {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 16px;
    transition: background var(--transition);
    border-bottom: 1px solid #f3f0ff;
  }
  
  .column:last-child { border-bottom: none; }
  .column:hover { background: #ede9fe; }
  
  .column-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-body);
    font-family: 'JetBrains Mono', monospace;
  }
  
  .column-type {
    font-size: 10px;
    font-weight: 600;
    color: #0369a1;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    padding: 2px 7px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    flex-shrink: 0;
  }
  
  /* ============================================================
     CHAT AREA
     ============================================================ */
  
  .chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-page);
    overflow: hidden;
  }
  
  /* ---------- Header ---------- */
  
  .chat-header {
    padding: 14px 26px;
    border-bottom: 1.5px solid var(--border-light);
    background: var(--bg-header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
  }
  
  .header-brand { display: flex; align-items: center; gap: 14px; }
  
  .brand-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 14px rgba(109,40,217,.3);
    flex-shrink: 0;
  }
  
  .main-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-dark);
    letter-spacing: -0.5px;
    line-height: 1.2;
  }
  
  .main-title .arrow {
    color: var(--primary);
    font-weight: 400;
  }
  
  .subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  
  .header-stats { display: flex; gap: 8px; }
  
  .stat-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-pale);
    border: 1.5px solid var(--primary-border);
    padding: 5px 12px;
    border-radius: var(--r-full);
  }
  
  /* ---------- Messages ---------- */
  
  .messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 30px;
    display: flex;
    flex-direction: column;
    gap: 22px;
  }
  
  /* ---------- Welcome Screen ---------- */
  
  .welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: 48px 20px;
    gap: 12px;
    animation: fadeUp 0.5s ease;
  }
  
  .welcome-icon {
    width: 80px;
    height: 80px;
    border-radius: 22px;
    background: linear-gradient(135deg, var(--primary-pale), #f5f3ff);
    border: 2px solid var(--primary-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    margin-bottom: 6px;
    box-shadow: var(--shadow-md);
  }
  
  .welcome-screen h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
  }
  
  .welcome-screen p {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 380px;
  }
  
  .welcome-screen .section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-top: 10px;
  }
  
  /* Sample query pills */
  .sample-queries {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 4px;
    max-width: 640px;
  }
  
  .sample-btn {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    background: #fff;
    border: 1.5px solid var(--primary-border);
    padding: 8px 15px;
    border-radius: var(--r-full);
    cursor: pointer;
    transition: all var(--transition);
    font-family: 'Inter', sans-serif;
    text-align: left;
    box-shadow: var(--shadow-sm);
  }
  
  .sample-btn:hover {
    background: var(--primary-pale);
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
  
  .sample-btn .btn-icon {
    margin-right: 5px;
    opacity: 0.65;
  }
  
  /* ---------- User Message ---------- */
  
  .user-message {
    display: flex;
    justify-content: flex-end;
    animation: fadeUp 0.25s ease;
  }
  
  .user-bubble {
    max-width: 65%;
    background: linear-gradient(135deg, #6d28d9, #4f46e5);
    color: white;
    padding: 12px 18px;
    border-radius: 18px 18px 4px 18px;
    font-size: 14px;
    line-height: 1.65;
    box-shadow: 0 4px 14px rgba(109,40,217,.25);
    word-wrap: break-word;
  }
  
  /* ---------- Assistant Card ---------- */
  
  .assistant-message { animation: fadeUp 0.3s ease; }
  
  .assistant-card {
    background: var(--bg-white);
    border: 1.5px solid var(--border-light);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
  }
  
  /* ---------- SQL Block ---------- */
  
  .sql-section { border-bottom: 1px solid var(--border-light); }
  
  .sql-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: linear-gradient(90deg, #f5f3ff, #ede9fe);
    border-bottom: 1px solid var(--border-light);
  }
  
  .sql-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.09em;
  }
  
  .sql-label svg { color: var(--primary); }
  
  .sql-actions { display: flex; gap: 8px; align-items: center; }
  
  .copy-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    background: #fff;
    border: 1.5px solid var(--border-light);
    padding: 5px 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-family: 'Inter', sans-serif;
  }
  
  .copy-btn:hover {
    color: var(--primary);
    border-color: var(--primary-border);
    background: var(--primary-pale);
  }
  
  .copy-btn.copied {
    color: var(--success);
    border-color: var(--success-border);
    background: var(--success-bg);
  }
  
  /* SQL code block — light background, readable syntax colors */
  .sql-block {
    margin: 0 !important;
    padding: 18px 22px !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 13px !important;
    line-height: 1.85 !important;
    background: #f8f7ff !important;   /* very soft lavender white */
    color: #3730a3 !important;         /* indigo base text */
    border: none !important;
    border-radius: 0 !important;
    overflow-x: auto;
    white-space: pre;
    word-wrap: normal;
  }
  
  .sql-block code {
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 13px !important;
    background: transparent !important;
    color: #3730a3 !important;
  }
  
  /* Override highlight.js to use light tokens */
  .sql-block .hljs-keyword   { color: #7c3aed !important; font-weight: 700; }  /* SELECT, FROM → purple */
  .sql-block .hljs-built_in  { color: #0369a1 !important; font-weight: 600; }  /* COUNT, SUM → blue */
  .sql-block .hljs-string    { color: #059669 !important; }                    /* 'string' → green */
  .sql-block .hljs-number    { color: #d97706 !important; }                    /* 123 → amber */
  .sql-block .hljs-operator  { color: #db2777 !important; }                    /* =, >, AND → pink */
  .sql-block .hljs-comment   { color: #9ca3af !important; font-style: italic; }
  .sql-block .hljs-title     { color: #0369a1 !important; }                    /* table names */
  .sql-block .hljs-attr      { color: #7c3aed !important; }
  
  /* ---------- Results Section ---------- */
  
  .results-section {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-light);
  }
  
  .section-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
  }
  
  .row-count-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--success);
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    padding: 2px 9px;
    border-radius: var(--r-full);
  }
  
  /* ---------- Table ---------- */
  
  .table-wrapper {
    overflow-x: auto;
    border-radius: var(--r-md);
    border: 1.5px solid var(--border-light);
  }
  
  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
  }
  
  thead tr { background: var(--primary-pale); }
  
  th {
    padding: 10px 15px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1.5px solid var(--primary-border);
    white-space: nowrap;
  }
  
  td {
    padding: 10px 15px;
    color: var(--text-body);
    border-bottom: 1px solid var(--border-light);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12.5px;
  }
  
  tbody tr { transition: background var(--transition); }
  tbody tr:hover { background: #faf9ff; }
  tbody tr:last-child td { border-bottom: none; }
  
  /* ---------- Chart Section ---------- */
  
  .chart-section { padding: 16px 18px; }
  
  .chart-card {
    background: #ffffff;
    border: 1.5px solid var(--border-mid);
    border-radius: var(--r-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
  }
  
  .chart-card canvas {
    height: 260px !important;
    max-height: 260px !important;
  }
  
  /* ---------- Input Area ---------- */
  
  .input-container {
    padding: 14px 22px 10px;
    background: var(--bg-white);
    border-top: 1.5px solid var(--border-light);
    flex-shrink: 0;
    box-shadow: 0 -2px 12px rgba(0,0,0,.04);
  }
  
  .input-box {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-input);
    border: 1.5px solid var(--border-mid);
    border-radius: var(--r-xl);
    padding: 10px 10px 10px 16px;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-shadow: var(--shadow-sm);
  }
  
  .input-box:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-pale), var(--shadow-md);
  }
  
  .input-icon {
    color: var(--text-faint);
    padding-bottom: 4px;
    flex-shrink: 0;
  }
  
  textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    min-height: 28px;
    max-height: 160px;
    font-size: 14px;
    line-height: 1.7;
    font-family: 'Inter', sans-serif;
    background: transparent;
    color: var(--text-body);
    overflow-y: auto;
  }
  
  textarea::placeholder { color: var(--text-faint); }
  
  #run-query {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: white;
    padding: 9px 18px;
    border-radius: var(--r-lg);
    font-size: 13.5px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
    white-space: nowrap;
    box-shadow: 0 3px 12px rgba(109,40,217,.28);
  }
  
  #run-query:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(109,40,217,.38);
  }
  
  #run-query:active { transform: translateY(0); }
  
  .input-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 6px;
  }
  
  kbd {
    display: inline-block;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
  }
  
  /* ---------- Loading ---------- */
  
  .loading {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 18px 20px;
  }
  
  .loading-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-left: 6px;
  }
  
  .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-light);
    animation: bounce 1.4s infinite;
  }
  
  .dot:nth-child(2) { animation-delay: .2s; }
  .dot:nth-child(3) { animation-delay: .4s; }
  
  @keyframes bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
  }
  
  /* ---------- Error Card ---------- */
  
  .error-card {
    background: var(--danger-bg);
    border: 1.5px solid var(--danger-border);
    border-radius: var(--r-md);
    padding: 13px 17px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13.5px;
    color: var(--danger);
  }
  
  .error-card svg { color: var(--danger); flex-shrink: 0; margin-top: 1px; }
  
  /* ---------- Animations ---------- */
  
  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  
  /* ============================================================
     MOBILE
     ============================================================ */
  
  @media (max-width: 900px) {
    .sidebar { display: none; }
    .messages { padding: 14px; }
    .main-title { font-size: 18px; }
    .chat-header { padding: 10px 14px; }
    .user-bubble { max-width: 85%; }
  }
  /* ============================================================
     DB CONNECT BUTTON & MODAL
     ============================================================ */
  
  /* -- Connect DB Button in header -- */
  .connect-db-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1.5px solid var(--border-mid);
    border-radius: 20px;
    background: var(--bg-white);
    color: var(--text-accent);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
  }
  .connect-db-btn:hover {
    background: var(--primary-pale);
    border-color: var(--primary);
  }
  .connect-db-btn.connected {
    background: #d1fae5;
    border-color: #059669;
    color: #065f46;
  }
  .db-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #d1d5db;
    transition: background 0.3s;
  }
  .db-status-dot.connected {
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.2);
  }
  
  /* -- Modal Overlay -- */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 10, 40, 0.45);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
  }
  .modal-overlay.active {
    display: flex;
  }
  
  /* -- Modal Box -- */
  .modal-box {
    background: var(--bg-white);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    margin: 20px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.18);
    border: 1px solid var(--border-light);
    overflow: hidden;
  }
  
  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-light);
  }
  .modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
  }
  .modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }
  .modal-close:hover {
    background: var(--primary-pale);
    color: var(--primary);
  }
  
  .modal-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  .modal-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
  }
  .modal-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
  }
  .modal-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
  }
  .modal-input {
    width: 100%;
    padding: 10px 40px 10px 12px;
    border: 1.5px solid var(--border-mid);
    border-radius: 8px;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-dark);
    background: var(--bg-page);
    outline: none;
    transition: border-color 0.2s;
  }
  .modal-input:focus {
    border-color: var(--primary);
    background: var(--bg-white);
  }
  .modal-toggle-eye {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    padding: 2px;
  }
  .modal-toggle-eye:hover { color: var(--primary); }
  
  .modal-info {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: var(--primary-pale);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-accent);
    line-height: 1.5;
  }
  .modal-info svg { flex-shrink: 0; margin-top: 1px; }
  
  /* Provider cards */
  .provider-cards {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
  }
  .provider-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-page);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 12px;
  }
  .provider-card strong {
    color: var(--text-dark);
    font-weight: 600;
    min-width: 80px;
  }
  .provider-card span {
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
  }
  
  /* Test result */
  .db-test-result {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
  }
  .db-test-result.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
  }
  .db-test-result.error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
  }
  
  /* Modal Footer */
  .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-page);
  }
  .modal-btn-secondary {
    padding: 9px 18px;
    border: 1.5px solid var(--border-mid);
    border-radius: 8px;
    background: var(--bg-white);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
  }
  .modal-btn-secondary:hover {
    background: var(--primary-pale);
    color: var(--primary);
    border-color: var(--primary);
  }
  .modal-btn-test {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
  }
  .modal-btn-test:hover { background: var(--primary-hover); }
  .modal-btn-test:disabled { opacity: 0.6; cursor: not-allowed; }

  .google-btn{
    background:#ffffff;
    border:1.5px solid #c4b5fd;
    color:#6d28d9;
    padding:6px 14px;
    border-radius:20px;
    cursor:pointer;
    font-size:13px;
    font-weight:600;
    transition:0.2s;
}

.google-btn:hover{
    background:#ede9fe;
    border-color:#8b5cf6;
}

/* ============================================================
   GOOGLE AUTH
   ============================================================ */

   #auth-container{
    display:flex;
    align-items:center;
  }
  
  .google-login-btn{
    display:flex;
    align-items:center;
    justify-content:center;
    padding:6px 14px;
    border:1.5px solid var(--border-mid);
    border-radius:20px;
    background:var(--bg-white);
    color:var(--text-accent);
    font-size:13px;
    font-weight:500;
    cursor:pointer;
    transition:all .2s ease;
    white-space:nowrap;
  }
  
  .google-login-btn:hover{
    background:var(--primary-pale);
    border-color:var(--primary);
  }
  
  .user-profile{
    display:flex;
    align-items:center;
    gap:8px;
  }
  
  .user-avatar{
    width:30px;
    height:30px;
    border-radius:50%;
    object-fit:cover;
    border:2px solid var(--primary-border);
  }
  
  .user-name{
    font-size:13px;
    font-weight:600;
    color:var(--text-dark);
    max-width:120px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  
  .logout-btn{
    padding:5px 10px;
    border:none;
    border-radius:16px;
    background:var(--primary-pale);
    color:var(--primary);
    font-size:12px;
    font-weight:600;
    cursor:pointer;
  }
  
  .logout-btn:hover{
    background:var(--primary-border);
  }

  /* ============================================================
   AUTH + HISTORY + RIGHT PANEL — append to style.css
   ============================================================ */

/* ── LOGIN SCREEN ─────────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 50%, #ddd6fe 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.login-card {
  background: #fff; border-radius: 20px;
  padding: 40px 40px 32px; width: 100%; max-width: 400px; margin: 20px;
  box-shadow: 0 24px 64px rgba(109,40,217,0.15);
  border: 1px solid #ede9fe; text-align: center;
}
.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; color: #fff;
}
.login-title { font-size: 24px; font-weight: 700; color: #1e1b4b; margin-bottom: 8px; }
.login-sub   { font-size: 14px; color: #6b7280; margin-bottom: 24px; line-height: 1.5; }

.google-login-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px; border: 1.5px solid #e5e7eb;
  border-radius: 10px; background: #fff; font-size: 14px; font-weight: 500;
  font-family: inherit; cursor: pointer; color: #374151;
  transition: all 0.2s; margin-bottom: 16px;
}
.google-login-btn:hover { background: #f9fafb; border-color: #d1d5db; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

.login-divider {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; color: #9ca3af; font-size: 12px;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: #e5e7eb;
}

.login-email-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.login-input {
  width: 100%; padding: 10px 14px; border: 1.5px solid #e5e7eb;
  border-radius: 8px; font-size: 13px; font-family: inherit; outline: none;
  transition: border-color 0.2s; box-sizing: border-box;
}
.login-input:focus { border-color: #7c3aed; }

.login-error {
  background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 8px; padding: 8px 12px;
  font-size: 12px; color: #dc2626; text-align: left;
}

.email-login-btn {
  width: 100%; padding: 10px; background: #7c3aed; color: #fff;
  border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: background 0.15s;
}
.email-login-btn:hover { background: #6d28d9; }

.email-signup-btn {
  width: 100%; padding: 10px; background: transparent; color: #7c3aed;
  border: 1.5px solid #7c3aed; border-radius: 8px; font-size: 14px; font-weight: 500;
  font-family: inherit; cursor: pointer; transition: all 0.15s;
}
.email-signup-btn:hover { background: #f5f3ff; }

.login-features { display: flex; flex-direction: column; gap: 6px; padding-top: 16px; border-top: 1px solid #f3f4f6; }
.login-feature { font-size: 12px; color: #6b7280; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ── USER CHIP ────────────────────────────────────────────── */
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--primary-pale); border: 1.5px solid var(--primary-border);
  border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--text-accent);
}
.user-avatar-sm {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
  background-size: cover; background-position: center;
}
.sign-out-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); display: flex; align-items: center;
  padding: 2px; border-radius: 4px; transition: color 0.15s;
}
.sign-out-btn:hover { color: #dc2626; }

/* ── HISTORY TOGGLE BUTTON ────────────────────────────────── */
.history-toggle-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border: 1.5px solid var(--border-mid);
  border-radius: 20px; background: var(--bg-white);
  color: var(--text-accent); font-size: 13px; font-weight: 500;
  font-family: inherit; cursor: pointer; transition: all 0.2s;
}
.history-toggle-btn:hover { background: var(--primary-pale); border-color: var(--primary); }

/* ── RIGHT HISTORY PANEL ──────────────────────────────────── */
.history-panel {
  width: 0; overflow: hidden; flex-shrink: 0;
  background: var(--bg-white); border-left: 1px solid var(--border-light);
  display: flex; flex-direction: column;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.history-panel.open { width: 320px; overflow: visible; }

.history-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px; border-bottom: 1px solid var(--border-light);
  flex-shrink: 0; min-width: 320px;
}
.history-panel-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--text-dark);
}
.history-panel-actions { display: flex; align-items: center; gap: 6px; }

.clear-history-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; border: 1px solid var(--border-mid);
  border-radius: 6px; background: none; font-size: 12px;
  color: var(--text-muted); font-family: inherit; cursor: pointer; transition: all 0.15s;
}
.clear-history-btn:hover { color: #dc2626; border-color: #fca5a5; background: #fef2f2; }

.history-close-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); display: flex; align-items: center;
  padding: 4px; border-radius: 6px; transition: all 0.15s;
}
.history-close-btn:hover { background: var(--primary-pale); color: var(--primary); }

.history-search {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--border-light);
  flex-shrink: 0; min-width: 320px;
}
.history-search input {
  flex: 1; border: none; outline: none; font-size: 12px;
  font-family: inherit; color: var(--text-dark); background: none;
}
.history-search input::placeholder { color: var(--text-faint); }

.history-list {
  flex: 1; overflow-y: auto; padding: 8px;
  min-width: 320px;
}

.history-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 40px 20px; text-align: center;
  color: var(--text-muted);
}
.history-empty svg { margin-bottom: 12px; opacity: 0.4; }
.history-empty p { font-size: 14px; font-weight: 500; margin-bottom: 4px; color: var(--text-dark); }
.history-empty span { font-size: 12px; color: var(--text-muted); }

.history-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; margin-bottom: 4px;
  transition: all 0.15s;
}
.history-item:hover {
  background: var(--primary-pale); border-color: var(--primary-border);
}
.history-item-number {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary-pale); color: var(--primary);
  font-size: 10px; font-weight: 700; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px;
}
.history-item-body { flex: 1; min-width: 0; }
.history-question {
  font-size: 12px; font-weight: 500; color: var(--text-dark);
  margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-sql-preview {
  font-size: 10px; font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted); margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.history-rows { font-size: 10px; color: var(--primary); font-weight: 500; }
.history-time { font-size: 10px; color: var(--text-faint); }
.history-item-arrow { color: var(--text-faint); flex-shrink: 0; margin-top: 2px; transition: color 0.15s; }
.history-item:hover .history-item-arrow { color: var(--primary); }

.history-footer {
  padding: 10px 16px; border-top: 1px solid var(--border-light);
  font-size: 11px; color: var(--text-muted); flex-shrink: 0; min-width: 320px;
}

/* When history is open, shrink chat */
.app.history-open .chat-area { min-width: 0; }

/* ── CONNECT DB BUTTON ────────────────────────────────────── */
.connect-db-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border: 1.5px solid var(--border-mid);
  border-radius: 20px; background: var(--bg-white);
  color: var(--text-accent); font-size: 13px; font-weight: 500;
  font-family: inherit; cursor: pointer; transition: all 0.2s;
}
.connect-db-btn:hover { background: var(--primary-pale); border-color: var(--primary); }
.connect-db-btn.connected { background: #d1fae5; border-color: #059669; color: #065f46; }
.db-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #d1d5db; transition: background 0.3s; }
.db-status-dot.connected { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }

/* ── MODAL ────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,10,40,0.45); backdrop-filter: blur(4px);
  z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-box { background: var(--bg-white); border-radius: 16px; width: 100%; max-width: 520px; margin: 20px; box-shadow: 0 24px 64px rgba(0,0,0,0.18); border: 1px solid var(--border-light); overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 16px; border-bottom: 1px solid var(--border-light); }
.modal-title { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; color: var(--text-dark); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 6px; display: flex; align-items: center; transition: all 0.15s; }
.modal-close:hover { background: var(--primary-pale); color: var(--primary); }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.modal-desc { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.modal-label { font-size: 12px; font-weight: 600; color: var(--text-dark); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.modal-input-wrap { position: relative; display: flex; align-items: center; }
.modal-input { width: 100%; padding: 10px 40px 10px 12px; border: 1.5px solid var(--border-mid); border-radius: 8px; font-size: 13px; font-family: 'JetBrains Mono', monospace; color: var(--text-dark); background: var(--bg-page); outline: none; transition: border-color 0.2s; }
.modal-input:focus { border-color: var(--primary); background: var(--bg-white); }
.modal-toggle-eye { position: absolute; right: 10px; background: none; border: none; cursor: pointer; color: var(--text-muted); display: flex; align-items: center; padding: 2px; }
.modal-toggle-eye:hover { color: var(--primary); }
.modal-info { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; background: var(--primary-pale); border-radius: 8px; font-size: 12px; color: var(--text-accent); line-height: 1.5; }
.modal-info svg { flex-shrink: 0; margin-top: 1px; }
.modal-example { display: flex; flex-direction: column; gap: 6px; }
.provider-cards { display: flex; flex-direction: column; gap: 6px; }
.provider-card { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg-page); border: 1px solid var(--border-light); border-radius: 8px; font-size: 12px; }
.provider-card strong { color: var(--text-dark); font-weight: 600; min-width: 80px; }
.provider-card span { color: var(--text-muted); font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.db-test-result { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; }
.db-test-result.success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.db-test-result.error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border-light); background: var(--bg-page); }
.modal-btn-secondary { padding: 9px 18px; border: 1.5px solid var(--border-mid); border-radius: 8px; background: var(--bg-white); color: var(--text-muted); font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer; transition: all 0.15s; }
.modal-btn-secondary:hover { background: var(--primary-pale); color: var(--primary); border-color: var(--primary); }
.modal-btn-test { display: flex; align-items: center; gap: 6px; padding: 9px 20px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer; transition: background 0.15s; }
.modal-btn-test:hover { background: var(--primary-hover); }
.modal-btn-test:disabled { opacity: 0.6; cursor: not-allowed; }