/* מספרת הפינה — the booking app.
   Hebrew, RTL, phone-first: a customer opens this from a WhatsApp message on a phone, so
   the week strip scrolls horizontally and every tap target is finger-sized. No framework —
   this repo has no build step for the browser and adding one to draw a calendar would cost
   more than it saves. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #14161a;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #b4884a;          /* barber brass */
  --accent-ink: #ffffff;
  --free: #f2f6f2;
  --free-line: #cfe0cf;
  --shut: #f4f4f5;
  --holiday: #fdf6e6;
  --holiday-line: #e8d6a8;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20,22,26,.06), 0 8px 24px rgba(20,22,26,.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216; --card: #171a20; --ink: #eceef2; --muted: #9aa1ac; --line: #262b33;
    --accent: #d7a75f; --accent-ink: #14161a;
    --free: #16211a; --free-line: #2c4433; --shut: #1a1d23;
    --holiday: #241f14; --holiday-line: #4a3d22; --danger: #f2b8b5;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 28px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 "Assistant", "Rubik", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
.skip { position: absolute; inset-inline-start: -9999px; }
.skip:focus { inset-inline-start: 8px; top: 8px; background: var(--card); padding: 8px 12px; border-radius: 8px; z-index: 20; }

/* ── header ─────────────────────────────────────────────────────────── */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px calc(14px + env(safe-area-inset-top)) 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .mark { font-size: 26px; line-height: 1; }
.brand strong { display: block; font-size: 17px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); font-size: 12.5px; }
.modes { display: flex; gap: 6px; }
.modes button {
  font: inherit; font-size: 13.5px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer;
}
.modes button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

