/* Bettercast Lab — workbench styles */

:root {
  --lab-primary: #764ba2;
  --lab-primary-2: #667eea;
  --lab-bg: #f7f8fb;
  --lab-bg-card: #ffffff;
  --lab-border: #e5e7eb;
  --lab-text: #1f2937;
  --lab-text-muted: #6b7280;
  --lab-text-subtle: #9ca3af;
  --lab-code-bg: #f5f3ff;
  --lab-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
}

body {
  background: var(--lab-bg);
  color: var(--lab-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  height: 100vh;
  overflow: hidden;
}

/* ---- Navbar ---- */

.lab-navbar {
  background: linear-gradient(135deg, var(--lab-primary), var(--lab-primary-2));
  padding: 8px 16px;
  height: 52px;
}
.lab-navbar .navbar-brand {
  color: white;
  font-size: 1.05rem;
}
.lab-navbar .navbar-brand:hover { color: white; }

/* ---- Main layout ---- */

.lab-main {
  height: calc(100vh - 52px);
  overflow: hidden;
}

.lab-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
}

/* ---- Sidebar ---- */

.lab-sidebar {
  background: var(--lab-bg-card);
  border-right: 1px solid var(--lab-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lab-sidebar-head {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--lab-text-muted);
  border-bottom: 1px solid var(--lab-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.lab-history {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.lab-history-item {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--lab-text);
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.1s;
  display: flex;
  align-items: center;
}
.lab-history-item:hover {
  background: var(--lab-bg);
}

.lab-suggestions {
  padding: 12px;
  border-top: 1px solid var(--lab-border);
  background: #fbfbfd;
}
.lab-suggestion {
  display: block;
  width: 100%;
  text-align: left;
  background: white;
  border: 1px solid var(--lab-border);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--lab-text);
  cursor: pointer;
  transition: all 0.15s;
}
.lab-suggestion:hover {
  border-color: var(--lab-primary);
  background: var(--lab-code-bg);
}

/* ---- Main column ---- */

.lab-main-col {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--lab-bg);
  overflow: hidden;
}

.lab-conv {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Welcome card */

.lab-welcome {
  max-width: 720px;
  margin: 40px auto;
}
.lab-welcome-card {
  background: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--lab-shadow);
  border: 1px solid var(--lab-border);
}

/* Messages */

.lab-msg {
  max-width: 860px;
  margin: 0 auto 16px;
  display: flex;
}
.lab-msg-user { justify-content: flex-end; }
.lab-msg-agent { justify-content: flex-start; }

.lab-bubble {
  background: linear-gradient(135deg, var(--lab-primary), var(--lab-primary-2));
  color: white;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  max-width: 72%;
  word-wrap: break-word;
  white-space: pre-wrap;
  line-height: 1.4;
}
.lab-bubble-agent {
  background: white;
  border: 1px solid var(--lab-border);
  padding: 14px 16px;
  border-radius: 16px 16px 16px 4px;
  max-width: 92%;
  min-width: 280px;
  line-height: 1.5;
  box-shadow: var(--lab-shadow);
}

.lab-thinking {
  color: var(--lab-text-muted);
  font-size: 13px;
  font-style: italic;
}

.lab-explanation {
  font-size: 14px;
  color: var(--lab-text);
}

.lab-error-text {
  color: #b91c1c;
  font-size: 13px;
  margin-top: 6px;
  background: #fef2f2;
  padding: 6px 10px;
  border-radius: 4px;
}

/* Action tags */

.lab-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  margin-right: 8px;
  letter-spacing: 0.3px;
  vertical-align: middle;
}
.lab-tag-sql      { background: #e0f2fe; color: #075985; }
.lab-tag-notes    { background: #fef3c7; color: #92400e; }
.lab-tag-decline  { background: #f3f4f6; color: #4b5563; }
.lab-tag-clarify  { background: #fce7f3; color: #9d174d; }
.lab-tag-error    { background: #fee2e2; color: #991b1b; }

/* Collapsible details */

.lab-details {
  margin-top: 10px;
  border-top: 1px solid #f3f4f6;
  padding-top: 8px;
}
.lab-details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--lab-primary);
  font-weight: 500;
  list-style: none;
  user-select: none;
}
.lab-details summary::-webkit-details-marker { display: none; }
.lab-details summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s;
}
.lab-details[open] summary::before { transform: rotate(90deg); }
.lab-details pre {
  background: var(--lab-code-bg);
  border-left: 3px solid var(--lab-primary);
  padding: 10px 12px;
  font-size: 12px;
  margin: 8px 0 0 0;
  border-radius: 4px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: "SF Mono", Menlo, Monaco, "Courier New", monospace;
}

/* Tables */

.lab-table-wrap {
  margin-top: 10px;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--lab-border);
  border-radius: 6px;
}
.lab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.lab-table th {
  background: #f9fafb;
  color: var(--lab-text);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--lab-border);
  position: sticky;
  top: 0;
  text-align: left;
}
.lab-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: top;
  max-width: 380px;
  word-wrap: break-word;
}
.lab-table tr:hover td { background: #fafbff; }
.lab-rowcount {
  font-size: 11.5px;
  color: var(--lab-text-subtle);
  margin-top: 4px;
}

/* Chart */

.lab-chart {
  margin-top: 12px;
  background: #fafbff;
  border-radius: 6px;
  padding: 8px;
  border: 1px solid var(--lab-border);
}

/* ---- Input row ---- */

.lab-input-row {
  padding: 14px 24px 18px;
  background: var(--lab-bg);
  border-top: 1px solid var(--lab-border);
}

.lab-input-wrap {
  display: flex;
  gap: 8px;
  background: white;
  border: 1px solid var(--lab-border);
  border-radius: 12px;
  padding: 8px 8px 8px 14px;
  box-shadow: var(--lab-shadow);
  max-width: 860px;
  margin: 0 auto;
  align-items: flex-end;
}
.lab-input-wrap:focus-within {
  border-color: var(--lab-primary);
}
.lab-input-wrap textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  padding: 6px 0;
  line-height: 1.4;
  max-height: 160px;
}
.lab-input-wrap button {
  border-radius: 8px;
  padding: 8px 14px;
  background: linear-gradient(135deg, var(--lab-primary), var(--lab-primary-2));
  border: none;
  color: white;
}
.lab-input-wrap button:disabled { opacity: 0.5; }

