/* Julia AI dashboard layout and components. Colours come from theme.css only. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--blue); }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.015em; }
p { margin: 0; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; border-radius: 6px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- buttons and inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: 12px; border: 1.5px solid transparent;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  background: var(--surface); color: var(--ink);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-deep); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-wide { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  border: 0; background: transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--soft); }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px; min-height: 42px; width: 100%;
}
textarea { min-height: 96px; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 13px; min-height: 140px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent); }
label.field { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.field-error { color: var(--danger); font-size: 13px; font-weight: 500; }

/* ---------- boot and gates ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 32px 28px; display: grid; gap: 16px; box-shadow: var(--shadow);
}
.gate-card h1 { font-size: 26px; font-weight: 800; }
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 24px; letter-spacing: -0.03em; }
.brand-lockup b { font-weight: 400; color: var(--blue); margin-inline-start: .4em; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px;
}
.sidebar-brand { padding: 4px 8px 0; font-size: 22px; }
.clinic-name { padding: 2px 10px 14px; color: var(--muted); font-size: 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink); text-decoration: none; font-weight: 500;
}
.sidebar nav a:hover { background: var(--soft); }
.sidebar nav a[aria-current="page"] { background: var(--soft); color: var(--blue); font-weight: 700; }
.sidebar nav .count { margin-inline-start: auto; background: var(--blue); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 1px 8px; }
.live-dot { margin-inline-start: auto; width: 9px; height: 9px; border-radius: 50%; background: var(--mint); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: .5; } }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 12px 28px; min-height: 64px; background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 22px; font-weight: 800; }
.topbar-end { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.menu-btn { display: none; }
.user-menu { position: relative; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--blue); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 240px; z-index: 20;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 8px;
}
.menu-email { padding: 8px 10px 0; font-weight: 600; overflow-wrap: anywhere; }
.menu-role { padding: 0 10px 8px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu button { width: 100%; text-align: start; background: none; border: 0; padding: 10px; border-radius: 8px; font: inherit; color: var(--ink); cursor: pointer; }
.menu button:hover { background: var(--soft); }

.demo-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; justify-content: space-between;
  margin: 16px 28px 0; padding: 12px 16px; border-radius: 12px; background: var(--warn-bg); color: var(--warn); font-size: 14px;
}
.view { padding: 24px 28px 64px; display: grid; gap: 20px; align-content: start; }
.view:focus { outline: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 272px; z-index: 30; transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  .shell.nav-open .sidebar { transform: none; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 10px 16px; }
  .topbar h1 { font-size: 19px; }
  .view { padding: 16px 16px 56px; }
  .demo-banner { margin: 12px 16px 0; }
}

/* ---------- cards, KPIs, tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; display: grid; gap: 14px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h2 { font-size: 18px; font-weight: 700; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 4px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: start; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: var(--surface-2); }
table.list .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.list .nowrap { white-space: nowrap; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 13px; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--soft); color: var(--ink); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--soft); color: var(--blue); }
.badge.demo { background: var(--warn-bg); color: var(--warn); font-size: 11px; letter-spacing: .05em; }

/* ---------- filters and segmented controls ---------- */
.filters { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); align-items: end; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--muted); padding: 7px 14px; border-radius: 9px; cursor: pointer; min-height: 36px; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--blue); box-shadow: 0 1px 3px rgba(15, 27, 61, .12); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; color: var(--muted); font-size: 14px; }

