/* === CWH DAY CALENDAR ===
   A clinic's bookings for its one day (public/js/dayCalendar.js) on FullCalendar v6's day view, first used
   by the vaccinator portal's Job Details (FLG-394). Loaded on every portal by sharedCSS.php, so every rule is
   scoped to .cwh-day-cal, which dayCalendar_create() puts on the mount element (FullCalendar puts .fc on that same
   element, hence .cwh-day-cal.fc). Ported from the v6 wireframe's mv-day.css.

   Colours that are not brand tokens are the v6 wireframe's, as approved by Mariah McCleery for FLG-394
   (October 2026): the pale booked fill, the walk-in teal (Q126) and its fill, and the pill text colours, which
   pass WCAG AA on the pills' white. */
@import url('brandingPalette.css');

/* --- Entry colours: booked appointments in Open Blue and walk-ins in teal, whatever they are up to (the pills
       say that). Also used by the legend's swatches. ---------------------------------------------------------- */
.cwh-day-cal-ev--booked { --cwh-day-cal-fill: #e9f2fb; --cwh-day-cal-line: var(--cwh-open-blue); }
.cwh-day-cal-ev--walkin { --cwh-day-cal-fill: #e2f3f1; --cwh-day-cal-line: #0e8a7e; }
/* A fully cancelled booking, listed only under Show = Cancelled (FLG-422): greyed, with muted text. */
.cwh-day-cal-ev--cancelled { --cwh-day-cal-fill: var(--cwh-border); --cwh-day-cal-line: var(--cwh-light-grey); }
.cwh-day-cal.fc .fc-v-event.cwh-day-cal-ev--cancelled .fc-event-main { color: var(--cwh-mid-grey); }
/* A cancelled sub-service on a booking still partly booked: struck through beside the live ones (FLG-422). */
.cwh-day-cal-struck { text-decoration: line-through; color: var(--cwh-mid-grey); }

/* --- The page's Show filter, search and legend, which dayCalendar_create() moves into FullCalendar's toolbar:
       they take its left section and wrap within it; the zoom buttons stay top right. ------------------------ */
.cwh-day-cal-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-family: var(--cwh-font-family); font-size: 13px; color: var(--cwh-dark-blue); }
.cwh-day-cal-field { width: 220px; max-width: 100%; }
.cwh-day-cal-empty { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--cwh-mid-grey); }
.cwh-day-cal.fc .fc-toolbar.fc-header-toolbar { align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.cwh-day-cal.fc .fc-header-toolbar > .fc-toolbar-chunk:first-child { flex: 1 1 auto; min-width: 0; }

/* --- The legend: each colour with how many entries have it, set apart by a bullet. ---------------------------- */
.cwh-day-cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.cwh-day-cal-sep { color: var(--cwh-light-grey); font-size: 13px; }
.cwh-day-cal-key { display: inline-flex; align-items: center; gap: 6px; color: var(--cwh-dark-blue); font-size: 13px; }
.cwh-day-cal-key strong { font-weight: var(--cwh-font-bold); }
.cwh-day-cal-swatch { flex-shrink: 0; width: 14px; height: 14px; border-radius: 3px; border-left: 4px solid var(--cwh-day-cal-line); background: var(--cwh-day-cal-fill); }

/* --- An entry's content fits its height, by a container query on the entry. A full slot or more shows its time,
       name, sub-services and pills on their own lines; a shorter one runs the details along one line over the
       pills; a shorter one puts the pills on that line too; a shorter one still keeps just the details; and one
       too thin for text is just its colour. Pills that don't fit under the details wrap to the top right, at any
       text size (FLG-1030). At the page's own text size two bands are too short for them underneath: own lines
       need 4 + 16.575 + 19.5 + 16 + 3 + 20 = 79.075px (padding, time, name, sub-services, gap, pill) and one line
       4 + 19.5 + 3 + 20 = 46.5px, so entries just under those put the details and pills in one row, where the
       pills shorten first. ---------------------------------------------------------------------------------- */
.cwh-day-cal.fc .fc-timegrid-event.cwh-day-cal-ev { container-type: size; }
.cwh-day-cal-c { display: flex; flex-direction: column; flex-wrap: wrap; align-content: space-between; column-gap: 6px; height: 100%; overflow: hidden; }
.cwh-day-cal-head { display: flex; flex-direction: column; min-width: 0; max-width: 100%; }
.cwh-day-cal-head > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cwh-day-cal.fc .cwh-day-cal-head .fc-event-time { flex-shrink: 0; margin-bottom: 0; }
/* FullCalendar puts " - " after the time on short events; the entries set their details apart themselves. */
.cwh-day-cal.fc .fc-timegrid-event-short .fc-event-time::after { content: none; }
.cwh-day-cal .cwh-day-cal-line { color: var(--cwh-dark-grey); font-size: 12px; line-height: 16px; }
@container (max-height: 76px) {
    .cwh-day-cal-c { flex-wrap: nowrap; }
    .cwh-day-cal-head { flex-direction: row; align-items: baseline; }
    .cwh-day-cal.fc .cwh-day-cal-head .fc-event-title { flex-shrink: 0; }
    .cwh-day-cal-head .fc-event-title::before,
    .cwh-day-cal-head .cwh-day-cal-line::before { content: '\00a0\00b7\00a0'; }
}
@container (max-height: 43px) {
    .cwh-day-cal-c { flex-direction: row; align-items: center; gap: 6px; }
    .cwh-day-cal-head { flex: 1 1 auto; }
    .cwh-day-cal .cwh-day-cal-c .cwh-day-cal-pills { flex: 0 1 auto; margin-top: 0; }
}
@container (max-height: 25px) {
    .cwh-day-cal.fc .fc-v-event.fc-timegrid-event.cwh-day-cal-ev .fc-event-main { padding-top: 0; padding-bottom: 0; }
    .cwh-day-cal .cwh-day-cal-c .cwh-day-cal-pills { display: none; }
}
@container (max-height: 15px) {
    .cwh-day-cal .cwh-day-cal-c { visibility: hidden; }
}
@container ((max-height: 79.075px) and (not (max-height: 76px))) or ((max-height: 46.5px) and (not (max-height: 43px))) {
    .cwh-day-cal .cwh-day-cal-c { flex-direction: row; flex-wrap: nowrap; align-items: flex-start; column-gap: 4px; }
    .cwh-day-cal .cwh-day-cal-head { flex: 0 1 auto; margin-right: 2px; overflow: hidden; }
    .cwh-day-cal .cwh-day-cal-c .cwh-day-cal-pills { display: contents; }
    .cwh-day-cal .cwh-day-cal-pill { flex: 1 1 0; min-width: calc(1em + 18px); max-width: max-content; }   /* 1em of text, room for its "...", inside the pill's 8px padding and 1px border each side */
    .cwh-day-cal .cwh-day-cal-pill:first-child { margin-left: auto; }
}

/* --- Pills: what the colour says, in words (Walk-in), where a booking is up to, its pre-screening and any AIR
       error. White with dark text and a matching border, so they read on either fill. --------------------------- */
.cwh-day-cal .cwh-day-cal-pills { display: flex; flex-shrink: 0; gap: 4px; max-width: 100%; margin-top: 3px; overflow: hidden; }
.cwh-day-cal-pill { flex-shrink: 1; min-width: 0; overflow: hidden; padding: 1px 8px; text-overflow: ellipsis; border: 1px solid currentColor; border-radius: 999px; background: var(--cwh-white); font-family: var(--cwh-font-family); font-size: 12px; font-weight: var(--cwh-font-medium); line-height: 16px; white-space: nowrap; }
.cwh-day-cal-pill--walkin { color: #0b6e65; }
.cwh-day-cal-pill--green { color: #1e6b34; }
.cwh-day-cal-pill--grey { color: var(--cwh-dark-grey); }
.cwh-day-cal-pill--amber { color: #8a5300; }
.cwh-day-cal-pill--air { color: #b42318; }
.cwh-day-cal-pill--air::before { content: '\26A0\FE0E'; margin-right: 3px; }

/* --- The day: lines 40px apart, marking each booking slot until the zoom buttons space them 15 or 30 minutes
       apart, so each step out shortens the hours. An entry sits at its own time for its own length. The hour
       label sits on its line rather than mid-row, and entries run the full width of the day. ------------------- */
.cwh-day-cal.fc .fc-timegrid-slot { height: 40px; }
.cwh-day-cal.fc .fc-timegrid-slot-label { vertical-align: top; }
.cwh-day-cal.fc-direction-ltr .fc-timegrid-col-events { margin: 0; }
.cwh-day-cal.fc { --fc-bg-event-color: rgba(108, 117, 125, 0.3); --fc-bg-event-opacity: 1; }   /* --cwh-mid-grey, see-through, so the band's "Break" reads at full strength */

/* --- Undo what older calendar styles do to every event, to today and to the grid: theme.min.css and
       custom.pharmacy.css pad, space, tint and border .fc-event (the FullCalendar v2 look), and cwh-calendar.css
       tints today and lightens the grid lines to --cwh-border (FullCalendar's own line colour is restored). ---- */
.cwh-day-cal.fc .fc-event { margin: 0; padding: 0; cursor: pointer; }
.cwh-day-cal.fc .fc-bg-event { border: 0 !important; color: var(--cwh-dark-grey) !important; cursor: default; }
.cwh-day-cal.fc .fc-day-today { background: transparent !important; }
.cwh-day-cal.fc-theme-standard .fc-scrollgrid,
.cwh-day-cal.fc-theme-standard td,
.cwh-day-cal.fc-theme-standard th { border-color: var(--fc-border-color); }

/* --- Each entry in its colour, as a button. ------------------------------------------------------------------- */
.cwh-day-cal.fc .fc-v-event.cwh-day-cal-ev { background: var(--cwh-day-cal-fill); border: 0; border-left: 4px solid var(--cwh-day-cal-line) !important; border-radius: 3px; }
.cwh-day-cal.fc .fc-v-event.cwh-day-cal-ev .fc-event-main { padding: 2px 6px; color: var(--cwh-black); }
.cwh-day-cal.fc .cwh-day-cal-ev:focus-visible { outline: 2px solid var(--cwh-dark-blue); outline-offset: 1px; }

/* --- Phones: the portal's responsive-table rule (custom.pharmacy.css, max-width 560px) turns every table, row and
       cell into a block, pads every cell and hides the first cell of each row. FullCalendar's day grid IS a table
       (its first cell is the hour label), so the day collapsed to nothing; restore table layout inside the day
       calendar only. Two classes keep these ahead of that rule wherever this file loads. -------------------------- */
@media screen and (max-width: 560px) {
    .cwh-day-cal.fc table { display: table; width: 100%; }
    .cwh-day-cal.fc thead { display: table-header-group; }
    .cwh-day-cal.fc tbody { display: table-row-group; }
    .cwh-day-cal.fc tr { display: table-row; margin: 0; border: 0; background: transparent; }
    .cwh-day-cal.fc thead tr { position: static; top: auto; left: auto; }
    .cwh-day-cal.fc th,
    .cwh-day-cal.fc td,
    .cwh-day-cal.fc td:nth-of-type(1) { display: table-cell; padding: 0 !important; }
    .cwh-day-cal-field { width: 100%; }
}