.lab-input-row .text-muted {
  text-align: center;
  max-width: 860px;
  margin: 0 auto;
  font-size: 11.5px;
}

/* Responsive (narrow screen — hide sidebar) */

@media (max-width: 768px) {
  .lab-grid { grid-template-columns: 1fr; }
  .lab-sidebar { display: none; }
}

/* --- 8760 build: confirm, progress, downloads --- */
.lab-profile { border: 1px solid var(--lab-border, #d8d8e0); border-radius: 8px;
  padding: 12px; margin-top: 10px; }
.lab-profile-est { font-size: 13px; opacity: .8; }
.lab-profile-badges { font-size: 13px; margin: 4px 0 8px; }
.lab-run-btn { padding: 6px 14px; border-radius: 6px; border: 0;
  background: #5b5bd6; color: #fff; font-size: 13px; cursor: pointer; }
.lab-run-btn:disabled { opacity: .55; cursor: default; }
.lab-progress { height: 8px; border-radius: 4px; background: #e6e6ef;
  overflow: hidden; margin-top: 10px; }
.lab-progress-bar { height: 100%; background: #5b5bd6; transition: width .4s ease; }
.lab-progress-step { font-size: 12px; opacity: .75; margin-top: 4px; }
.lab-warnings { margin-top: 10px; padding: 8px 10px; border-radius: 6px;
  background: #fff4e5; border: 1px solid #f0c894; font-size: 13px; }
.lab-warnings ul, .lab-files ul { margin: 4px 0 0; padding-left: 18px; }
.lab-files { margin-top: 10px; font-size: 13px; }

/* Post-query sanity warnings — shown above the table, never after it. */
.lab-sanity { margin: 6px 0; padding: 7px 10px; border-radius: 6px;
  background: #fff4e5; border: 1px solid #f0c894; font-size: 12px; }

/* Agent reasoning steps */
.lab-steps { margin: 6px 0; font-size: 12px; }
.lab-step { padding: 4px 8px; margin: 3px 0; border-left: 2px solid #5b5bd6;
  background: #f6f6fb; font-size: 11px; word-break: break-word; }

/* Generated report download */
.lab-report { margin: 10px 0; padding: 12px 14px; border-radius: 6px;
  background: #eef0ff; border: 1px solid #c9cdf5; }
.lab-report-btn { display: inline-block; padding: 7px 14px; border-radius: 6px;
  background: #5b5bd6; color: #fff; text-decoration: none; font-size: 13px; }
.lab-report-note { margin-top: 6px; font-size: 11px; color: #5a5a68; }

/* CSV export */
.lab-csv-btn { margin-top: 8px; padding: 5px 12px; border-radius: 6px; border: 1px solid #c9cdf5;
  background: #eef0ff; color: #3a3a8c; font-size: 12px; cursor: pointer; }
.lab-csv-btn:hover { background: #e2e5ff; }
