/* Light, clean dashboard look in the office logo's purples (#450864 and #cda6c5). */
:root {
  --bg: #f6f2f8;
  --surface: #ffffff;
  --text: #2a1934;
  --muted: #76668a;
  --border: #ebe2ef;
  --accent: #5e1a80;
  --accent-dark: #450864;
  --accent-text: #ffffff;
  --selected: #f3e9f5;
  --logo-dark: #450864;
  --logo-light: #cda6c5;
  --ok: #15944a;
  --warn: #c26a00;
  --error: #d92d20;
  --shadow: 0 2px 12px rgba(69, 8, 100, .07);
  /* Schedule: light purple = note not added yet, dark purple = note completed */
  --apt-due: #efe0ed;
  --apt-due-border: #cda6c5;
  --apt-noted: #450864;
  --apt-noted-text: #ffffff;
  --apt-broken: #f1edf3;
  color-scheme: light;
  accent-color: var(--accent); /* tick boxes and date picker */
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.3rem; margin: 0; font-weight: 700; }
h2 { font-size: 1rem; margin: 0 0 .7rem; display: flex; align-items: center; gap: .5rem; font-weight: 650; }
[hidden] { display: none !important; }

/* ---------- App frame: left menu + main area ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1.2rem;
  padding: 1.2rem .9rem; background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; padding: 0 .4rem; }
.brand .logo { max-width: 100%; max-height: 72px; object-fit: contain; }
.brand-name { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.logo:not([hidden]) + .brand-name { display: none; } /* the logo already shows the office name */
.brand-app { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tabs { display: flex; flex-direction: column; gap: .3rem; }
.tabs a {
  display: flex; align-items: center; gap: .7rem; padding: .65rem .8rem; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 600;
}
.tabs a:hover { background: var(--selected); color: var(--accent); }
.tabs a.active { background: var(--accent); color: var(--accent-text); box-shadow: 0 4px 12px rgba(69, 8, 100, .28); }
.tabs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; padding: 0 .4rem; }

.main { min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1.1rem 1.5rem .3rem;
}

@media (max-width: 1000px) { .app { grid-template-columns: 180px 1fr; } }
/* Narrow screens (iPad held upright is fine; phones): the menu becomes a bar across the top. */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: .7rem 1rem; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { flex-direction: row; align-items: center; }
  .brand .logo { max-height: 40px; max-width: 140px; }
  .tabs { flex-direction: row; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
}

