/* Call Assistant AI — web dashboard.
 *
 * Palette variables are copied from ../renderer/styles.css rather than shared:
 * the overlay is a transparent, borderless window and this is an opaque page,
 * so they need different surfaces from the same hues. Keep the six --dash-*
 * colours below in step with the overlay's :root block.
 *
 * Two families of class live here and they are not the same thing:
 *   .dash-*  our own markup, prefixed because .panel/.sheet/.badge/.screen-*
 *            are all taken elsewhere in this repo and a collision has already
 *            cost us one real bug.
 *   .ui-*    the shared components in ../renderer/ui/, which ship unstyled.
 *            This is currently the only stylesheet that dresses them; when the
 *            overlay grows its own, both should move to one shared file.
 */

:root {
  --dash-bg: #1b1b1e;
  --dash-surface: #232326;
  --dash-surface-2: #2b2b2e;
  --dash-line: rgba(255, 255, 255, 0.09);
  --dash-fg: #f2f2f5;
  --dash-muted: #9a9aa2;
  --dash-accent: #2f6bff;
  --dash-danger: #e5484d;
  --dash-ok: #4ade80;
  --dash-radius: 12px;
  --dash-gap: 16px;
  --dash-fs: 15px;
}

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

body {
  font: var(--dash-fs) / 1.55 -apple-system, 'Segoe UI', system-ui, sans-serif;
  color: var(--dash-fg);
  background: var(--dash-bg);
  min-height: 100vh;
}

/* Visible only once focused, which is the whole point of a skip link. */
.dash-skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--dash-accent); color: #fff; padding: 10px 14px; border-radius: 0 0 8px 0;
}
.dash-skip:focus { left: 0; }

.dash-hidden, .ui-hidden { display: none !important; }

.dash-shell { max-width: 1080px; margin: 0 auto; padding: 0 20px 64px; }

/* ── chrome ────────────────────────────────────────────────────────────────── */
.dash-topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 18px 0; border-bottom: 1px solid var(--dash-line);
  position: sticky; top: 0; background: var(--dash-bg); z-index: 20;
}
.dash-brand { font-weight: 700; letter-spacing: -0.01em; }
.dash-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.dash-navlink {
  color: var(--dash-muted); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 7px 12px; border-radius: 8px;
}
.dash-navlink:hover { background: rgba(255, 255, 255, 0.06); color: var(--dash-fg); }
.dash-navlink-active { background: var(--dash-surface-2); color: var(--dash-fg); }

.dash-banner {
  margin: 16px 0 0; padding: 12px 14px; border-radius: 10px;
  background: rgba(47, 107, 255, 0.12); border: 1px solid rgba(47, 107, 255, 0.35);
  font-size: 14px;
}

.dash-main { padding-top: 24px; }
.dash-screen { display: flex; flex-direction: column; gap: var(--dash-gap); }
.dash-screen-head { display: flex; flex-direction: column; gap: 6px; }
.dash-h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.dash-h2 { font-size: 17px; font-weight: 700; }
.dash-sub { color: var(--dash-muted); font-size: 14px; }
.dash-notice { font-size: 14px; color: var(--dash-muted); }

.dash-toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  justify-content: space-between;
}
.dash-toolbar-actions { display: flex; gap: 8px; align-items: center; }

.dash-panels { display: grid; gap: var(--dash-gap); }
.dash-card {
  background: var(--dash-surface); border: 1px solid var(--dash-line);
  border-radius: var(--dash-radius); padding: 18px; display: flex;
  flex-direction: column; gap: 12px; align-items: flex-start;
}

.dash-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.dash-chip {
  font-size: 13px; color: var(--dash-muted); background: var(--dash-surface-2);
  border-radius: 999px; padding: 5px 12px;
}
.dash-loading { padding: 40px 0; text-align: center; color: var(--dash-muted); }
.dash-error-host, .dash-noresults, .dash-notbuilt { padding: 8px 0; }

.dash-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; width: 100%;
}
.dash-stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dash-muted); }
.dash-stat-value { font-size: 15px; font-weight: 600; word-break: break-word; }

.dash-list { display: grid; gap: 10px; width: 100%; }
.dash-list-item { display: grid; gap: 2px; list-style: none; }
.dash-list-term { font-size: 14px; }
.dash-list-desc { font-size: 14px; color: var(--dash-muted); }