/* ---------- call control ---------- */
.modes { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.mode {
  text-align: start; font: inherit; color: var(--ink); background: var(--surface); border: 2px solid var(--line);
  border-radius: 16px; padding: 16px; cursor: pointer; display: grid; gap: 6px;
}
.mode strong { font-size: 16px; }
.mode span { color: var(--muted); font-size: 14px; }
.mode[aria-pressed="true"] { border-color: var(--blue); background: var(--soft); }
.status-line { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; font-size: 14px; }
.big-number { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
.live-call { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--ok-bg); color: var(--ok); }
.live-call .live-dot { margin: 0; }

/* ---------- appointments ---------- */
.cal { display: grid; gap: 12px; }
.cal-days { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.cal-day { background: var(--surface-2); border-radius: 14px; padding: 12px; display: grid; gap: 8px; align-content: start; min-height: 120px; }
.cal-day h3 { font-size: 14px; font-weight: 700; color: var(--muted); }
.cal-day.today h3 { color: var(--blue); }
.appt { background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--blue); border-radius: 10px; padding: 10px 12px; display: grid; gap: 3px; font-size: 14px; }
.appt.cancelled { border-inline-start-color: var(--danger); opacity: .75; }
.appt.rescheduled { border-inline-start-color: var(--mint); }
.appt .time { font-weight: 700; font-variant-numeric: tabular-nums; }
.provider-cols { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }

/* ---------- drawer ---------- */
.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(12, 20, 40, .45); }
.drawer-panel {
  position: absolute; inset-block: 0; inset-inline-end: 0; width: min(100%, 640px); background: var(--paper);
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.drawer-head h2 { font-size: 19px; font-weight: 800; }
.drawer-body { overflow-y: auto; padding: 20px; display: grid; gap: 16px; align-content: start; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.transcript { white-space: pre-wrap; font-size: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; max-height: 420px; overflow-y: auto; }
.transcript .who { font-weight: 700; }
pre.json { font-family: var(--mono); font-size: 12.5px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; overflow-x: auto; margin: 0; }
audio { width: 100%; }

/* ---------- settings ---------- */
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.faq { border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 10px; background: var(--surface); }
.faq-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; cursor: pointer; }
.switch input { appearance: none; width: 42px; height: 24px; min-height: 0; padding: 0; border-radius: 999px; background: var(--line); border: 0; position: relative; cursor: pointer; flex-shrink: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s ease; }
.switch input:checked { background: var(--mint-ink); }
.switch input:checked::after { inset-inline-start: 21px; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--soft); font-size: 14px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.danger { background: var(--danger-bg); color: var(--danger); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- toast ---------- */
.toast {
  position: fixed; inset-inline: 16px; bottom: max(16px, env(safe-area-inset-bottom)); margin: 0 auto; max-width: 520px; z-index: 50;
  background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 500;
}
.toast.error { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
  .sidebar { transition: none; }
}

/* ---------- guided test (first sign-in tour) ---------- */
.guide {
  position: fixed; z-index: 45; inset-inline-end: 20px; bottom: max(20px, env(safe-area-inset-bottom));
  width: min(400px, calc(100vw - 32px)); max-height: min(78vh, 680px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  padding: 18px 20px 16px; display: grid; gap: 12px; animation: guide-in .35s cubic-bezier(.2, .8, .2, 1);
}
.guide.guide-leaving { animation: guide-out .2s ease forwards; }
@keyframes guide-in { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes guide-out { to { opacity: 0; transform: translateY(12px); } }
.guide-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.guide-kicker { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--blue); }
.guide .icon-btn { width: 32px; height: 32px; }
.guide-dots { display: flex; gap: 6px; }
.guide-dots span { height: 6px; flex: 1; border-radius: 999px; background: var(--line); transition: background .3s ease; }
.guide-dots span.past { background: var(--mint); }
.guide-dots span.on { background: var(--blue); }
.guide h2 { font-size: 20px; font-weight: 800; }
.guide h2:focus { outline: none; }
.guide-body { display: grid; gap: 8px; font-size: 15px; }
.guide-muted { color: var(--muted); font-size: 14px; }
.guide-phone { font-size: 18px; white-space: nowrap; color: var(--blue); }
.guide-progress { font-weight: 700; color: var(--mint-ink); font-size: 14px; }
.guide-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.guide-list label { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; cursor: pointer; font-size: 14px; }
.guide-list input { width: 18px; height: 18px; min-height: 0; padding: 0; margin-top: 2px; accent-color: var(--mint-ink); }
.guide-list label > span { display: grid; gap: 2px; }
.guide-list input:checked + span strong { color: var(--muted); text-decoration: line-through; }
.guide-actions { display: flex; justify-content: space-between; gap: 10px; padding-top: 4px; }
.sidebar nav a.guide-target { position: relative; background: var(--soft); color: var(--blue); }
.sidebar nav a.guide-target::after {
  content: ""; position: absolute; inset: -3px; border-radius: 12px; border: 2px solid var(--mint);
  animation: guide-pulse 1.6s ease-in-out infinite; pointer-events: none;
}
@keyframes guide-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(1.03); } }
@media (max-width: 900px) {
  .guide { inset-inline: 12px; width: auto; bottom: max(12px, env(safe-area-inset-bottom)); max-height: 70vh; }
}
@media (prefers-reduced-motion: reduce) {
  .guide, .guide.guide-leaving, .sidebar nav a.guide-target::after { animation: none; }
}