.pill { font-size: .8rem; padding: .25rem .7rem; border-radius: 999px; font-weight: 600; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.pill.ok { color: var(--ok); background: #e8f7ee; border-color: #bfe8cf; }
.pill.warn { color: var(--warn); background: #fff4e5; border-color: #f7d9a8; }
.pill.error { color: var(--error); background: #fdecea; border-color: #f6c3be; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem; box-shadow: var(--shadow); }
.step {
  display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--selected); color: var(--accent); font-size: .78rem; font-weight: 700;
}

.row { display: flex; gap: .5rem; align-items: center; }
.row.between { justify-content: space-between; flex-wrap: wrap; }
.inline { display: flex; gap: .4rem; align-items: center; font-size: .85rem; color: var(--muted); margin-bottom: .4rem; }
.muted { color: var(--muted); font-size: .85rem; }

input[type=search], input[type=text], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: .55rem .7rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; margin-bottom: .6rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
  font: inherit; font-weight: 600; padding: .5rem 1rem; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent); white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
button.ghost { background: var(--surface); color: var(--accent); border-color: var(--border); }
button.ghost:hover:not(:disabled) { background: var(--selected); border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Notes screen ---------- */
.layout { display: grid; grid-template-columns: 340px 1fr; gap: 1.1rem; padding: 1rem 1.5rem 1.5rem; max-width: 1400px; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } }
.sidebar, .workspace { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }

.list { list-style: none; margin: .6rem 0 0; padding: 0; max-height: 260px; overflow-y: auto; }
.list li { padding: .5rem .6rem; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.list li:hover { background: var(--bg); }
.list li.selected { background: var(--selected); border-color: var(--accent); }
.list li.muted { cursor: default; }
.list li small { display: block; color: var(--muted); }
.list label { display: flex; gap: .5rem; cursor: pointer; }

.prompts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem; }
.prompt label.title { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .25rem; }
.prompt.missing label.title::after { content: " • needed"; color: var(--warn); font-weight: 400; }
.prompt .options { display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; }
.prompt .options label { display: flex; gap: .4rem; align-items: center; }

#message { margin: .6rem 0 0; min-height: 1.2em; }
#message.ok { color: var(--ok); }
#message.error { color: var(--error); }

/* ---------- Sign-in page ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: .5rem; padding: 1.6rem; }
.login-card .logo { max-width: 260px; max-height: 90px; object-fit: contain; align-self: center; margin-bottom: .4rem; }
.login-card h1 { margin-bottom: 0; }
.login-card label { font-weight: 600; font-size: .85rem; margin-top: .4rem; }
.login-card button { margin-top: .8rem; }
.error { color: var(--error); min-height: 1.2em; margin: 0; }

/* ---------- Schedule: a time grid with one column per chair (operatory). 1 minute = 1.6px. ---------- */
.schedule { padding: 1rem 1.5rem 1.5rem; }
.schedule input[type=date] { width: auto; padding: .45rem .6rem; }
#day-title { margin: 0; font-size: 1.05rem; }
.sched-scroll { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--border); border-radius: 10px; margin-top: .6rem; }
.sched { display: grid; position: relative; min-width: min-content; }
.sched-head { position: sticky; top: 0; z-index: 3; background: #faf6fb; border-bottom: 1px solid var(--border);
  padding: .6rem .5rem; font-weight: 700; font-size: .85rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-head.corner { left: 0; z-index: 4; }
.sched-times { position: sticky; left: 0; z-index: 2; background: var(--surface); border-right: 1px solid var(--border); }
.sched-times span { position: absolute; right: .45rem; transform: translateY(-50%); font-size: .75rem; color: var(--muted); }
.sched-col { position: relative; border-right: 1px solid var(--border);
  background-image: linear-gradient(var(--border) 1px, transparent 1px); background-size: 100% 96px; }

.appt {
  position: absolute; left: 4px; right: 4px; padding: .3rem .5rem; border-radius: 8px; overflow: hidden; cursor: pointer;
  background: var(--apt-due); color: var(--text); border: 1px solid var(--apt-due-border); border-left: 5px solid var(--logo-light);
  font-size: .8rem; line-height: 1.3; text-align: left; font-weight: 400;
}
.appt:hover:not(:disabled) { background: #e6cfe2; border-color: var(--logo-light); }
.appt:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; z-index: 1; }
.appt b { display: block; font-size: .88rem; }
.appt small { display: block; color: var(--muted); }
.appt .tag { display: block; width: fit-content; margin: .2rem 0; padding: 0 .45rem; border-radius: 999px; font-size: .72rem; font-weight: 700;
  background: var(--surface); border: 1px solid var(--apt-due-border); color: var(--muted); }

/* Note completed: dark logo purple */
.appt.noted { background: var(--apt-noted); color: var(--apt-noted-text); border-color: var(--apt-noted); border-left-color: var(--logo-light);
  box-shadow: 0 3px 8px rgba(69, 8, 100, .3); }
.appt.noted:hover:not(:disabled) { background: #5a1580; border-color: #5a1580; }
.appt.noted small { color: inherit; opacity: .85; }
.appt.noted .tag { background: rgba(255, 255, 255, .18); border-color: transparent; color: inherit; }

/* Broken appointments: grey and striped, whatever their note state */
.appt.broken, .appt.broken.noted {
  background: repeating-linear-gradient(135deg, var(--apt-broken) 0 8px, var(--surface) 8px 16px);
  color: var(--muted); border-color: var(--border); box-shadow: none; text-decoration: line-through;
}
.appt.broken .tag { background: #fdecea; color: var(--error); text-decoration: none; }

.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--error); z-index: 2; pointer-events: none; }
.sched-times + .sched-col .now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--error); }

.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .82rem; font-weight: 600; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.legend i.due { background: var(--apt-due); border: 1px solid var(--apt-due-border); }
.legend i.noted { background: var(--apt-noted); }
.sched-empty { padding: 2rem; text-align: center; }

/* Sign button: the note is signed as whoever is logged in */
.sign { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: .2rem 0 .8rem; padding: .7rem .8rem;
  border: 1px solid var(--border); border-radius: 10px; background: #fdfbfd; }
.sign.signed { background: var(--selected); border-color: var(--logo-light); }
.sign.signed #sign-status { color: var(--accent-dark); font-weight: 700; font-size: .9rem; }

/* Template setup */
.setup { padding: 1rem 1.5rem 1.5rem; max-width: 900px; }
.rules-head, .rule { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: .6rem; align-items: center; }
.rules-head { margin-top: .8rem; font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.rule { margin-top: .5rem; }
.rules-actions { margin-top: 1rem; }
#setup-message { margin: .8rem 0 0; min-height: 1.2em; }
#setup-message.ok { color: var(--ok); }
.auto-note { margin: -.3rem 0 .7rem; font-size: .82rem; font-weight: 600; color: var(--accent); }
@media (max-width: 760px) { .rule, .rules-head { grid-template-columns: 1fr; } .rules-head { display: none; } }

/* Dictation */
.with-mic { display: flex; gap: .4rem; }
.mic { padding: .45rem .7rem; }
.mic.on { background: var(--error); border-color: var(--error); color: #fff; }
