/* Core Design System & Styling for AI SQL Platform */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&family=Fira+Code:wght@400;500&display=swap');

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: rgba(17, 24, 39, 0.7);
  --bg-sidebar: #0f172a;
  --bg-panel: #1e293b;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #64748b;
  
  --accent-primary: #6366f1; /* Indigo */
  --accent-secondary: #14b8a6; /* Teal */
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  --accent-glow: rgba(99, 102, 241, 0.15);
  
  --success: #10b981;
  --error: #f43f5e;
  --warning: #f59e0b;
  --info: #3b82f6;

  --sidebar-width: 280px;
  --explorer-width: 320px;
  --header-height: 70px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Scrollbar styles */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
}

/* App Layout Grid */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
  transition: transform var(--transition-normal);
}

.sidebar.collapsed {
  display: none;
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-gradient);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.logo-icon svg {
  color: white;
  width: 18px;
  height: 18px;
}

.logo-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.btn-new-chat {
  margin: 0 16px 20px 16px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
  transition: all var(--transition-fast);
}

.btn-new-chat:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
  filter: brightness(1.08);
}

.btn-new-chat svg {
  width: 16px;
  height: 16px;
}

.history-section {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0 12px 20px 12px;
}

.history-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dark);
  letter-spacing: 0.05em;
  padding: 0 8px 10px 8px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-muted);
  font-size: 0.85rem;
  border: 1px solid transparent;
}

.history-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
}

.history-item.active {
  background-color: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.2);
  color: var(--text-main);
}

.history-item-label {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex-grow: 1;
}

.history-item-label svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-delete-session {
  background: transparent;
  border: none;
  color: var(--text-dark);
  cursor: pointer;
  opacity: 0;
  padding: 2px;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.history-item:hover .btn-delete-session {
  opacity: 1;
}

.btn-delete-session:hover {
  color: var(--error);
  background-color: rgba(244, 63, 94, 0.15);
}

.btn-delete-session svg {
  width: 13px;
  height: 13px;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-dark);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* Main Area Container */
.main-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  position: relative;
}

/* Main Top Header */
.main-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(11, 15, 25, 0.6);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.header-title-container h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.btn-icon {
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: var(--border-hover);
}

.btn-icon svg {
  width: 16px;
  height: 16px;
}

/* Chat Stream Container */
.chat-container {
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Empty State / Welcome Screen */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

.empty-logo {
  width: 70px;
  height: 70px;
  background: var(--accent-gradient);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.3);
}

.empty-logo svg {
  width: 32px;
  height: 32px;
  color: white;
}

.empty-state h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  margin-bottom: 12px;
  font-weight: 700;
  background: linear-gradient(135deg, #ffffff 0%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 32px;
  line-height: 1.5;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

.suggestion-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggestion-card:hover {
  border-color: var(--accent-primary);
  background-color: rgba(99, 102, 241, 0.03);
  transform: translateY(-2px);
}

.suggestion-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.suggestion-header svg {
  width: 14px;
  height: 14px;
}

.suggestion-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Chat Messages */
.message {
  display: flex;
  gap: 16px;
  max-width: 85%;
  min-width: 0;
  animation: fadeIn 0.3s ease;
}

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

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.assistant {
  align-self: flex-start;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.message.assistant .avatar {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

.avatar svg {
  width: 18px;
  height: 18px;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.message.user .bubble {
  background-color: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  overflow-wrap: break-word;
}

.message.assistant .bubble {
  color: var(--text-main);
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 4px 0;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
}

/* SQL Result Cards & Badges */
.answer-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(6, 182, 212, 0.05));
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 4px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-main);
}

.answer-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-secondary);
  margin-bottom: 8px;
}

.answer-card-header svg {
  width: 14px;
  height: 14px;
}

.answer-card-body {
  white-space: pre-wrap;
}

.sql-card {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-top: 10px;
  width: 100%;
  max-width: 100%;
}