/* ── sessions ──────────────────────────────────────────────────────────────── */
.dash-cell-title { display: flex; flex-direction: column; gap: 2px; }
.dash-cell-name { font-weight: 600; }
.dash-cell-meta { font-size: 13px; color: var(--dash-muted); }
.dash-row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ── session detail ────────────────────────────────────────────────────────── */
.dash-detail-body { min-height: 200px; }
.dash-tabbody { padding-top: 14px; }
.dash-transcript { display: grid; gap: 10px; list-style: none; }
.dash-line {
  display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: baseline;
  padding: 10px 12px; border-radius: 10px; background: var(--dash-surface);
}
.dash-line-self { background: var(--dash-surface-2); }
.dash-line-who { font-size: 13px; font-weight: 600; color: var(--dash-muted); }
.dash-line-text { white-space: pre-wrap; }
.dash-line-at { font-size: 12px; color: var(--dash-muted); font-variant-numeric: tabular-nums; }

.dash-answers { display: grid; gap: 12px; }
.dash-answer {
  background: var(--dash-surface); border: 1px solid var(--dash-line);
  border-radius: var(--dash-radius); padding: 14px 16px; display: grid; gap: 8px;
}
.dash-answer-q { font-size: 15px; font-weight: 700; }
.dash-answer-q::before { content: '💬 '; }
.dash-answer-a { white-space: pre-wrap; }
.dash-answer-foot {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  font-size: 12px; color: var(--dash-muted);
}
.dash-notes { width: 100%; }
.dash-notes-body {
  font: inherit; white-space: pre-wrap; background: var(--dash-surface);
  border: 1px solid var(--dash-line); border-radius: var(--dash-radius); padding: 16px;
}

/* ── documents ─────────────────────────────────────────────────────────────── */
.dash-dropzone {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1px dashed rgba(255, 255, 255, 0.28); border-radius: var(--dash-radius);
  padding: 18px; background: var(--dash-surface);
}
.dash-dropzone-over { border-color: var(--dash-accent); background: rgba(47, 107, 255, 0.08); }
.dash-dropzone-text { color: var(--dash-muted); font-size: 14px; }
.dash-file-input { display: none; }
.dash-upload-status { font-size: 13px; color: var(--dash-muted); flex-basis: 100%; }

.dash-doclist { display: grid; gap: 10px; }
.dash-doc {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 14px; align-items: center;
  background: var(--dash-surface); border: 1px solid var(--dash-line);
  border-radius: var(--dash-radius); padding: 14px 16px;
}
.dash-doc-title { font-size: 15px; font-weight: 600; }
.dash-doc-preview {
  font-size: 13px; color: var(--dash-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dash-doc-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.dash-doc-count { font-size: 12px; color: var(--dash-muted); }

/* ── live browser test ───────────────────────────────────────────────────── */
.dash-live-setup, .dash-live-conversation { width: 100%; }
.dash-live-field { display: grid; gap: 6px; width: 100%; }
.dash-live-label { font-size: 13px; font-weight: 700; }
.dash-live-status {
  padding: 10px 12px; border-radius: 10px; color: var(--dash-muted);
  background: var(--dash-surface-2); border: 1px solid var(--dash-line);
}
.dash-live-error {
  padding: 10px 12px; border-radius: 10px; color: #ffb4b6;
  background: rgba(229, 72, 77, 0.12); border: 1px solid rgba(229, 72, 77, 0.4);
}
.dash-live-session-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; flex-wrap: wrap;
}
.dash-live-session-id { font-size: 12px; color: var(--dash-muted); overflow-wrap: anywhere; }
.dash-live-transcript { display: grid; gap: 12px; width: 100%; list-style: none; }
.dash-live-turn {
  display: grid; gap: 8px; padding: 14px; border-radius: 10px;
  background: var(--dash-surface-2); border: 1px solid var(--dash-line);
}
.dash-live-question { font-weight: 700; }
.dash-live-question::before { content: 'Interviewer: '; color: var(--dash-muted); }
.dash-live-answer { white-space: pre-wrap; overflow-wrap: anywhere; }
.dash-live-meta { font-size: 12px; color: var(--dash-muted); }

/* ── billing ───────────────────────────────────────────────────────────────── */
.dash-balance { display: grid; gap: 6px; }
.dash-balance-headline { font-size: 24px; font-weight: 700; }
.dash-offers { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; width: 100%; }
.dash-offer {
  display: grid; gap: 6px; padding: 16px; border-radius: var(--dash-radius);
  background: var(--dash-surface-2); border: 1px solid var(--dash-line);
}
.dash-offer-title { font-size: 15px; font-weight: 700; }
.dash-offer-price { font-size: 20px; font-weight: 700; }
.dash-offer-terms { font-size: 13px; color: var(--dash-muted); }
.dash-referral { display: grid; gap: 6px; width: 100%; }
.dash-referral-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 20px;
  letter-spacing: 0.08em;
}

