/* ============================================================
   Layra dashboard — same palette as web/assets/css/layra.css,
   duplicated rather than shared: this folder deploys separately
   (app.layra.si vs layra.si, see dashboard/README.md), so the two
   shouldn't be coupled at deploy time. If the tokens drift, that's
   an acceptable cost of that independence — keep them in sync by
   eye when you touch one.
   ============================================================ */

:root {
  --paper:     #F1F5FB;
  --card:      #FFFFFF;
  --ink:       #101725;
  --ink-soft:  #5C6779;
  --ink-faint: #8D97A8;
  --azure:     #1F6FE5;
  --indigo:    #4338CA;
  --pine:      #10786A;
  --alert:     #C8372D;
  --line:      rgba(16, 23, 37, .10);
  --line-soft: rgba(16, 23, 37, .06);

  --font-sans: "Segoe UI Variable Display", "Segoe UI", -apple-system,
               BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue",
               Arial, sans-serif;
  --shell: 1180px;
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--azure); outline-offset: 2px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ---- buttons ------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem;
  padding: .65rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 600;
  font-size: .92rem;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; pointer-events: none; }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--azure), var(--indigo));
}
.btn-primary:hover { opacity: .92; }

.btn-quiet {
  color: var(--ink);
  background: var(--card);
  border-color: var(--line);
}
.btn-quiet:hover { background: var(--line-soft); }

.btn-danger {
  color: var(--alert);
  background: #fff;
  border-color: var(--line);
}
.btn-danger:hover { background: rgba(200, 55, 45, .08); }

.btn-sm { padding: .4rem .75rem; font-size: .82rem; }

/* ---- forms ---------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.field label { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.field input, .field select {
  padding: .7rem .85rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: .95rem;
}
.field input:focus, .field select:focus { border-color: var(--azure); }
.field-hint { font-size: .78rem; color: var(--ink-faint); }

.form-error {
  display: none;
  padding: .7rem .9rem;
  border-radius: 9px;
  background: rgba(200, 55, 45, .08);
  color: var(--alert);
  font-size: .88rem;
  margin-bottom: 1rem;
}
.form-error.show { display: block; }

/* ---- auth pages (login/signup) -------------------------------- */

.auth-shell {
  min-height: 100svh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 20px 50px -25px rgba(16, 23, 37, .25);
}
.auth-wordmark {
  display: block;
  text-align: center;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: .04em;
  background: linear-gradient(135deg, var(--azure), var(--indigo));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 1.6rem;
}
.auth-card h1 { font-size: 1.25rem; font-weight: 700; margin-bottom: .3rem; }
.auth-card .sub { color: var(--ink-soft); font-size: .88rem; margin-bottom: 1.5rem; }
.auth-card .btn { width: 100%; margin-top: .25rem; }
.auth-switch { text-align: center; margin-top: 1.4rem; font-size: .88rem; color: var(--ink-soft); }
.auth-switch a { color: var(--azure); font-weight: 600; }

/* ---- app shell -------------------------------------------------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  height: 4rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar__brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; letter-spacing: .03em; }
.topbar__brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: linear-gradient(135deg, var(--azure), var(--indigo));
}
.topbar__business { color: var(--ink-soft); font-size: .85rem; }
.topbar__nav { display: flex; gap: .25rem; }
.topbar__nav a {
  padding: .5rem .85rem;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.topbar__nav a:hover { background: var(--line-soft); }
.topbar__nav a.active { background: var(--line-soft); color: var(--ink); }
.topbar__actions { display: flex; align-items: center; gap: .75rem; }

main.shell {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

.page-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem; }
.page-head h1 { font-size: 1.35rem; font-weight: 800; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ---- calendar --------------------------------------------------- */

.cal-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 860px) { .cal-layout { grid-template-columns: 1fr; } }

