/* ==========================================================================
   Attendance register: layout only. Tabs, filters, tables, chips, buttons, fields, callouts and dialogs come from components/ui.css and
   Web Awesome. The Register / Import switch (ui-tabs) is shared with the Import screen.
   ========================================================================== */
@layer app-pages {

    #viewAttendanceRegister > .ui-page { display: flex; flex-direction: column; gap: 1rem; }
    /* The switch sits just above the page header */
    #viewAttendanceRegister .ui-tabs { margin-bottom: 0.25rem; }
    #viewAttendanceRegister .ui-filter-bar,
    #viewAttendanceRegister wa-tab-group { margin: 0; }

    /* Custom range: From and To sit side by side on their own row of the filter bar, and only show for "Custom range" */
    .attreg-custom-range[hidden] { display: none; }          /* the display rule below would otherwise beat the hidden attribute */
    .attreg-custom-range { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 14rem)); gap: 0.75rem 1rem; }

    /* The filters in use, as removable tags */
    .attreg-chips[hidden] { display: none; }
    .attreg-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0; }
    .attreg-chips-label { font-size: 0.8125rem; color: var(--d26-ink-3); }

    /* One panel for the period and the filters: a header, the import note, and the filters under a divider */
    .attreg-panel { display: flex; flex-direction: column; gap: 1rem; padding: 1.125rem 1.375rem; }
    .attreg-panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem; }
    .attreg-period { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
    .attreg-period-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 2.75rem; height: 2.75rem; border-radius: var(--d26-radius-control); background: var(--d26-accent-soft); color: var(--d26-accent); font-size: 1.125rem; }
    .attreg-period-text { display: flex; flex-direction: column; gap: 0.125rem; min-width: 0; }
    .attreg-period-kicker { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--d26-ink-3); }
    .attreg-month-name { font-size: 1.25rem; line-height: 1.2; color: var(--d26-ink); overflow-wrap: anywhere; }
    .attreg-month { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0; }
    .attreg-month .ui-field { width: auto; min-width: 11rem; margin: 0; }
    .attreg-panel-filters { display: flex; flex-direction: column; gap: 0.75rem; padding-top: 1rem; border-top: 1px solid var(--d26-line); }
    /* The filter bar is a card of its own elsewhere; inside the panel it is only the grid of fields */
    #viewAttendanceRegister .attreg-panel .ui-filter-bar { margin: 0; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; }

    #attRegCoverage:empty { display: none; }
    #attRegLoadingSkeleton:not([hidden]) { margin: 0; }

    .attreg-more { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.75rem; margin-top: 0.75rem; }
    .attreg-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin: 0 0 0.75rem; }
    .attreg-pick { display: inline-flex; align-items: center; justify-content: center; min-width: var(--d26-target); min-height: var(--d26-target); }
    .attreg-summary { margin: 0 0 1rem; padding: 0.75rem 1rem; border: 1px solid var(--d26-line); border-radius: var(--d26-radius-card); background: var(--d26-accent-soft); font-size: 0.875rem; line-height: 1.5; }
    .attreg-summary:empty { display: none; }

    /* A number that deserves attention is also bold, so colour is never the only signal */
    .attreg-late { color: var(--d26-wait-fg); font-weight: 700; }
    .attreg-absent { color: var(--d26-bad-fg); font-weight: 700; }
    .attreg-code { font-size: 0.75rem; color: var(--d26-ink-2); }
    .attreg-tfoot td { font-weight: 700; background: var(--d26-draft-bg); }
    .attreg-name { text-align: left; }
    .attreg-tint-minor td { background: var(--d26-wait-bg); }
    .attreg-tint-urgent td { background: var(--d26-bad-bg); }
    /* Tinted rows of the Register and the days dialog. The shared table paints its hover on the row, but these rows colour their cells, so each needs its own hover */
    .attreg-tint-minor:hover td { background: var(--d26-wait-bg-hover); }
    .attreg-tint-urgent:hover td { background: var(--d26-bad-bg-hover); }
    /* Today's row: the accent tint with a bar on the left; "Working now" or "Today" is written in the Status cell */
    .attreg-day-now td { background: var(--d26-accent-soft); }
    .attreg-day-now:hover td { background: var(--d26-accent-soft-hover); }
    .attreg-day-now td:first-child { box-shadow: inset 0.25rem 0 0 var(--d26-accent); }
    /* The days dialog has 10 columns, so it is wider than the shared "wide" size (52rem), and never wider than the screen */
    wa-dialog#attDaysModal { --width: min(72rem, calc(100vw - 2rem)); }
    .attreg-legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin: 0 0 0.75rem; padding: 0; list-style: none; font-size: 0.875rem; color: var(--d26-ink-2); }
    .attreg-legend li { display: flex; align-items: center; gap: 0.5rem; }
    .attreg-legend--card { margin: 0; padding: 0.75rem 1rem; border-bottom: 1px solid var(--d26-line); }
    .attreg-swatch { flex: none; width: 1rem; height: 1rem; border: 1px solid var(--d26-line); border-radius: 0.25rem; }
    .attreg-swatch--minor { background: var(--d26-wait-bg); }
    .attreg-swatch--urgent { background: var(--d26-bad-bg); }
    .attreg-swatch--now { background: var(--d26-accent-soft); box-shadow: inset 0.25rem 0 0 var(--d26-accent); }
    .attreg-swatch--plain { background: transparent; }
    /* Resolve and Correct time dialogs: a header for the case, the recorded figures, time boxes with what is recorded beside them */
    wa-dialog#hrCorrectModal { --width: min(36rem, calc(100vw - 2rem)); }
    .attreg-case { display: grid; justify-items: start; gap: 0.375rem; margin: 0 0 1rem; font-size: 0.875rem; }
    .attreg-case-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; }
    .attreg-case-head strong { font-size: 1rem; }
    .attreg-case-date { color: var(--d26-ink-2); }
    .attreg-case-detail { margin: 0; color: var(--d26-ink-2); white-space: pre-line; }
    .attreg-recorded { margin: 0 0 1rem; padding: 0.75rem 1rem; border: 1px solid var(--d26-line); border-radius: var(--d26-radius-card); background: var(--d26-surface); }
    .attreg-recorded-title { margin: 0 0 0.375rem; font-size: 0.875rem; font-weight: 600; }
    .attreg-figures { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin: 0; }
    .attreg-figures dt { font-size: 0.75rem; color: var(--d26-ink-2); }
    .attreg-figures dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
    .attreg-figures dd.attreg-miss { color: var(--d26-wait-fg); }
    .attreg-timegrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
    .attreg-timecell { display: grid; align-content: start; gap: 0.25rem; }
    .attreg-timecell--flag { padding-left: 0.75rem; box-shadow: inset 0.25rem 0 0 var(--d26-wait-fg); }
    .attreg-rec { margin: 0; font-size: 0.8125rem; color: var(--d26-ink-2); font-variant-numeric: tabular-nums; }
    .attreg-rec--missing { color: var(--d26-wait-fg); font-weight: 600; }
    .attreg-lunch { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 0; padding: 0; border: 0; min-width: 0; }
    .attreg-lunch legend { margin: 0 0 0.5rem; padding: 0; font-size: 0.875rem; font-weight: 600; }
    .attreg-quick { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0 1rem; }      /* the room above keeps the buttons off the box they fill */
    .attreg-quick wa-button::part(base) { min-height: var(--d26-target); }
    .attreg-changes { display: grid; gap: 0.25rem; margin: 0.375rem 0 0.5rem; padding: 0; list-style: none; }
    .attreg-changes li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-variant-numeric: tabular-nums; }
    .attreg-was { color: var(--d26-ink-2); }
    .attreg-switch { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; margin: 0 0 1rem; font-size: 0.875rem; color: var(--d26-ink-2); }
    @media (max-width: 30rem) {
        .attreg-timegrid, .attreg-lunch { grid-template-columns: minmax(0, 1fr); }
    }
    .attreg-detail { white-space: pre-line; }      /* each fact of a Days to fix detail is its own line */
    .attreg-days { max-height: 60vh; overflow: auto; }
    .attreg-cap { text-transform: capitalize; }
    .attreg-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.375rem; }
    .attreg-correct { display: flex; flex-direction: column; gap: 0.875rem; }      /* the Correct time fields */

    /* The card switch for the three tables and the days window is the shared data_table() (cards="wide" / "narrow"); these are this page's extras. */
    @container (width > 55rem) {                                                    /* wide table: keep the action in view while it scrolls sideways */
        .ui-table--cards-wide th.attreg-col-act, .ui-table--cards-wide td.attreg-col-act { position: sticky; right: 0; box-shadow: -1px 0 0 var(--d26-line); }
        .ui-table--cards-wide td.attreg-col-act .attreg-actions { flex-wrap: nowrap; }   /* the row's buttons side by side */
        .ui-table--cards-wide td.attreg-col-act { background: var(--d26-card); }
        .ui-table--cards-wide th.attreg-col-act { background: var(--d26-surface); }
        .ui-table--cards-wide tbody tr:hover td.attreg-col-act { background: var(--d26-surface); }
    }
    @container (width <= 55rem) { .ui-table--cards-wide td[data-label="Select"]:empty { display: none; } }   /* a row that cannot be ticked has no empty "Select" line */

    /* The days-to-fix bar sticks under the top bar while the table scrolls */
    #attExcBulkBar:not([hidden]) { position: sticky; top: 4rem; z-index: 5; margin: 0 0 0.75rem; padding: 0.625rem 1rem; background: var(--d26-card); border: 1px solid var(--d26-accent); border-radius: var(--d26-radius-card); }
    #attExcBulkBar .attreg-bulk { margin: 0; }
    @media screen and (max-width: 1100px) { #attExcBulkBar:not([hidden]) { position: static; } }
}