/* ── shared components (../renderer/ui) ────────────────────────────────────── */
.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: 600 14px/1 inherit; border: 1px solid transparent; border-radius: 9px;
  padding: 9px 14px; cursor: pointer; color: var(--dash-fg);
  background: var(--dash-surface-2);
}
.ui-btn:hover:not(:disabled) { filter: brightness(1.15); }
.ui-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ui-btn-brand { background: var(--dash-accent); color: #fff; }
.ui-btn-destructive { background: var(--dash-danger); color: #fff; }
.ui-btn-outline { background: transparent; border-color: var(--dash-line); }
.ui-btn-secondary { background: var(--dash-surface-2); }
.ui-btn-ghost { background: transparent; }
.ui-btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }
.ui-btn-link { background: none; color: var(--dash-accent); text-decoration: underline; padding: 0; }
.ui-btn-sm { padding: 6px 10px; font-size: 13px; }
.ui-btn-lg { padding: 12px 18px; font-size: 15px; }
.ui-btn-icon, .ui-btn-icon-sm { padding: 8px; }
.ui-btn-label { display: inline-block; }
.ui-spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: currentColor;
  animation: dash-spin 0.7s linear infinite;
}
@keyframes dash-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ui-spinner { animation: none; } }

.ui-icon-btn {
  background: var(--dash-surface-2); border: 1px solid var(--dash-line); color: var(--dash-fg);
  border-radius: 9px; padding: 8px 11px; cursor: pointer; font-size: 15px;
}
.ui-sort { position: relative; }

.ui-input, .ui-search-input, .ui-textarea {
  background: var(--dash-surface); border: 1px solid var(--dash-line); color: var(--dash-fg);
  border-radius: 9px; padding: 9px 12px; font: inherit; width: 100%;
}
.ui-input:focus-visible, .ui-search-input:focus-visible,
.ui-btn:focus-visible, .ui-tab:focus-visible, .ui-checkbox:focus-visible,
.dash-navlink:focus-visible, .ui-menu-item:focus-visible {
  outline: 2px solid var(--dash-accent); outline-offset: 2px;
}
.ui-search { position: relative; display: flex; align-items: center; min-width: 260px; flex: 1; }
.ui-search-icon { position: absolute; left: 11px; color: var(--dash-muted); }
.ui-search .ui-search-input { padding-left: 32px; }
.ui-search-clear {
  position: absolute; right: 8px; background: none; border: 0; color: var(--dash-muted);
  font-size: 17px; cursor: pointer; line-height: 1;
}

.ui-field { display: grid; gap: 6px; width: 100%; }
.ui-field-desc { font-size: 13px; color: var(--dash-muted); }
.ui-field-error { font-size: 13px; color: var(--dash-danger); }
.ui-label { font-size: 13px; font-weight: 600; color: var(--dash-muted); }
.ui-label-required { color: var(--dash-danger); }

.ui-badge {
  display: inline-flex; align-items: center; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: var(--dash-surface-2);
  border: 1px solid transparent; white-space: nowrap;
}
.ui-badge-default { background: rgba(47, 107, 255, 0.2); color: #b9cdff; }
.ui-badge-secondary { background: var(--dash-surface-2); color: var(--dash-muted); }
.ui-badge-destructive { background: rgba(229, 72, 77, 0.18); color: #ffb4b6; }
.ui-badge-outline { background: transparent; border-color: var(--dash-line); color: var(--dash-muted); }

.ui-checkbox {
  width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--dash-line);
  background: var(--dash-surface-2); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; padding: 0;
}
.ui-checkbox.ui-checked { background: var(--dash-accent); border-color: var(--dash-accent); }
.ui-checkbox.ui-checked .ui-checkbox-mark::before { content: '✓'; color: #fff; font-size: 13px; }
.ui-checkbox-row { display: inline-flex; align-items: center; gap: 8px; }
.ui-checkbox-label { font-size: 14px; }

.ui-switch {
  position: relative; width: 38px; height: 22px; border-radius: 999px;
  background: #4a4a50; border: 0; cursor: pointer; padding: 0;
}
.ui-switch.ui-on { background: var(--dash-accent); }
.ui-switch-thumb {
  position: absolute; top: 2px; left: 3px; width: 17px; height: 17px;
  border-radius: 50%; background: #fff; transition: transform 0.15s;
}
.ui-switch.ui-on .ui-switch-thumb { transform: translateX(15px); }

.ui-table-scroll { overflow-x: auto; width: 100%; }
.ui-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ui-caption { text-align: left; padding-bottom: 8px; font-size: 13px; color: var(--dash-muted); }
.ui-th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--dash-muted); padding: 8px 12px; border-bottom: 1px solid var(--dash-line);
  white-space: nowrap;
}
.ui-td { padding: 12px; border-bottom: 1px solid var(--dash-line); vertical-align: middle; }
.ui-align-end { text-align: right; }
.ui-tbody .ui-tr { cursor: pointer; }
.ui-tbody .ui-tr:hover { background: var(--dash-surface); }
.ui-tr-selected { background: var(--dash-surface-2); }
.ui-table-empty { color: var(--dash-muted); text-align: center; padding: 32px 12px; }

