/* LS Analytics — re-skinned to Legalsense design system.
   Primary tokens come from legalsense-tokens.css (loaded earlier in <head>).
   This file maps the app's structural styles onto LS tokens. */

:root {
  /* Bridge aliases for legacy references in app.js (e.g. --text-light). */
  --text:        var(--ls-ink-900);
  --text-light:  var(--ls-ink-500);
  --font:        var(--font-ui);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--ls-canvas);
  color: var(--ls-ink-900);
  font-size: 14px;
  line-height: var(--leading-normal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Sticky top section ── */
.sticky-top {
  flex-shrink: 0;
  background: var(--ls-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

/* ── Top bar ── */
.topbar {
  padding: 0 24px 0 0;
  display: flex;
  align-items: center;
  height: 64px;
  gap: 12px;
}
.topbar-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  padding-left: 24px;
}
.topbar-logo img {
  height: 40px;
  width: auto;
}
.logo-analytics {
  font-family: 'Courier New', Courier, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: var(--ls-coral-500);
  margin-left: 12px;
  margin-top: 3px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.firm-badge {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.04em;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--ls-peri-100);
  color: var(--ls-navy-700);
  border: none;
}

/* ── Theme toggle (sliding switch) ── */
.theme-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.theme-toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--ls-canvas-warm);
  border: 1px solid var(--border);
  transition: background var(--duration-fast) var(--ease-out-quart),
              border-color var(--duration-fast) var(--ease-out-quart);
}
.theme-toggle-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-out-quart);
}
.theme-toggle-sun  { left: 5px;  color: var(--ls-coral-500); opacity: 1; }
.theme-toggle-moon { right: 5px; color: var(--ls-navy-700);  opacity: 0.75; }
.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2), 0 1px 1px rgba(0,0,0,0.06);
  transition: transform var(--duration-base) var(--ease-out-quart),
              background var(--duration-fast) var(--ease-out-quart);
  pointer-events: none;
}
.theme-toggle:hover .theme-toggle-track { border-color: var(--border-strong); }

/* ── Scope section ── */
.scope-section {
  background: var(--ls-canvas);
  border-top: 1px solid var(--ls-line-100);
}
.scope-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 24px;
}
.scope-row + .scope-row {
  border-top: 1px solid var(--ls-line-100);
}
.scope-label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ls-ink-500);
  white-space: nowrap;
  min-width: 110px;
}
.scope-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.picker-search { position: relative; width: 220px; flex-shrink: 0; }
.picker-search input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  color: var(--ls-ink-900);
  background: var(--ls-surface);
  transition: border-color var(--duration-fast) var(--ease-out-quart),
              box-shadow var(--duration-fast) var(--ease-out-quart);
}
.picker-search input:focus {
  outline: none;
  border-color: var(--ls-navy-700);
  box-shadow: 0 0 0 3px rgba(26,31,106,0.10);
}
.picker-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--ls-surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-md);
}
.picker-results.open { display: block; }
.picker-result {
  padding: 8px 12px;
  font-size: var(--text-sm);
  cursor: pointer;
  color: var(--ls-ink-900);
}
.picker-result:hover, .picker-result.highlighted { background: var(--ls-peri-100); }
.picker-result .picker-result-type {
  font-size: var(--text-xs);
  color: var(--ls-ink-500);
  margin-left: 6px;
}

.picker-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--ls-peri-500);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.picker-chip-x {
  background: none;
  border: none;
  color: white;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.75;
  padding: 0 0 0 2px;
}
.picker-chip-x:hover { opacity: 1; }

.picker-matters select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  color: var(--ls-ink-900);
  background: var(--ls-surface);
  max-width: 300px;
}
.picker-matters select:focus {
  outline: none;
  border-color: var(--ls-navy-700);
}

/* ── Preset buttons ── */
.preset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--ls-surface);
  color: var(--ls-ink-700);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  font-family: var(--font-ui);
  transition: background var(--duration-fast) var(--ease-out-quart),
              border-color var(--duration-fast) var(--ease-out-quart),
              color var(--duration-fast) var(--ease-out-quart);
}
.preset-btn:hover {
  background: var(--ls-surface-hover);
  border-color: var(--ls-peri-300);
  color: var(--ls-navy-700);
}
.preset-btn.active {
  background: var(--ls-navy-700);
  color: white;
  border-color: var(--ls-navy-700);
}

/* ── Query bar ── */
.query-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 24px 14px;
  border-top: 1px solid var(--ls-line-100);
  background: var(--ls-surface);
}
.query-bar textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  color: var(--ls-ink-900);
  background: var(--ls-surface);
  resize: none;
  height: 40px;
  line-height: 1.5;
  transition: border-color var(--duration-fast) var(--ease-out-quart),
              box-shadow var(--duration-fast) var(--ease-out-quart);
}
.query-bar textarea::placeholder { color: var(--ls-ink-400); }
.query-bar textarea:focus {
  outline: none;
  border-color: var(--ls-navy-700);
  box-shadow: 0 0 0 3px rgba(26,31,106,0.10);
}
.query-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Model toggle ── */
.model-toggle {
  display: flex;
  gap: 2px;
  background: var(--ls-peri-100);
  border-radius: var(--radius-md);
  padding: 3px;
}
.model-btn {
  padding: 5px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  font-family: var(--font-ui);
  cursor: pointer;
  background: transparent;
  color: var(--ls-ink-500);
  transition: background var(--duration-fast) var(--ease-out-quart),
              color var(--duration-fast) var(--ease-out-quart);
}
.model-btn:hover { color: var(--ls-navy-700); }
.model-btn.active {
  background: var(--ls-surface);
  color: var(--ls-navy-700);
  font-weight: var(--weight-bold);
  box-shadow: var(--shadow-xs);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--duration-fast) var(--ease-out-quart),
              border-color var(--duration-fast) var(--ease-out-quart),
              color var(--duration-fast) var(--ease-out-quart);
  text-decoration: none;
  font-family: var(--font-sans);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--ls-navy-700);
  color: white;
  border-color: var(--ls-navy-700);
}
.btn-primary:hover { background: var(--ls-navy-900); border-color: var(--ls-navy-900); }
.btn-secondary {
  background: var(--ls-surface);
  color: var(--ls-navy-700);
  border: 1.5px solid var(--ls-navy-700);
}
.btn-secondary:hover { background: var(--ls-navy-700); color: white; }
.btn-sm { padding: 6px 14px; font-size: var(--text-xs); }

