/* =============================================================================
   THE BOOKING SCREENS (core) — the month calendar, the time chips and the day book that
   every vertical's appointment book is built from (docs/booking-engine.md §3.5). Lifted from
   the restaurant's touch-reservations.css, which lifted them from the salon.

   Served, not scoped: components in a referenced project never reach a head's scoped bundle.
   Paint comes from the head through the family's --touch-* tokens (and the café/restaurant's
   --status-* palette where it has one); the --bk-* aliases below are the only names the rules
   use, each with a neutral fallback so a head that declares nothing still gets a readable book.
   ========================================================================== */
:root {
    --bk-panel: var(--touch-tile-alt, var(--touch-panel, rgba(255, 255, 255, 0.86)));
    --bk-border: var(--touch-frost-border, rgba(255, 255, 255, 0.6));
    --bk-inset: var(--touch-frost-inset, rgba(255, 255, 255, 0.5));
    --bk-control: var(--touch-control, rgba(255, 255, 255, 0.7));
    --bk-line: var(--touch-line, #dcdcd8);
    --bk-ink: var(--touch-ink, #1c1c1c);
    --bk-muted: var(--touch-muted, #5e5e5c);
    --bk-hint: var(--touch-hint, #8f8f8c);
    --bk-accent: var(--touch-accent, #2f4a63);
    --bk-accent-fill: var(--touch-accent-fill, var(--bk-accent));
    --bk-on-accent: var(--touch-on-accent, #fff);
    --bk-booked: var(--status-ordered, #3b82c4);
    --bk-arrived: var(--status-ready, #3fa34d);
    --bk-occupying: var(--status-preparing, #f5a623);
    --bk-alert: var(--status-unpaid, #e5484d);
}
/* The same tokens re-resolved under a night theme (they are composed from --touch-*). */
.theme-dark {
    --bk-panel: var(--touch-tile-alt, var(--touch-panel, rgba(40, 40, 40, 0.88)));
    --bk-border: var(--touch-frost-border, rgba(255, 255, 255, 0.1));
    --bk-inset: var(--touch-frost-inset, rgba(255, 255, 255, 0.06));
    --bk-control: var(--touch-control, rgba(255, 255, 255, 0.06));
    --bk-line: var(--touch-line, rgba(255, 255, 255, 0.1));
    --bk-ink: var(--touch-ink, #f0f0ec);
    --bk-muted: var(--touch-muted, #b0b0ac);
    --bk-hint: var(--touch-hint, #8f8f8c);
    --bk-accent: var(--touch-accent, #a9c4de);
    --bk-accent-fill: var(--touch-accent-fill, var(--bk-accent));
    --bk-on-accent: var(--touch-on-accent, #fff);
}

/* The panel a calendar, list or sheet sits on. */
.bk-panel {
    box-sizing: border-box; border-radius: 20px; background: var(--bk-panel);
    backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid var(--bk-border); box-shadow: 0 6px 20px var(--touch-shadow, rgba(0,0,0,.12)), inset 0 1px 0 var(--bk-inset);
}
.bk-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 16px; text-align: center; color: var(--bk-muted); }
.bk-chips--alt { margin-top: 8px; align-items: center; }
.bk-chips__label { font-size: 0.85rem; font-weight: 600; color: var(--bk-muted); margin-inline-end: 4px; }

/* ── Calendar ── */
.bk-cal { box-sizing: border-box; border-radius: 20px; background: var(--bk-panel); border: 1px solid var(--bk-border); box-shadow: 0 6px 20px var(--touch-shadow, rgba(0,0,0,.12)), inset 0 1px 0 var(--bk-inset); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.bk-cal__head { display: flex; align-items: center; gap: 6px; }
.bk-cal__title { flex: 1; text-align: center; font-weight: 700; font-size: 1.05rem; text-transform: capitalize; }
.bk-nav, .bk-today {
    -webkit-appearance: none; appearance: none; font: inherit; cursor: pointer; touch-action: manipulation;
    height: 40px; min-width: 40px; border-radius: 11px; border: 1px solid var(--bk-line); background: var(--bk-control); color: var(--bk-ink); font-weight: 700;
}
.bk-nav { font-size: 1.3rem; line-height: 1; }
.bk-today { padding: 0 12px; font-size: 0.85rem; font-weight: 600; }
.bk-cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.bk-cal__dow { text-align: center; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--bk-hint); padding: 4px 0; }
.bk-cal__cell {
    -webkit-appearance: none; appearance: none; font: inherit; cursor: pointer; touch-action: manipulation; position: relative;
    aspect-ratio: 1 / 1; min-height: 44px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--bk-ink);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.bk-cal__cell--blank { cursor: default; }
.bk-cal__cell.is-past { color: var(--bk-hint); }
.bk-cal__cell.is-today { border-color: var(--bk-accent); }
.bk-cal__cell.is-sel { background: var(--bk-accent-fill); color: var(--bk-on-accent); border-color: var(--bk-accent); }
/* A span: its two ends are filled like a single day, the days between carry a tint, so the
   eye reads one continuous band across the week rows. */
.bk-cal__cell.is-inrange { background: color-mix(in srgb, var(--bk-accent) 16%, transparent); border-color: transparent; border-radius: 6px; }
.bk-today.is-on { background: var(--bk-accent-fill); border-color: var(--bk-accent); color: var(--bk-on-accent); }
.bk-cal__daynum { font-weight: 600; font-size: 0.95rem; line-height: 1; }
.bk-cal__n { min-width: 18px; height: 16px; padding: 0 5px; border-radius: 999px; display: inline-grid; place-items: center; font-size: 0.68rem; font-weight: 700; background: var(--bk-booked); color: #fff; }
.bk-cal__cell.is-sel .bk-cal__n { background: var(--bk-on-accent); color: var(--bk-accent-fill); }
.bk-cal__foot { font-size: 0.85rem; color: var(--bk-muted); text-align: center; }
.bk-cal__foot b { color: var(--bk-ink); }

.bk-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bk-chip {
    -webkit-appearance: none; appearance: none; font: inherit; cursor: pointer; touch-action: manipulation;
    height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--bk-line); background: var(--bk-control); color: var(--bk-ink); font-weight: 600; font-size: 0.85rem;
}
.bk-chip.is-on { background: var(--bk-accent-fill); border-color: var(--bk-accent); color: var(--bk-on-accent); }
.bk-chip.is-full:not(.is-on) { opacity: 0.45; text-decoration: line-through; }
.bk-chip:disabled { cursor: not-allowed; }
.bk-chip--alt { border-color: var(--bk-arrived); color: color-mix(in srgb, var(--bk-arrived) 70%, var(--bk-ink)); background: color-mix(in srgb, var(--bk-arrived) 10%, var(--bk-control)); }

.bk-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.bk-stat {
    display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px;
    background: var(--bk-panel); border: 1px solid var(--bk-border); font-size: 0.88rem; color: var(--bk-muted);
}
.bk-stat b { color: var(--bk-ink); font-variant-numeric: tabular-nums; }
.bk-stat.is-full, .bk-stat--warn { border-color: color-mix(in srgb, var(--bk-alert) 50%, transparent); color: var(--bk-alert); }
.bk-stat.is-full b { color: var(--bk-alert); }
.bk-legend { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-left: auto; font-size: 0.82rem; color: var(--bk-muted); }
.bk-sw { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-left: 4px; }
.bk-sw--booked { background: var(--bk-booked); }
.bk-sw--arrived { background: var(--bk-arrived); }
.bk-sw--occupying { background: var(--bk-occupying); }
.bk-sw--free { background: var(--bk-control); border: 1px solid var(--bk-line); }

.bk-unplaced {
    display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 14px;
    background: color-mix(in srgb, var(--bk-alert) 9%, var(--bk-panel));
    border: 1px solid color-mix(in srgb, var(--bk-alert) 40%, transparent);
}
.bk-unplaced__h { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--bk-alert); }
.bk-unplaced__row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; color: var(--bk-ink); text-decoration: none; font-size: 0.92rem; }
.bk-unplaced__why { color: var(--bk-muted); font-size: 0.85rem; }

/* The grid sits on the solid panel so the shop's background photos never run through it. */
.bk-grid__scroll {
    overflow: auto; max-height: calc(100vh - 240px); border-radius: 18px;
    background: var(--bk-panel); border: 1px solid var(--bk-border);
    box-shadow: 0 6px 20px var(--touch-shadow); -webkit-overflow-scrolling: touch;
}
.bk-grid { display: grid; min-width: max-content; position: relative; }

.bk-grid__corner, .bk-grid__th {
    position: sticky; top: 0; z-index: 3; padding: 8px 6px; background: var(--bk-control);
    border-bottom: 2px solid var(--bk-line);
}
.bk-grid__corner { left: 0; z-index: 4; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--bk-hint); display: flex; align-items: flex-end; }
.bk-grid__th { display: flex; flex-direction: column; align-items: center; gap: 2px; border-left: 1px solid var(--bk-line); text-align: center; }
.bk-grid__th-label { font-weight: 800; font-size: 0.95rem; color: var(--bk-ink); white-space: nowrap; }
.bk-grid__th-meta { font-size: 0.72rem; color: var(--bk-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* The gutter: the time on the hour, and for every row the tables taken over the room's. */
.bk-grid__time {
    position: sticky; left: 0; z-index: 2; display: flex; align-items: center; gap: 6px; padding: 0 6px;
    background: var(--bk-control); border-right: 1px solid var(--bk-line);
    border-top: 1px solid color-mix(in srgb, var(--bk-line) 45%, transparent);
    font-variant-numeric: tabular-nums;
}
.bk-grid__time.is-hour { border-top-color: var(--bk-line); }
.bk-grid__time-t { width: 38px; font-size: 0.76rem; font-weight: 700; color: var(--bk-ink); }
.bk-grid__cap { font-size: 0.72rem; font-weight: 700; color: var(--bk-hint); min-width: 30px; text-align: right; }
.bk-grid__cap.is-some { color: var(--bk-ink); }
.bk-grid__cap.is-full { color: var(--bk-alert); }
.bk-grid__bar { position: absolute; left: 0; bottom: 0; width: 100%; height: 3px; background: transparent; }
.bk-grid__bar > span { display: block; height: 100%; background: color-mix(in srgb, var(--bk-booked) 55%, transparent); }
.bk-grid__time:has(.bk-grid__cap.is-full) .bk-grid__bar > span { background: var(--bk-alert); }
.bk-grid__time.is-now .bk-grid__time-t { color: var(--bk-alert); }

.bk-grid__cell {
    position: relative; border-left: 1px solid color-mix(in srgb, var(--bk-line) 60%, transparent);
    border-top: 1px solid color-mix(in srgb, var(--bk-line) 35%, transparent);
}
.bk-grid__cell.is-hour { border-top-color: var(--bk-line); }
.bk-grid__cell.is-shut { background: color-mix(in srgb, var(--bk-ink) 6%, transparent); }
.bk-grid__cell.is-past { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--bk-ink) 9%, transparent) 0 3px, transparent 3px 8px); }
.bk-grid__cell.is-now { box-shadow: inset 0 2px 0 var(--bk-alert); }
.bk-grid__cell.is-free { cursor: pointer; }
.bk-grid__cell.is-free:hover { background: color-mix(in srgb, var(--bk-arrived) 14%, transparent); }
.bk-grid__plus { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--bk-arrived); opacity: 0; }
.bk-grid__cell.is-free:hover .bk-grid__plus { opacity: 1; }

/* A party: a card over the rows it holds. */
.bk-grid__block {
    --s: var(--bk-booked);
    z-index: 1; margin: 2px 3px; padding: 4px 7px; border-radius: 8px; overflow: hidden; text-decoration: none;
    display: flex; flex-direction: column; gap: 1px; min-width: 0;
    background: color-mix(in srgb, var(--s) 18%, var(--bk-panel));
    border: 1px solid color-mix(in srgb, var(--s) 55%, transparent); border-left: 4px solid var(--s);
    color: var(--bk-ink);
}
.bk-grid__block--arrived { --s: var(--bk-arrived); }
.bk-grid__block--occupying { --s: var(--bk-occupying); }
.bk-grid__block.is-squeezed { border-style: dashed; }
.bk-grid__block-name { font-size: 0.82rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-grid__block-meta { font-size: 0.72rem; color: var(--bk-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-grid__block-note { font-size: 0.72rem; font-style: italic; color: var(--bk-accent); overflow: hidden; text-overflow: ellipsis; }