main { max-width: 880px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.pane { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.pane-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px; }
h1, h2 { font-size: 18px; margin: 0 0 4px; letter-spacing: -.01em; }
h3 { font-size: 17px; margin: 0 0 10px; }
.note { color: var(--muted); font-size: 13.5px; margin: 2px 0 12px; }
.status { margin: 0; font-size: 14.5px; }
.status[data-kind="error"] { color: var(--danger); }

/* ── service chooser ────────────────────────────────────────────────── */
.svc { display: flex; gap: 6px; flex-wrap: wrap; }
.svc button {
  font: inherit; font-size: 13.5px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: inherit; cursor: pointer;
}
.svc button[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.svc .price { color: var(--muted); font-size: 12.5px; margin-inline-start: 6px; }

/* ── week navigation ────────────────────────────────────────────────── */
.weekbar { display: flex; align-items: center; gap: 8px; margin: 14px 0 10px; }
.weekbar .range { flex: 1; font-size: 14.5px; color: var(--muted); text-align: center; }
.nav, .today {
  font: inherit; border: 1px solid var(--line); background: transparent; color: inherit;
  border-radius: 10px; cursor: pointer; min-height: 36px; padding: 0 12px;
}
.nav { font-size: 20px; line-height: 1; width: 40px; }
.today { font-size: 13.5px; }
button:disabled { opacity: .4; cursor: default; }

/* ── the week itself ────────────────────────────────────────────────── */
.week { display: grid; gap: 10px; }
@media (min-width: 640px) { .week { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); align-items: start; } }

.day { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.day.is-shut { background: var(--shut); }
.day.is-holiday { background: var(--holiday); border-color: var(--holiday-line); }
.day.is-today { outline: 2px solid var(--accent); outline-offset: 1px; }
.day > header { padding: 9px 11px; border-bottom: 1px solid var(--line); }
.day .dow { font-weight: 700; font-size: 14.5px; }
.day .date { color: var(--muted); font-size: 12.5px; margin-inline-start: 6px; }
/* The Hebrew date sits under the civil one, small: it is what makes this an Israeli
   calendar rather than a grid with Hebrew labels, but nobody books by it. */
.day .hdate { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.day .tag { display: block; font-size: 12px; margin-top: 3px; }
.day.is-holiday .tag { color: #8a6d1f; font-weight: 600; }
@media (prefers-color-scheme: dark) { .day.is-holiday .tag { color: var(--accent); } }
.day .slots { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 11px; }
.day .empty { padding: 12px 11px; color: var(--muted); font-size: 13px; }
/* A day with nothing to offer needs a line, not a panel. On a phone the week is a vertical
   list, so five shut days at full height push today's actual free hours below the fold —
   which is the one thing the page exists to show. */
.day.is-shut > header { display: flex; align-items: baseline; gap: 6px; border-bottom: 0; padding-block: 8px; }
.day.is-shut .hdate { display: inline; margin-inline-start: 2px; }
.day.is-shut .empty { padding: 0 11px 9px; }
@media (min-width: 640px) { .day.is-shut > header { display: block; } }

.slot {
  font: inherit; font-size: 14px; font-variant-numeric: tabular-nums;
  min-height: 38px; padding: 0 11px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--free-line); background: var(--free); color: inherit;
}
.slot:hover { border-color: var(--accent); }
.slot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── appointment rows (mine / admin) ────────────────────────────────── */
.appt { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.appt:last-child { border-bottom: 0; }
.appt-main { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 10px; }
.appt .when { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.appt .name { font-weight: 600; }
.appt .tel { color: var(--muted); font-size: 14px; text-decoration: none; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.appt .via { flex-basis: 100%; color: var(--muted); font-size: 12.5px; }
.appt .cancel { font: inherit; font-size: 13px; color: var(--danger); background: none; border: 0; cursor: pointer; padding: 4px 2px; flex: none; }

.empty-state { color: var(--muted); font-size: 14.5px; padding: 8px 0; }

/* ── settings ───────────────────────────────────────────────────────── */
.set-group { margin-bottom: 18px; }
.set-group h4 { margin: 0 0 8px; font-size: 15px; }
/* A grid, not a wrapping flex row. As flex, the save button fell to its own line on every
   row and the time inputs were squeezed until their own value was clipped — seven days of
   opening hours became a column of half-legible boxes. Fixed tracks keep label, both
   fields and the button on ONE line at phone width. */
.set-row { display: grid; grid-template-columns: 68px 1fr 1fr auto; align-items: center; gap: 6px; padding: 6px 0; }
.set-row label { font-size: 13.5px; }
.set-row input { font: inherit; font-size: 14px; padding: 7px 6px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: inherit; width: 100%; min-width: 0; text-align: center; }
.set-row .via { grid-column: 2 / 4; font-size: 13px; color: var(--muted); }
.set-row .ghost, .set-row .primary { min-height: 36px; padding: 0 10px; font-size: 13.5px; }
/* Three fields plus a button do not fit beside a label at phone width. The fields keep one
   line; the button takes the next, full width, where it also reads as the commit action. */
.set-row-add { grid-template-columns: 1fr 1fr 1fr; }
.set-row-add label { grid-column: 1 / -1; }
.set-row-add .primary { grid-column: 1 / -1; margin-top: 4px; }
.primary, .ghost {
  font: inherit; font-size: 15px; min-height: 42px; padding: 0 18px; border-radius: 11px; cursor: pointer; border: 1px solid transparent;
}
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.ghost { background: transparent; border-color: var(--line); color: inherit; }

/* ── booking sheet ──────────────────────────────────────────────────── */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(420px, calc(100vw - 24px));
  background: var(--card); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10,12,16,.5); }
dialog form { padding: 18px; display: grid; gap: 12px; }
dialog label { display: grid; gap: 5px; font-size: 14px; }
dialog input { font: inherit; font-size: 16px; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); color: inherit; }
dialog small { color: var(--muted); font-size: 12.5px; }
.sheet-when { margin: 0; font-size: 15px; color: var(--muted); }
.sheet-error { margin: 0; color: var(--danger); font-size: 14px; }
dialog menu { display: flex; gap: 8px; justify-content: flex-start; margin: 4px 0 0; padding: 0; }

.foot { max-width: 880px; margin: 0 auto; padding: 4px 16px 28px; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.foot a { color: var(--muted); }
