/* ============================================================
   SQL.CSS — SQL Workspace page specific styles
   ============================================================ */

/* SQL header bar */
.sql-header {
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border-ghost);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-low);
  flex-shrink: 0;
}
.sql-header h3 { font-size: 1.1rem; font-weight: 600; }
.sql-header .subtitle { font-size: 0.75rem; color: var(--text-secondary); font-family: var(--font-mono); margin-top: 2px; }

/* Layer tabs — pill style */
.tabs {
  display: flex;
  gap: 0.5rem;
  background: rgba(0,0,0,0.3);
  padding: 0.25rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-ghost);
}
.tab {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s;
  background: transparent;
  border: none;
}
.tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.tab.active { background: var(--primary); color: #ffffff; box-shadow: 0 0 12px rgba(0,209,255,0.3); }

/* Editor container with CodeMirror */
.editor-container {
  flex: 0 0 auto;
  min-height: 180px;
  border-bottom: 1px solid var(--border-ghost);
  background: rgba(0,0,0,0.5);
  overflow: hidden;
}
.CodeMirror { height: 100%; min-height: 180px; font-family: var(--font-mono); font-size: 14px; background: transparent !important; }
.CodeMirror-gutters { background: transparent !important; border-right: 1px solid var(--border-ghost) !important; }

/* Actions bar */
.actions {
  padding: 0.75rem 2rem;
  border-bottom: 1px solid var(--border-ghost);
  background: var(--surface-highest);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* NL to SQL container */
.ask-nl-container {
  display: none;
  padding: 1rem 2rem;
  background: linear-gradient(180deg, rgba(0,209,255,0.05) 0%, transparent 100%);
  border-bottom: 1px solid rgba(0,209,255,0.2);
  animation: slideDown 0.2s ease;
}
.ask-nl-container.show { display: block; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.ask-nl-container label {
  display: block;
  font-size: 0.75rem;
  color: var(--primary);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}
.ask-nl-row { display: flex; gap: 0.5rem; align-items: flex-start; }
.ask-nl-input {
  flex: 1;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(0,209,255,0.3);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 0.65rem 1rem;
  resize: vertical;
  min-height: 52px;
  max-height: 120px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.ask-nl-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0,209,255,0.15); }
.ask-nl-input::placeholder { color: var(--text-secondary); opacity: 0.6; }
.ask-nl-generate-btn {
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(139,92,246,0.3);
  transition: all 0.2s;
}
.ask-nl-generate-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.ask-nl-generate-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; filter: none; }
.ask-nl-status { font-size: 0.75rem; color: var(--text-secondary); font-family: var(--font-mono); margin-top: 0.4rem; min-height: 1em; }
.ask-nl-status.error { color: var(--error); }
.ask-nl-status.success { color: var(--success); }

/* Error block */
#errorBlock {
  color: var(--error);
  padding: 0.75rem 2rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  display: none;
  background: rgba(255,115,115,0.08);
  border-bottom: 1px solid rgba(255,115,115,0.15);
}

/* Results */
.results-container {
  flex: 1 1 0;
  min-height: 160px;
  position: relative;
  background: var(--surface-base);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.table-scroll-wrapper { flex: 1; overflow: auto; padding: 1rem 2rem; }
table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-family: var(--font-mono); font-size: 0.83rem; }
th, td { padding: 0.6rem 1rem; text-align: left; border-bottom: 1px solid var(--border-ghost); white-space: nowrap; }
th { background: var(--surface-highest); color: var(--primary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; position: sticky; top: 0; z-index: 1; }
tr:hover td { background: rgba(255,255,255,0.03); }

/* Chart */
#chartContainer { display: none; padding: 1rem; max-height: 380px; position: relative; overflow: hidden; }

/* Footer metrics */
.footer-metrics {
  padding: 0.75rem 2rem;
  border-top: 1px solid var(--border-ghost);
  display: flex;
  gap: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  background: var(--surface-lowest);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.metric span { color: var(--text-primary); font-family: var(--font-mono); font-weight: 700; }
.metric-accent span { color: var(--primary); }

/* Explain SQL panel */
#explainSqlPanel {
  display: none;
  padding: 1rem 2rem;
  background: linear-gradient(180deg, rgba(139,92,246,0.06) 0%, transparent 100%);
  border-bottom: 1px solid rgba(139,92,246,0.2);
}
#explainSqlContent {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
  max-height: 200px;
  overflow-y: auto;
}