.sql-card-header {
  background-color: rgba(0, 0, 0, 0.2);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.sql-card-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sql-card-title svg {
  width: 14px;
  height: 14px;
  color: var(--accent-secondary);
}

.btn-copy-sql {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.btn-copy-sql:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.btn-copy-sql svg {
  width: 12px;
  height: 12px;
}

.sql-card-body {
  padding: 14px 16px;
  overflow-x: auto;
  background-color: rgba(0, 0, 0, 0.1);
}

.sql-card-body pre {
  margin: 0;
}

.sql-card-body code {
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  color: #a7f3d0;
  white-space: pre-wrap;
  word-break: break-all;
}

.sql-card.error-card {
  border-color: var(--error);
  background-color: rgba(244, 63, 94, 0.05);
}

.error-message {
  color: var(--error);
  font-size: 0.85rem;
  padding: 8px 0;
}

/* Multi Query Section */
.multi-query-section {
  margin-top: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: rgba(15, 23, 42, 0.4);
}

.multi-query-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
}

.row-count-badge {
  margin-left: auto;
  background-color: var(--accent-primary);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Query Metadata / Stats panel */
.query-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.stat-badge {
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-badge.success {
  border-color: rgba(16, 185, 129, 0.2);
  background-color: rgba(16, 185, 129, 0.05);
  color: var(--success);
}

.stat-badge.cached {
  border-color: rgba(59, 130, 246, 0.2);
  background-color: rgba(59, 130, 246, 0.05);
  color: var(--info);
}

.stat-badge svg {
  width: 12px;
  height: 12px;
}

/* Tabular Data View */
.data-table-container {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: auto;
  max-height: 400px;
  margin-top: 14px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 100%;
}

.data-table {
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
  background-color: rgba(15, 23, 42, 0.4);
}

.data-table th {
  background-color: var(--bg-panel);
  color: var(--text-main);
  font-weight: 600;
  padding: 10px 14px;
  position: sticky;
  top: 0;
  border-bottom: 2px solid var(--border-color);
  z-index: 1;
  white-space: nowrap;
  min-width: 120px;
}

.data-table td {
  padding: 8px 14px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text-main);
}

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

.table-empty-state {
  padding: 20px;
  text-align: center;
  color: var(--text-dark);
  font-style: italic;
  font-size: 0.8rem;
  background-color: rgba(0, 0, 0, 0.1);
}

/* Chat Input Bar Area */
.input-area {
  padding: 24px;
  border-top: 1px solid var(--border-color);
  background-color: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(12px);
  z-index: 5;
}

.input-box {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  transition: border-color var(--transition-fast);
}

.input-box:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow), var(--shadow-lg);
}

.input-box textarea {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  height: 48px;
  max-height: 200px;
}

.input-box textarea::placeholder {
  color: var(--text-dark);
}

.input-box-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.input-options {
  display: flex;
  gap: 8px;
}

.btn-option {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.btn-option:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.btn-option svg {
  width: 14px;
  height: 14px;
}

.btn-send {
  background: var(--accent-gradient);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
  transition: all var(--transition-fast);
}

.btn-send:hover {
  transform: scale(1.05);
  filter: brightness(1.1);
}

.btn-send svg {
  width: 16px;
  height: 16px;
}

.input-disclaimer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-dark);
  margin-top: 10px;
}

/* Right Sidebar: Schema Explorer */
.schema-explorer {
  width: var(--explorer-width);
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
  transition: transform var(--transition-normal);
}

.schema-explorer.collapsed {
  display: none;
}

.explorer-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.explorer-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.explorer-title svg {
  width: 16px;
  height: 16px;
  color: var(--accent-primary);
}

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

.btn-refresh:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.btn-refresh.spinning svg {
  animation: spin 1s linear infinite;
}

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

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

.explorer-search {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.search-box {
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.8rem;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-dark);
}

.search-box svg {
  width: 14px;
  height: 14px;
  color: var(--text-dark);
}



.explorer-content {
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  min-height: 0;
}

.schema-table-item {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.schema-table-item:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.schema-table-header {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.schema-table-name {
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  min-width: 0;
  flex: 1 1 auto;
}

.schema-table-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.schema-table-name svg {
  width: 13px;
  height: 13px;
  color: var(--text-muted);
}

.schema-table-meta {
  font-size: 0.7rem;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

.schema-table-meta svg {
  width: 10px;
  height: 10px;
  transition: transform var(--transition-fast);
}

.schema-table-item.open .schema-table-meta svg {
  transform: rotate(180deg);
}

.schema-table-body {
  display: none;
  background-color: rgba(0, 0, 0, 0.15);
  border-top: 1px solid var(--border-color);
  padding: 8px 14px;
}

.schema-table-item.open .schema-table-body {
  display: block;
}

.column-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.column-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
}

.column-name-box {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.column-name-box.pk {
  color: var(--accent-secondary);
  font-weight: 500;
}

.column-name-box.fk {
  color: var(--accent-primary);
}

.column-name-box svg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

.column-type {
  font-family: 'Fira Code', monospace;
  color: var(--text-dark);
  font-size: 0.65rem;
}

/* Toast Notification */
.toast-container {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background-color: #1e293b;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg), var(--shadow-glass);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 250px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 4px solid var(--info);
}

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

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--error);
}

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

.toast.success svg {
  color: var(--success);
}

.toast.error svg {
  color: var(--error);
}

/* Skeleton Loaders */
.skeleton {
  animation: pulse 1.5s ease-in-out infinite;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.skeleton-text {
  height: 14px;
  width: 80%;
  margin-bottom: 8px;
}

.skeleton-text.short {
  width: 40%;
}

/* =========================================================
   Mobile backdrop (shown behind sidebar/explorer drawers)
   ========================================================= */
.mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 40;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.mobile-backdrop.visible {
  display: block;
  opacity: 1;
}

/* =========================================================
   Responsive breakpoints
   ========================================================= */

/* Tablet: narrower schema explorer, tighter spacing */
@media (max-width: 1180px) {
  :root {
    --explorer-width: 280px;
  }

  .suggestions-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Small tablet / large phone landscape: sidebar + explorer become
   slide-in overlay drawers instead of fixed columns, so the chat
   always gets the full width by default. */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(85vw, var(--sidebar-width));
    box-shadow: 20px 0 40px rgba(0, 0, 0, 0.4);
    transform: translateX(0);
  }

  .sidebar.collapsed {
    display: flex; /* keep in DOM/layout so the slide-out transition can play */
    transform: translateX(-100%);
    box-shadow: none;
  }

  .schema-explorer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(85vw, var(--explorer-width));
    box-shadow: -20px 0 40px rgba(0, 0, 0, 0.4);
    transform: translateX(0);
  }

  .schema-explorer.collapsed {
    display: flex; /* keep in DOM/layout so the slide-out transition can play */
    transform: translateX(100%);
    box-shadow: none;
  }

  .main-header h1#session-title {
    font-size: 1rem;
  }
}

