/* Dashboard (index.html) — state-derived W2 surface.
   Only page-specific styles live here. Shared primitives stay in style.css. */

/* ===== Copy button — shared but premiered on dashboard. ===== */
copy-button { display: inline-flex; }
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-8);
  padding: var(--s-4) var(--s-12);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  transition: var(--motion);
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--hover-bg); }
.copy-btn.copy-btn-done  { color: #16a34a; border-color: #16a34a; background: rgba(22, 163, 74, 0.08); }
.copy-btn.copy-btn-failed { color: #dc2626; border-color: #dc2626; background: rgba(220, 38, 38, 0.08); }

/* ===== Trial banner — Free plan only. ===== */
.trial-banner {
  display: flex;
  align-items: center;
  gap: var(--s-16);
  padding: var(--s-12) var(--s-24);
  border-radius: var(--radius);
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-shadow);
}
.trial-banner-icon { font-size: 20px; flex-shrink: 0; }
.trial-banner-body { flex: 1; font-size: 14px; }
.trial-banner-body strong { font-weight: 700; }
.trial-banner .btn { color: #fff; border-color: rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.1); }
.trial-banner .btn:hover { background: rgba(255, 255, 255, 0.2); border-color: #fff; }
.trial-banner-dismiss {
  background: transparent; color: rgba(255, 255, 255, 0.8);
  padding: var(--s-4) var(--s-8); border-radius: 6px; transition: var(--motion);
}
.trial-banner-dismiss:hover { color: #fff; background: rgba(255, 255, 255, 0.15); }

/* ===== State cards — primary panel for State 1 + State 2. =====
   Both use a large hero-style card with a 48×48 gradient icon badge and
   more generous vertical rhythm than a standard .card. */
.state-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-32);
  box-shadow: 0 4px 16px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--s-24);
}
.state-head { display: flex; align-items: flex-start; gap: var(--s-16); }
.state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: var(--accent-gradient);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 4px 12px var(--accent-shadow);
}
.state-head-body { flex: 1; }
.state-headline {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-strong);
}
.state-sub { margin: var(--s-4) 0 0; color: var(--muted); font-size: 15px; }

/* ===== State 1 — Connect your warehouse ===== */
.connect-paste { display: flex; flex-direction: column; gap: var(--s-8); }
.connect-paste-hint {
  font-size: 13px;
  color: var(--muted);
}
.connect-detected {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s-16);
  display: flex;
  flex-direction: column;
  gap: var(--s-8);
}
.connect-detected-head {
  display: flex;
  align-items: center;
  gap: var(--s-8);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
}
.connect-detected-head i { color: #16a34a; }
.connect-detected-row {
  display: flex;
  gap: var(--s-8);
  font-size: 13px;
}
.connect-detected-key { color: var(--muted); min-width: 140px; }
.connect-detected-val { color: var(--text-strong); font-family: "SF Mono", Menlo, Consolas, monospace; word-break: break-all; }
.connect-error {
  padding: var(--s-12) var(--s-16);
  border-radius: var(--radius);
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
  font-size: 13px;
}
.connect-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-8);
}
.connect-help {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.connect-help summary {
  cursor: pointer;
  padding: var(--s-12) var(--s-16);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--s-8);
}
.connect-help summary::-webkit-details-marker { display: none; }
.connect-help summary:hover { color: var(--accent); }
.connect-help summary i { transition: transform var(--motion); }
.connect-help[open] summary i { transform: rotate(90deg); }
.connect-help-body {
  padding: 0 var(--s-16) var(--s-16);
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}
.connect-help-body ul { margin: var(--s-8) 0; padding-left: var(--s-24); }
.connect-help-body li + li { margin-top: var(--s-4); }

/* ===== State 2 — Wire up a client ===== */
.wire-fqdn {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  padding: var(--s-16) var(--s-24);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.wire-fqdn-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.wire-fqdn-value {
  flex: 1;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 16px;
  color: var(--text-strong);
  word-break: break-all;
}
.wire-templates { display: flex; flex-direction: column; gap: var(--s-12); }
.wire-template {
  display: flex;
  flex-direction: column;
  gap: var(--s-8);
  padding: var(--s-16);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.wire-template-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-8);
}
.wire-template-title { font-size: 13px; font-weight: 600; color: var(--text-strong); }
.wire-template pre {
  margin: 0;
  padding: var(--s-12);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
}
.wire-waiting {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  padding: var(--s-12) var(--s-16);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--hover-bg);
  color: var(--text);
  font-size: 14px;
}
.wire-waiting-dot {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--accent);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { transform: scale(0.8); opacity: 0.4; }
  50%      { transform: scale(1.2); opacity: 1; }
}
.wire-change-adapter {
  align-self: flex-start;
}

/* ===== Value band (cache effectiveness + response time) =====
   Two-tile row that replaces v1's KPI grid + activity charts in steady state.
   Also rendered in demo mode below the wire-up panel — calculator stays
   interactive, result halves render greyed with a Connect-warehouse CTA.
   AIR-680 spec: new-workflow/docs/specs/2026-05-03-cost-savings-placement.md */

