/* requ dashboard — custom styles to complement Tailwind CDN */

/* ── Fonts ─────────────────────────────────────────────── */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbars ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Skeleton loader animation ─────────────────────────── */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.skeleton {
  background: #e2e8f0;
  border-radius: 6px;
  animation: skeleton-pulse 1.6s ease-in-out infinite;
}
.skeleton-sm  { height: 12px; }
.skeleton-md  { height: 16px; }
.skeleton-lg  { height: 24px; }
.skeleton-xl  { height: 40px; }

/* ── Progress bar ───────────────────────────────────────── */
.progress-track {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.5s ease;
}
.progress-fill--green  { background: #16a34a; }
.progress-fill--indigo { background: #4f46e5; }
.progress-fill--amber  { background: #d97706; }
.progress-fill--red    { background: #dc2626; }

/* Mini progress (inside KPI cards) */
.progress-mini {
  height: 4px;
  background: #f1f5f9;
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-mini-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.5s ease;
}

/* ── Chart containers ───────────────────────────────────── */
.chart-container {
  position: relative;
  height: 380px;
  width: 100%;
}
.chart-container-sm {
  position: relative;
  height: 260px;
  width: 100%;
}

/* ── Tab transition ─────────────────────────────────────── */
[x-cloak] { display: none !important; }

.tab-panel {
  animation: fadeIn 0.18s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Table ──────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.data-table th:hover { background: #f1f5f9; color: #334155; }
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: #334155;
}
.data-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr.expanded { background: #f0f9ff; }

/* ── Expandable detail row ──────────────────────────────── */
.detail-row td {
  padding: 0 !important;
  border-bottom: 2px solid #e2e8f0 !important;
  cursor: default;
}
.detail-row:hover { background: transparent !important; }
.detail-content {
  padding: 16px 14px 16px 40px;
  background: #f8fafc;
}

/* ── Pill badges ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-amber  { background: #fef3c7; color: #b45309; }
.badge-slate  { background: #f1f5f9; color: #475569; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-indigo { background: #e0e7ff; color: #4338ca; }
.badge-purple { background: #ede9fe; color: #6d28d9; }

/* ── Pulse dot (active phase) ───────────────────────────── */
.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.4);
  animation: pulse-ring 2s ease-out infinite;
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  70%  { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* ── KPI card ───────────────────────────────────────────── */
.kpi-card {
  background: white;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 20px 24px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.kpi-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.07); border-color: #c7d2fe; }

/* ── Section card ───────────────────────────────────────── */
.section-card {
  background: white;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
}
.section-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  font-weight: 600;
  font-size: 0.9rem;
  color: #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Component card ─────────────────────────────────────── */
.component-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.component-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); border-color: #a5b4fc; }

/* ── Gaps panel ─────────────────────────────────────────── */
.gap-panel-red    { background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; padding: 16px; }
.gap-panel-amber  { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 16px; }
.gap-panel-slate  { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px; }

/* ── Filter strip ───────────────────────────────────────── */
.filter-pill {
  padding: 5px 14px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #e2e8f0;
  background: white;
  color: #475569;
  transition: all 0.12s;
}
.filter-pill:hover { border-color: #a5b4fc; color: #4338ca; }
.filter-pill.active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: white;
}

/* ── Search input ───────────────────────────────────────── */
.search-input {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 12px 8px 36px;
  font-size: 0.875rem;
  color: #1e293b;
  background: white;
  width: 100%;
  max-width: 320px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.search-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }

/* ── Select dropdown ────────────────────────────────────── */
.filter-select {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 32px 7px 10px;
  font-size: 0.8rem;
  color: #334155;
  background: white;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s;
}
.filter-select:focus { border-color: #6366f1; }
/* The same box on a text field: no dropdown arrow to promise a menu that is
   not there, and a text cursor rather than a pointer. */
input.filter-select,
textarea.filter-select {
  background-image: none;
  padding-right: 10px;
  cursor: text;
}
textarea.filter-select { line-height: 1.45; }
.filter-select--dark {
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23cbd5e1' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  color: #e2e8f0; /* slate-200 — overrides the dark color from .filter-select base */
}

/* ── Button ─────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: #4f46e5;
  color: white;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.12s;
}
.btn-primary:hover { background: #4338ca; }
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: white;
  color: #334155;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #e2e8f0;
  transition: all 0.12s;
}
.btn-secondary:hover { border-color: #a5b4fc; color: #4338ca; }
.btn-primary:disabled,
.btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary:disabled:hover,
.btn-secondary:disabled:hover { border-color: #e2e8f0; color: inherit; }

/* ── Empty state ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #94a3b8;
  text-align: center;
  gap: 12px;
}
.empty-state svg { opacity: 0.4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: #64748b; margin: 0; }
.empty-state p  { font-size: 0.85rem; margin: 0; max-width: 280px; line-height: 1.5; }

/* ── Not initialized banner ─────────────────────────────── */
.init-banner {
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: #92400e;
  margin-bottom: 20px;
}

/* ── Horizontally scrollable tab row (every width) ──────────
   The scrollbar stays hidden; the ‹ › buttons and edge fades in the nav are
   the affordance. scroll-padding keeps a revealed tab clear of those
   44px-wide buttons (plus a margin). */
.tab-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-padding-inline: 52px; /* 44px buttons + safety margin */
}
.tab-scroll::-webkit-scrollbar { display: none; }
.tab-scroll .tab-list { min-width: max-content; }

@media (max-width: 640px) {
  .data-table-wrap { overflow-x: auto; }
}

/* ── Chip ───────────────────────────────────────────────── */
.chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  margin: 1px;
  white-space: nowrap;
}
.chip-indigo { background: #e0e7ff; color: #4338ca; }
.chip-green  { background: #dcfce7; color: #15803d; }
.chip-amber  { background: #fef3c7; color: #b45309; }
.chip-slate  { background: #f1f5f9; color: #475569; }
.chip-red    { background: #fee2e2; color: #b91c1c; }

/* ── Spinner ────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Coverage summary bar ───────────────────────────────── */
.cov-stat {
  text-align: center;
  padding: 16px 12px;
}
.cov-stat .value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.cov-stat .label { font-size: 0.72rem; color: #64748b; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Accessibility: respect prefers-reduced-motion ──────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* Keep skeleton visible (no pulsing) but still show it */
  .skeleton {
    animation: none;
    opacity: 0.7;
  }
}

/* ── Toggle switch ──────────────────────────────────────── */
.toggle-group {
  display: inline-flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.toggle-btn {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: #64748b;
  transition: all 0.15s;
}
.toggle-btn.active {
  background: white;
  color: #1e293b;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ── Non-sortable table headers (global panel) ─────────────── */
#panel-global .data-table th {
  cursor: default;
}
#panel-global .data-table th:hover {
  background: #f8fafc;
  color: #64748b;
}

/* ── Brief content — Markdown prose ────────────────────────── */
.brief-content p { margin-bottom: 0.75rem; color: #475569; line-height: 1.6; }
.brief-content h1,
.brief-content h2,
.brief-content h3 { font-weight: 600; color: #1e293b; margin-top: 1rem; margin-bottom: 0.5rem; }
.brief-content h1 { font-size: 1.125rem; }
.brief-content h2 { font-size: 1rem; }
.brief-content h3 { font-size: 0.9rem; }
.brief-content ul,
.brief-content ol { margin-left: 1.25rem; margin-bottom: 0.75rem; color: #475569; }
.brief-content ul { list-style-type: disc; }
.brief-content ol { list-style-type: decimal; }
.brief-content li { margin-bottom: 0.25rem; }
.brief-content code { font-family: monospace; font-size: 0.85em; background: #f1f5f9; color: #0f172a; padding: 0.1em 0.35em; border-radius: 3px; }
.brief-content pre { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 0.75rem 1rem; overflow-x: auto; margin-bottom: 0.75rem; }
.brief-content pre code { background: none; padding: 0; font-size: 0.85rem; }
.brief-content a { color: #4f46e5; text-decoration: underline; }
.brief-content strong { font-weight: 600; color: #1e293b; }
.brief-content em { font-style: italic; }
.brief-content > p:last-child,
.brief-content > ul:last-child,
.brief-content > ol:last-child { margin-bottom: 0; }

/* ── Brief expand/collapse ─────────────────────────────── */
.brief-collapse {
  max-height: 7.5rem;   /* ≈ 5 lines at 1.5rem line-height */
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.brief-collapse.brief-expanded {
  max-height: 2000px;   /* large enough; animates via max-height trick */
}

/* ── Execution action buttons (Scenarios tab) ───────────── */
.exec-btn {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 0.375rem;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.exec-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.exec-btn:not(:disabled):hover  { opacity: 0.85; }
.exec-btn:not(:disabled):active { transform: scale(0.97); }
.exec-btn-pass    { background: #dcfce7; color: #15803d; }
.exec-btn-fail    { background: #fee2e2; color: #b91c1c; }
.exec-btn-pending { background: #fef3c7; color: #b45309; }

/* ── Scenario gherkin viewer ───────────────────────────── */
.scenario-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.125rem 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
}
.scenario-row:hover { color: #4338ca; }
.scenario-chevron {
  margin-left: auto;
  color: #94a3b8;
  transition: transform 0.15s ease;
}
.scenario-chevron.open { transform: rotate(90deg); }
.gherkin-block {
  margin: 0;
  padding: 0.75rem 0.875rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre;
  overflow-x: auto;
  max-height: 22rem;
  overflow-y: auto;
}
.gherkin-block code { background: none; padding: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ── ADR reader ────────────────────────────────────────────────────────────
   Reuses .brief-content for prose; this adds the bits a full decision record
   needs — headings that breathe, tables, and centred mermaid figures. */
.adr-content h1 { font-size: 1.35rem; font-weight: 600; margin: 0 0 .75rem; }
.adr-content h2 { font-size: 1.1rem;  font-weight: 600; margin: 1.5rem 0 .5rem; padding-bottom: .25rem; border-bottom: 1px solid #e2e8f0; }
.adr-content h3 { font-size: .95rem;  font-weight: 600; margin: 1.15rem 0 .4rem; }
.adr-content blockquote { margin: .75rem 0; padding: .25rem 0 .25rem .9rem; border-left: 3px solid #e2e8f0; color: #64748b; }
.adr-content table { width: 100%; border-collapse: collapse; margin: .9rem 0; font-size: .875rem; }
.adr-content th, .adr-content td { border: 1px solid #e2e8f0; padding: .4rem .6rem; text-align: left; }
.adr-content th { background: #f8fafc; font-weight: 600; }
.adr-content hr { border: 0; border-top: 1px solid #e2e8f0; margin: 1.5rem 0; }
.adr-content pre.mermaid {
  display: flex;
  justify-content: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: .75rem;
  padding: 1rem;
  margin: 1rem 0;
  overflow-x: auto;
  /* Pre-render the fence is plain text; keep it readable if mermaid never loads. */
  white-space: pre-wrap;
  font-size: .8rem;
  color: #64748b;
}
.adr-content pre.mermaid[data-processed] {
  white-space: normal;
  color: inherit;
}
.adr-content pre.mermaid svg { max-width: 100%; height: auto; }

/* ── Traceability chain (Requirements → Stories → Scenarios → result) ── */
.trace-graph {
  position: relative;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(300px, 1.6fr);
  gap: 56px;
  padding: 16px;
  align-items: start;
}
.trace-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.trace-col-header {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  padding: 6px 4px;
  border-bottom: 1px solid #e2e8f0;
}
.trace-col-header .count { color: #94a3b8; font-weight: 500; margin-left: 4px; }

.trace-node {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  background: white;
  border: 1px solid #e2e8f0;
  border-left-width: 3px;
  border-left-color: #94a3b8;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  font-size: 0.8rem;
  color: #334155;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.trace-node--req, .trace-node--story, .trace-node--scenario, .trace-node--more { cursor: pointer; }
.trace-node--req:hover, .trace-node--story:hover, .trace-node--scenario:hover, .trace-node--more:hover {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}
.trace-node:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; }
.trace-node--scenario { grid-template-columns: minmax(0, 1fr) auto; }
.trace-node--ok  { border-left-color: #16a34a; }
.trace-node--gap { border-left-color: #ef4444; }
.trace-node--missing {
  border: 1px dashed #f87171;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.75rem;
  padding: 6px 10px;
}
.trace-node--more {
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  color: #475569;
  font-size: 0.75rem;
  padding: 6px 10px;
}
.trace-node.is-selected { border-color: #6366f1; box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25); }

.trace-node__main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trace-node__id {
  align-self: flex-start;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: #4338ca;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.trace-node__id:hover { text-decoration: underline; }
.trace-node__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trace-node__sub {
  font-size: 0.7rem;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Result cell: a short connector then the status chip, aligned to the scenario row. */
.trace-node__result { display: flex; align-items: center; }
.trace-connector { width: 22px; height: 2px; background: #cbd5e1; }
.trace-connector--pass    { background: #16a34a; }
.trace-connector--fail    { background: #ef4444; }
.trace-connector--pending { background: #f59e0b; }
.trace-connector--never_run { background: repeating-linear-gradient(90deg, #ef4444 0 4px, transparent 4px 7px); }
.trace-chip {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.trace-chip--pass      { background: #dcfce7; color: #15803d; }
.trace-chip--fail      { background: #fee2e2; color: #b91c1c; }
.trace-chip--pending   { background: #fef3c7; color: #b45309; }
.trace-chip--never_run { background: white; color: #b91c1c; border: 1px dashed #f87171; }

.trace-edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}
.trace-edge { fill: none; stroke: #cbd5e1; stroke-width: 1.5; }
.trace-edge--gap  { stroke: #f87171; stroke-dasharray: 4 3; }
.trace-edge--warn { stroke: #f59e0b; stroke-dasharray: 4 3; }
.trace-edge--more { stroke: #cbd5e1; stroke-dasharray: 2 3; }
.trace-edge.is-lit { stroke: #6366f1; stroke-width: 2.5; }

.trace-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid #f1f5f9;
  font-size: 0.72rem;
  color: #64748b;
}
.trace-legend span { display: inline-flex; align-items: center; gap: 6px; }
.trace-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.trace-banner {
  margin: 12px 16px 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 0.78rem;
}