/* Phone: tighter paddings, single-column suggestions, full-width messages */
@media (max-width: 640px) {
  .main-header {
    padding: 0 14px;
    height: 60px;
  }

  .header-actions {
    gap: 8px;
  }

  .btn-icon {
    width: 34px;
    height: 34px;
  }

  .chat-container {
    padding: 18px 12px;
    gap: 18px;
  }

  .empty-logo {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    margin-bottom: 18px;
  }

  .empty-logo svg {
    width: 26px;
    height: 26px;
  }

  .empty-state h2 {
    font-size: 1.35rem;
  }

  .empty-state p {
    font-size: 0.88rem;
    margin-bottom: 22px;
  }

  .suggestions-grid {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 100%;
    gap: 10px;
  }

  .avatar {
    width: 30px;
    height: 30px;
  }

  .avatar svg {
    width: 15px;
    height: 15px;
  }

  .message.user .bubble,
  .message.assistant .bubble {
    font-size: 0.9rem;
  }

  .sql-card-body code {
    font-size: 0.78rem;
  }

  .data-table {
    font-size: 0.78rem;
  }

  .data-table th,
  .data-table td {
    padding: 7px 10px;
  }

  .data-table td {
    max-width: 160px;
  }

  .data-table-container {
    max-height: 320px;
  }

  .input-area {
    padding: 14px 12px calc(14px + env(safe-area-inset-bottom));
  }

  .input-box textarea {
    height: 42px;
    font-size: 0.9rem;
  }

  .btn-option span {
    display: none; /* icon-only cache toggle on very small screens */
  }

  .input-disclaimer {
    font-size: 0.65rem;
  }

  .sidebar,
  .schema-explorer {
    width: 82vw;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast {
    min-width: 0;
    width: 100%;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .logo-text {
    font-size: 1rem;
  }

  .sidebar-header {
    padding: 18px 16px;
  }

  .header-title-container h1 {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Similar Tables Banner Styles */
.similar-tables-banner {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px dashed;
  font-size: 0.85rem;
}

.similar-tables-banner.all-mode {
  background-color: rgba(20, 184, 166, 0.06);
  border-color: rgba(20, 184, 166, 0.3);
  color: #14b8a6;
}

.similar-tables-banner.relevant-mode {
  background-color: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.3);
  color: #94a3b8;
}

.similar-tables-banner .banner-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 8px;
}

.similar-tables-banner.all-mode .banner-header {
  color: #2dd4bf;
}

.similar-tables-banner.relevant-mode .banner-header {
  color: #818cf8;
}

.similar-tables-banner .banner-header svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.similar-tables-banner .banner-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 23px;
}

.similar-match-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fira Code', monospace;
  font-size: 0.78rem;
}

.similar-match-item svg {
  width: 12px;
  height: 12px;
  color: var(--text-dark);
}

.similar-match-item .primary-tbl {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.similar-match-item .counterparts-list {
  color: var(--text-muted);
  background-color: rgba(255, 255, 255, 0.03);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* Make sure option toggle buttons show correctly */
.btn-option.active {
  background-color: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-option.active span {
  color: var(--text-main);
}

/* Login Modal Overlay & Form */
.login-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 20% 20%, #1e1b4b 0%, #0b0f19 65%, #05070c 100%);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-overlay.hidden {
  display: none !important;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 40px 34px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  animation: modalSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-icon {
  width: 60px;
  height: 60px;
  background: var(--accent-glow);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.login-icon svg {
  width: 28px;
  height: 28px;
  color: var(--accent-primary);
}

.login-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.login-header p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-form label {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.login-form label svg {
  width: 14px;
  height: 14px;
}

.login-form input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  color: #ffffff;
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.login-form input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-error {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fb7185;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  text-align: center;
}

.btn-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.btn-login:hover {
  opacity: 0.94;
  transform: translateY(-1px);
}

.btn-login svg {
  width: 18px;
  height: 18px;
}


/* User Info Bar in Sidebar */
.user-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

#logged-username {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

#logged-username svg {
  width: 14px;
  height: 14px;
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.btn-logout:hover {
  color: var(--error);
}

.btn-logout svg {
  width: 16px;
  height: 16px;
}