.value-band {
  display: grid;
  grid-template-columns: 3fr 2fr;  /* effectiveness gets a touch more room — it carries the prose */
  gap: var(--s-16);
}
.band-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-24);
  box-shadow: 0 2px 8px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--s-12);
  transition: var(--motion);
}
.band-tile-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.band-tile-demo {
  /* Greyed treatment for the data-driven halves (effectiveness headline +
     response-time numbers/bars). Calculator inside the effectiveness tile
     stays full-contrast — it's interactive even in demo mode. */
  background: var(--bg);
  border-style: dashed;
  border-color: var(--border-strong);
}
.band-tile-empty {
  color: var(--muted);
}
.band-empty-text {
  display: block;
  color: var(--muted);
  font-size: 13px;
}
.band-divider {
  margin: var(--s-8) 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* --- Effectiveness tile (left) --- */
.effectiveness-tile { gap: var(--s-12); }
.effectiveness-headline {
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.effectiveness-sub {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}
.effectiveness-prose {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}
.effectiveness-prose strong {
  color: var(--text-strong);
  font-weight: 700;
}
.effectiveness-caveat {
  margin: 0;
  font-size: 12px;
  font-style: italic;
  color: var(--muted);
  line-height: 1.5;
}
.effectiveness-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

/* Inline calculator input — styled to read inside the prose, not as a form. */
.calc-input {
  display: inline-block;
  width: 8.5ch;            /* fits "$99,999" cleanly; larger values horizontal-scroll inside the input */
  min-width: 5ch;
  padding: 2px var(--s-8);
  font: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  background: var(--hover-bg);
  border: 1px solid var(--accent);
  border-radius: 6px;
  text-align: right;
  transition: var(--motion);
}
.calc-input:focus {
  outline: none;
  background: var(--card-bg);
  box-shadow: 0 0 0 3px var(--accent-shadow);
}
.calc-input.calc-input-error {
  border-color: #dc2626;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
}
.projection-line strong {
  color: var(--text-strong);
  font-weight: 700;
}

/* --- Response-time tile (right) --- */
.response-time-tile { gap: var(--s-12); }
.rt-row {
  display: grid;
  grid-template-columns: 80px 1fr 90px;
  align-items: center;
  gap: var(--s-12);
  font-size: 13px;
}
.rt-row-label {
  color: var(--muted);
  font-weight: 600;
}
.rt-row-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--code-bg);
  overflow: hidden;
}
.rt-row-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width var(--motion);
}
.rt-row-bar-fill-cached   { background: var(--accent-gradient); }
.rt-row-bar-fill-uncached { background: var(--muted); opacity: 0.5; }
.band-tile-demo .rt-row-bar-fill {
  background: var(--code-bg);
  border: 1px dashed var(--border-strong);
}
.rt-row-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text-strong);
}
.band-tile-demo .rt-row-value { color: var(--muted); }
.rt-improvement {
  margin-top: var(--s-4);
  font-size: 14px;
  color: var(--text);
}
.rt-improvement strong {
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
}

/* ===== State 3 — Steady state: KPI tiles + chart cards ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-16);
}
.kpi-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s-16) var(--s-24);
  box-shadow: 0 2px 8px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  transition: var(--motion);
}
.kpi-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 20px var(--shadow-strong); }
.kpi-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.kpi-value-accent { color: var(--accent); }
.kpi-trend { font-size: 12px; color: var(--muted); }

.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--s-16);
}
.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-24);
  box-shadow: 0 2px 8px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--s-12);
}
.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
}
.chart-sub { font-size: 12px; color: var(--muted); }
.chart-canvas { position: relative; height: 240px; }

/* ===== Secondary tiles row ===== */
.secondary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-16);
}
.secondary-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-24);
  box-shadow: 0 2px 8px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--s-12);
  transition: var(--motion);
}
.secondary-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-8);
}
.secondary-title { font-size: 14px; font-weight: 600; color: var(--text-strong); }
.secondary-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.secondary-link:hover { color: var(--accent-hover); }
.secondary-link i { margin-left: var(--s-4); font-size: 11px; }

.rule-row, .opp-row {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  padding: var(--s-8) 0;
  font-size: 13px;
}
.rule-row + .rule-row, .opp-row + .opp-row { border-top: 1px solid var(--border); }
.rule-row-name, .opp-row-sql {
  flex: 1;
  color: var(--text-strong);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.opp-row-sql { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12px; color: var(--text); font-weight: normal; }
.rule-row-stat {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12px;
}
.rule-row-hit { color: var(--accent); font-weight: 700; font-size: 13px; min-width: 48px; text-align: right; }
.opp-row-action { flex-shrink: 0; }

.tile-teased {
  opacity: 0.7;
}
.tile-teased-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-8);
  background: var(--hover-bg);
  color: var(--accent);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ===== Inline error banner (when tenant config / summaries outright fail). ===== */
.dash-error {
  padding: var(--s-12) var(--s-16);
  border-radius: var(--radius);
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: var(--s-12);
}

/* ===== Skeleton placeholder while primary panel loads. ===== */
.dash-skeleton {
  height: 220px;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, var(--code-bg) 0%, var(--bg) 50%, var(--code-bg) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s linear infinite;
}
@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
  .value-band { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .secondary-grid { grid-template-columns: 1fr; }
  .state-card { padding: var(--s-24); }
  .state-headline { font-size: 18px; }
  .wire-fqdn { flex-direction: column; align-items: flex-start; }
  .trial-banner { flex-wrap: wrap; }
  .effectiveness-headline { font-size: 44px; }
}