.ui-pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; padding-top: 4px;
}
.ui-pagination-status { font-size: 13px; color: var(--dash-muted); }
.ui-pagination-actions { display: flex; gap: 8px; }

.ui-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; padding: 48px 20px; color: var(--dash-muted);
}
.ui-empty-icon { font-size: 30px; }
.ui-empty-title { font-size: 16px; font-weight: 700; color: var(--dash-fg); }
.ui-empty-desc { font-size: 14px; max-width: 44ch; }
.ui-empty-error .ui-empty-icon { color: var(--dash-danger); }

.ui-list-rows { display: block; }
.ui-list-sentinel { height: 1px; }
.ui-load-more { margin: 12px auto; display: block; }

.ui-tabs { display: flex; flex-direction: column; }
.ui-tablist {
  display: flex; gap: 4px; border-bottom: 1px solid var(--dash-line); flex-wrap: wrap;
}
.ui-tab {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--dash-muted);
  font: 600 14px/1 inherit; padding: 10px 12px; cursor: pointer;
}
.ui-tab-active { color: var(--dash-fg); border-bottom-color: var(--dash-accent); }
.ui-tab-badge {
  margin-left: 6px; font-size: 11px; background: var(--dash-surface-2);
  border-radius: 999px; padding: 1px 6px;
}

.ui-dialog-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.62);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 60;
}
.ui-dialog {
  background: var(--dash-surface); border: 1px solid var(--dash-line);
  border-radius: 14px; padding: 20px; max-width: 460px; width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.ui-dialog-title { font-size: 17px; font-weight: 700; }
.ui-dialog-desc, .ui-prompt-body { font-size: 14px; color: var(--dash-muted); }
.ui-dialog-head, .ui-prompt-copy { display: grid; gap: 6px; }
.ui-dialog-foot, .ui-prompt-actions {
  display: flex; gap: 8px; justify-content: flex-end; padding-top: 16px; flex-wrap: wrap;
}
.ui-prompt { display: grid; gap: 10px; }
.ui-prompt-icon { font-size: 22px; }
.ui-dialog-close {
  background: none; border: 0; color: var(--dash-muted); cursor: pointer; font-size: 18px;
}

.ui-menu {
  position: absolute; z-index: 50; min-width: 190px; background: #141416;
  border: 1px solid var(--dash-line); border-radius: 11px; padding: 5px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.7);
}
.ui-menu-anchor { position: relative; }
.ui-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: 0; color: var(--dash-fg); font: inherit; font-size: 14px;
  padding: 8px 11px; border-radius: 7px; cursor: pointer;
}
.ui-menu-item:hover { background: rgba(255, 255, 255, 0.07); }
.ui-menu-item-danger { color: #ff6b6b; }
.ui-menu-heading { font-size: 12px; color: var(--dash-muted); padding: 6px 11px; }
.ui-menu-sep { height: 1px; background: var(--dash-line); margin: 4px 0; }
.ui-menu-hint { margin-left: auto; color: var(--dash-muted); font-size: 12px; }

.ui-separator { border: 0; height: 1px; background: var(--dash-line); }
.ui-skeleton {
  background: linear-gradient(90deg, var(--dash-surface), var(--dash-surface-2), var(--dash-surface));
  border-radius: 8px; min-height: 14px;
}
.ui-sr-only, .ui-visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

@media (max-width: 720px) {
  .dash-line { grid-template-columns: 1fr; }
  .dash-doc { grid-template-columns: auto 1fr; }
  .dash-doc-meta, .dash-doc .ui-btn { grid-column: 2; justify-self: start; }
}
