/* ==========================================================================
   Work schedules: layout only. Tab group, cards, tables, chips, buttons, fields, callouts and the dialogs come from components/ui.css and
   Web Awesome. The screen is an Alpine component: Alpine's x-show sets the display of what it hides, so these rules never set a display on
   an element that Alpine shows or hides, except through a wrapper.
   ========================================================================== */
@layer app-pages {

    /* "New schedule" sits at the right end of the row of tabs. The tab bar is Web Awesome's, so the button is placed over its right end;
       on a narrow screen there is no room beside the tabs, so it goes above them. */
    .work-schedule-tabs { position: relative; }
    .work-schedule-new { position: absolute; top: -0.5rem; right: 0; z-index: 2; }
    @media (max-width: 720px) {
        .work-schedule-new { position: static; display: block; margin: 0 0 0.75rem; }
    }

    /* The tab: a title and a line under it */
    .work-schedule-tab { display: flex; flex-direction: column; align-items: flex-start; text-align: left; line-height: 1.3; }
    .work-schedule-tab-title { font-weight: 700; color: var(--d26-ink); }
    .work-schedule-tab-sub { font-size: 0.75rem; font-weight: 400; color: var(--d26-ink-muted); }

    .work-schedule-error { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }

    /* One schedule */
    /* The parts of a card (head with its buttons, the facts, a planned change, the history) are spaced by the card's own gap, not by
       margins on each part, so no rule elsewhere can squeeze them together. A part that is hidden takes no gap. */
    .work-schedule-card { margin: 0 0 1rem; display: flex; flex-direction: column; gap: 1.25rem; }
    .work-schedule-card.is-off { background: var(--d26-surface); }
    .work-schedule-card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
    .work-schedule-name { display: inline; margin: 0 0.5rem 0 0; font-size: 1.0625rem; color: var(--d26-ink); }
    .work-schedule-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
    /* Switch off, Make default and Delete sit apart from Edit and History, so a risky button is not next to the usual ones */
    .work-schedule-actions-more { display: inline-flex; flex-wrap: wrap; gap: 0.5rem; margin-left: 0.75rem; padding-left: 0.75rem; border-left: 1px solid var(--d26-line); }
    .work-schedule-actions-more:not(:has(> wa-button:not([style*="display: none"]))) { display: none; }
    .work-schedule-impact { margin: 0.5rem 0 0; color: var(--d26-ink-2); }
    @media (max-width: 640px) {
        .work-schedule-actions-more { margin-left: 0; padding-left: 0; border-left: 0; }
    }
    .work-schedule-facts { margin: 0; }
    .work-schedule-card wa-callout { margin: 0; }
    .work-schedule-history { margin: 0; border: 1px solid var(--d26-line); border-radius: var(--d26-radius-control); }

    /* The tables: the buttons stay on one line, and on a phone each row becomes a small card (data-label) */
    .work-schedule-row-actions { white-space: nowrap; text-align: right; }
    .work-schedule-row-actions wa-button + wa-button { margin-left: 0.5rem; }
    .work-schedule-h3 { margin: 1.5rem 0 0.5rem; }
    /* "Who uses which" and "Check a day": a hint, a filter box, a line, then the tables or the result. The panel spaces them with one gap
       (the same way as a schedule card), so a hint never sits on top of the box under it. */
    #wsPaneWho > div, #wsPaneCheck > div { display: flex; flex-direction: column; gap: 1rem; }
    #wsPaneWho > div > *, #wsPaneCheck > div > * { margin: 0; }
    #wsPaneWho > div > .work-schedule-h3 { margin-top: 0.75rem; }
    #wsPaneWho > div > .work-schedule-h3 + .ui-hint { margin-top: -0.5rem; }      /* the note belongs to the heading above it */
    .work-schedule-submit { display: flex; align-items: flex-end; }
    /* The department picker holds several tags, so it takes two columns of the filter bar and stays level with its neighbours */
    .work-schedule-depts { grid-column: span 2; min-width: 0; }
    .work-schedule-depts wa-select::part(combobox) { min-height: var(--d26-target, 2.75rem); }
    .work-schedule-depts wa-select::part(tags) { gap: 0.25rem; }
    @media (max-width: 640px) {
        .work-schedule-depts { grid-column: 1 / -1; }
    }
    .ui-filter-bar + wa-callout { margin-top: -0.5rem; }

    /* The week table in the rules dialog: seven rows of controls; it scrolls sideways on a narrow screen instead of squeezing */
    /* Wider than the usual "wide" dialog, so all seven columns show without scrolling sideways on a desktop */
    wa-dialog#wsRulesModal { --width: min(68rem, 96vw); }
    /* position (here and on .work-schedule-inline): hidden captions and labels are absolute; without a positioned parent they
       stretch the dialog and give it a second scrollbar */
    .work-schedule-days { margin: 1rem 0; position: relative; }
    .work-schedule-days-table { min-width: 40rem; }
    .work-schedule-days-table th, .work-schedule-days-table td { padding: 0.375rem 0.5rem; vertical-align: middle; }
    .work-schedule-days-table tr.is-rest th, .work-schedule-days-table tr.is-rest td { color: var(--d26-ink-3); }
    .work-schedule-copy { margin-top: 0.625rem; }
    .work-schedule-fieldset { margin: 1rem 0; padding: 0.75rem 1rem; border: 1px solid var(--d26-line); border-radius: var(--d26-radius-control); min-width: 0; }
    .work-schedule-fieldset legend { padding: 0 0.375rem; font-size: 0.8125rem; font-weight: 600; color: var(--d26-ink-2); }
    .work-schedule-inline { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
    .work-schedule-narrow { width: 8rem; }
    wa-dialog .ui-form-grid + .work-schedule-days, wa-dialog .work-schedule-fieldset + .ui-form-grid { margin-top: 1rem; }

    /* The card switch is the shared data_table(cards="narrow"); in a card the buttons stack under their label. */
    @container (width <= 40rem) {
        .work-schedule-row-actions { white-space: normal; text-align: left; }
        .work-schedule-row-actions wa-button + wa-button { margin-left: 0; }
    }
}