.cal-card { padding: 1.25rem; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.cal-head h2 { font-size: 1.05rem; font-weight: 700; text-transform: capitalize; }
.cal-nav { display: flex; gap: .4rem; }
.cal-nav button {
  width: 2rem; height: 2rem;
  border-radius: 8px; border: 1px solid var(--line); background: #fff;
  cursor: pointer; font-size: 1rem;
}
.cal-nav button:hover { background: var(--line-soft); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: .72rem; font-weight: 700; color: var(--ink-faint); padding-bottom: .35rem; text-transform: uppercase; letter-spacing: .04em; }
.cal-day {
  position: relative;
  aspect-ratio: 1 / .82;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--line-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .2rem;
  cursor: pointer;
  font-size: .85rem;
  color: var(--ink);
}
.cal-day:hover { border-color: var(--line); }
.cal-day.outside { color: var(--ink-faint); background: transparent; }
.cal-day.today { border-color: var(--azure); font-weight: 700; }
.cal-day.selected { background: linear-gradient(135deg, var(--azure), var(--indigo)); color: #fff; }
.cal-day .n { font-size: .58rem; padding: 1px 6px; border-radius: 999px; background: rgba(16,23,37,.08); }
.cal-day.selected .n { background: rgba(255,255,255,.25); }

.day-panel { padding: 1.25rem; display: flex; flex-direction: column; gap: 1.1rem; }
.day-panel h3 { font-size: .95rem; font-weight: 700; text-transform: capitalize; }
.appt-list { display: flex; flex-direction: column; gap: .5rem; max-height: 260px; overflow-y: auto; }
.appt-row {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: .85rem;
}
.appt-row .time { font-weight: 700; color: var(--azure); min-width: 3.4rem; }
.appt-row .who { flex: 1; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-row button { background: none; border: none; color: var(--ink-faint); cursor: pointer; font-size: .8rem; }
.appt-row button:hover { color: var(--alert); }
.empty-note { color: var(--ink-faint); font-size: .85rem; padding: .5rem 0; }

.slot-grid { display: flex; flex-wrap: wrap; gap: .4rem; }
.slot-chip {
  padding: .35rem .6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .78rem;
  background: #fff;
  cursor: pointer;
}
.slot-chip:hover { border-color: var(--azure); color: var(--azure); }

/* ---- call log table -------------------------------------------- */

.calls-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.calls-table th {
  text-align: left; padding: .7rem 1rem;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
}
.calls-table td { padding: .8rem 1rem; border-bottom: 1px solid var(--line-soft); }
.calls-table tbody tr { cursor: pointer; }
.calls-table tbody tr:hover { background: var(--line-soft); }
.calls-table .muted { color: var(--ink-faint); }

.load-more { display: block; margin: 1rem auto 0; }

/* ---- modal -------------------------------------------------------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(16, 23, 37, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  width: 100%; max-width: 560px; max-height: 85vh;
  background: var(--card);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; padding: 1.25rem 1.4rem; border-bottom: 1px solid var(--line); }
.modal__head h2 { font-size: 1.05rem; font-weight: 700; }
.modal__meta { color: var(--ink-soft); font-size: .82rem; margin-top: .2rem; }
.modal__close { background: none; border: none; font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--ink-faint); padding: .2rem .4rem; }
.modal__close:hover { color: var(--ink); }
.modal__body { padding: 1.1rem 1.4rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }
.modal__audio { width: 100%; }
.modal__foot { padding: .9rem 1.4rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }

.turns { display: flex; flex-direction: column; gap: .6rem; }
.turn { max-width: 80%; padding: .6rem .85rem; border-radius: 12px; font-size: .88rem; line-height: 1.4; }
.turn .speaker { display: block; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .65; margin-bottom: .15rem; }
.turn.caller { align-self: flex-start; background: var(--line-soft); border-bottom-left-radius: 3px; }
.turn.agent { align-self: flex-end; background: linear-gradient(135deg, rgba(31,111,229,.12), rgba(67,56,202,.12)); border-bottom-right-radius: 3px; }

/* ---- misc --------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  background: var(--line-soft); color: var(--ink-soft);
}
.badge-soon { background: rgba(200, 55, 45, .08); color: var(--alert); }

/* ---- Phase 1b: Google connection state ---------------------------
   Three colours, one meaning each, used identically on the settings badge
   and on every appointment row: green = Layra is booking, amber = it is
   only taking messages, red = something is broken and she should look. */
.badge-ok    { background: rgba(16, 120, 106, .10); color: var(--pine); }
.badge-warn  { background: rgba(180, 120, 10, .12); color: #8A5D00; }
.badge-fault { background: rgba(200, 55, 45, .10);  color: var(--alert); }

/* The state that protects her, so it is loud rather than tasteful. */
.alert-box {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  border: 1px solid rgba(200, 55, 45, .35);
  background: rgba(200, 55, 45, .07);
  color: var(--alert);
  border-radius: 9px;
  padding: .8rem 1rem;
  font-size: .87rem; line-height: 1.45;
  margin-bottom: .75rem;
}
.alert-box .btn { color: var(--alert); border-color: rgba(200, 55, 45, .35); }

.warn-box {
  border: 1px solid rgba(180, 120, 10, .3);
  background: rgba(180, 120, 10, .07);
  color: #8A5D00;
  border-radius: 9px;
  padding: .7rem .9rem;
  font-size: .85rem; line-height: 1.45;
  margin-bottom: .9rem;
}

/* Her diary, not ours: greyed, and with nothing to click. */
.appt-row.busy { background: var(--line-soft); border-style: dashed; }
.appt-row.busy .time, .appt-row.busy .who { color: var(--ink-faint); font-weight: 500; }

.kv { display: grid; gap: .5rem; font-size: .85rem; }
.kv > div { display: flex; justify-content: space-between; gap: 1rem; }
.kv span { color: var(--ink-faint); }
.kv b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.check { display: flex; align-items: flex-start; gap: .55rem; font-size: .87rem; margin: .35rem 0; cursor: pointer; }
.check input { margin-top: .2rem; flex: none; }

.steps { margin: 0; padding-left: 1.2rem; font-size: .87rem; line-height: 1.6; color: var(--ink-soft); }
.steps li { margin-bottom: .6rem; }
.steps code, .copy-row code {
  background: var(--line-soft); border-radius: 5px; padding: .1rem .35rem;
  font-size: .82em; word-break: break-all;
}

.copy-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .35rem; }

.sa-details { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .9rem; }
.sa-details summary { cursor: pointer; font-size: .85rem; color: var(--ink-soft); margin-bottom: .8rem; }

.hours-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; font-size: .87rem; }
.hours-row .hours-open { flex: 1; margin: 0; }
.hours-row input[type="time"] { width: 7.5rem; }
.hours-row input:disabled { opacity: .45; }

.muted { color: var(--ink-faint); }

.loading, .empty-state { text-align: center; color: var(--ink-faint); padding: 2.5rem 1rem; font-size: .9rem; }

.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: .7rem 1.1rem; border-radius: 9px;
  font-size: .85rem;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.toast.show { opacity: 1; }