/* ── Scrollable content area ── */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Diagram toggle ── */
.diagram-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--ls-ink-700);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.diagram-toggle input { cursor: pointer; accent-color: var(--ls-navy-700); }

button#clear {
  font-family: var(--font-sans);
  background: var(--ls-danger-bg);
  color: var(--ls-danger);
  border: 1px solid transparent;
}
button#clear:hover {
  background: var(--ls-danger);
  color: white;
}

/* ── Status indicator ── */
.status {
  color: var(--ls-coral-500);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  margin-bottom: 12px;
  display: none;
}
.status.visible { display: block; }

/* ── Progress bar ── */
.progress-bar {
  display: none;
  height: 4px;
  background: var(--ls-peri-100);
  border-radius: var(--radius-pill);
  margin-bottom: 16px;
  overflow: hidden;
}
.progress-bar.visible { display: block; }
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--ls-coral-500);
  border-radius: var(--radius-pill);
  transition: width 0.6s var(--ease-out-quart);
}

/* ── Conversation ── */
.conv-q {
  background: var(--ls-peri-100);
  border-left: 3px solid var(--ls-peri-500);
  padding: 12px 16px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-bottom: 12px;
  font-size: var(--text-sm);
  color: var(--ls-ink-700);
}
.conv-a {
  background: var(--ls-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  font-size: var(--text-base);
  line-height: var(--leading-loose);
  color: var(--ls-ink-700);
  margin-bottom: 24px;
  box-shadow: var(--shadow-xs);
}
.conv-a strong { color: var(--ls-ink-900); font-weight: var(--weight-bold); }

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
.thinking-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ls-navy-700);
  opacity: 0.3;
  animation: thinking-pulse 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinking-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(1); }
  40%           { opacity: 1;   transform: scale(1.3); }
}

/* ── Executive Summary callout ── */
.exec-summary {
  background: var(--ls-peri-100);
  border-left: 4px solid var(--ls-coral-500);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  padding: 18px 24px;
  margin: 4px 0 20px 0;
}
.exec-summary-title {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--ls-coral-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ls-peri-200);
}
.exec-summary strong { color: var(--ls-navy-700); }

/* ── Section headings in answers ── */
.section-heading {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--ls-navy-700);
  margin: 24px 0 10px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ls-line-100);
}
.subsection-heading {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--ls-navy-700);
  margin: 16px 0 8px 0;
}

/* ── Data tables ── */
.data-table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0 16px 0;
  font-size: var(--text-sm);
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.data-table th {
  text-align: left;
  font-family: var(--font-ui);
  font-weight: var(--weight-bold);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 12px;
  background: var(--ls-canvas);
  border-bottom: 1px solid var(--ls-line-100);
  color: var(--ls-ink-500);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--ls-line-100);
  color: var(--ls-ink-700);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--ls-canvas); }

/* ── Mermaid charts ── */
.mermaid-container {
  margin: 18px 0;
  padding: 24px;
  background: var(--ls-canvas);
  border: 1px solid var(--ls-line-100);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}
.mermaid-container svg { max-width: 100%; height: auto; }

.csv-download-block { margin: 16px 0; }
.csv-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: var(--ls-navy-700);
  color: white;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out-quart);
}
.csv-download-btn:hover { background: var(--ls-navy-600); }

/* ── Follow-up ── */
.followup {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  margin-bottom: 24px;
}
.followup textarea {
  flex: 1;
  padding: 9px 14px;
  background: var(--ls-surface);
  border: 1px solid var(--border);
  color: var(--ls-ink-900);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  resize: none;
  height: 40px;
}
.followup textarea:focus {
  outline: none;
  border-color: var(--ls-navy-700);
  box-shadow: 0 0 0 3px rgba(26,31,106,0.10);
}
.followup button {
  padding: 0 18px;
  background: var(--ls-navy-700);
  border: 1px solid var(--ls-navy-700);
  color: white;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  font-family: var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
}
.followup button:hover { background: var(--ls-navy-900); }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,31,106,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--ls-surface);
  border-radius: var(--radius-xl);
  width: 440px;
  max-width: 95vw;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--ls-line-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--ls-navy-700);
}
.modal-close {
  cursor: pointer;
  font-size: 22px;
  color: var(--ls-ink-500);
  background: none;
  border: none;
  line-height: 1;
}
.modal-close:hover { color: var(--ls-navy-700); }
.modal-body { padding: 24px; color: var(--ls-ink-700); }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--ls-line-100);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.modal-pros { margin-bottom: 18px; }
.modal-pro, .modal-con {
  font-size: var(--text-sm);
  padding: 5px 0;
  color: var(--ls-ink-700);
}
.modal-pro::before {
  content: '+';
  display: inline-block;
  width: 22px;
  color: var(--ls-success);
  font-weight: var(--weight-bold);
}
.modal-con::before {
  content: '\2212';
  display: inline-block;
  width: 22px;
  color: var(--ls-warning);
  font-weight: var(--weight-bold);
}
