/* Schedule grid: agents as rows, time as columns. Activity tints appear only here, always with a code. */

.schedule {
  --slot: 14px;               /* width of one 15-minute interval */
  --name-width: 168px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: auto; font-size: var(--text-xs);
}

/* As wide as its hours, not the visible area: the lines between rows start and end with the schedule. */
.schedule__row { display: grid; grid-template-columns: var(--name-width) calc(var(--slots) * var(--slot)); width: max-content; min-height: 30px; }
.schedule__row + .schedule__row { border-top: 1px solid var(--border); }
.schedule__name {
  position: sticky; left: 0; z-index: 1;
  display: flex; align-items: center; padding: 0 var(--space-3);
  background: var(--surface); border-right: 1px solid var(--border);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.schedule__pick {
  display: flex; align-items: center; gap: var(--space-2); min-width: 0; cursor: pointer;
  span { overflow: hidden; text-overflow: ellipsis; }
}
.schedule__lane {
  position: relative;
  background-image: repeating-linear-gradient(to right, var(--border) 0 1px, transparent 1px calc(var(--slot) * 4));
}

.schedule__head .schedule__name, .schedule__head .schedule__lane { background-color: var(--surface-muted); color: var(--text-secondary); font-weight: 500; }
.schedule__hour { position: absolute; top: 7px; left: calc(var(--at) * var(--slot)); transform: translateX(4px); } /* --at: its slot */

.shift, .activity {
  position: absolute; top: 4px; bottom: 4px;
  left: calc(var(--from) * var(--slot)); width: calc(var(--span) * var(--slot));
  border-radius: var(--radius-sm);
}
.shift { background: var(--surface); border: 1px solid var(--border-strong); }
.shift--draft { opacity: .6; border-style: dashed; }
.activity {
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  font-size: 10px; font-weight: 600; letter-spacing: .02em;
}
.activity--unpaid { background-image: repeating-linear-gradient(-45deg, transparent 0 3px, color-mix(in srgb, currentColor 35%, transparent) 3px 5px); }
.activity--violation { box-shadow: inset 0 0 0 2px var(--danger); }

.activity--break    { background-color: var(--activity-break-bg);    color: var(--activity-break-text); }
.activity--lunch    { background-color: var(--activity-lunch-bg);    color: var(--activity-lunch-text); }
.activity--training { background-color: var(--activity-training-bg); color: var(--activity-training-text); }
.activity--coaching { background-color: var(--activity-coaching-bg); color: var(--activity-coaching-text); }
.activity--meeting  { background-color: var(--activity-meeting-bg);  color: var(--activity-meeting-text); }
.activity--nesting  { background-color: var(--activity-nesting-bg);  color: var(--activity-nesting-text); }
.activity--late     { background-color: var(--activity-late-bg);     color: var(--activity-late-text); }
.activity--vto      { background-color: var(--activity-vto-bg);      color: var(--activity-vto-text); }
.activity--sick     { background-color: var(--activity-sick-bg);     color: var(--activity-sick-text); }
.activity--overtime { background-color: var(--activity-overtime-bg); color: var(--activity-overtime-text); }

/* Time off (issue #70): a layer over the shift and its activities, which show through it. Approved exceptions (issue
   #362) too, in their type's colour, over what they replaced. */
.time-off, .exception {
  position: absolute; top: 2px; bottom: 2px; /* after the shift in the markup, so over it, and under the sticky names */
  left: calc(var(--from) * var(--slot)); width: calc(var(--span) * var(--slot));
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  border-radius: var(--radius-sm);
  font-size: 10px; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
}
.time-off {
  border: 1px dashed var(--time-off-text);
  background: color-mix(in srgb, var(--time-off-bg) 80%, transparent); color: var(--time-off-text);
}
.exception { border: 1px solid currentColor; }
/* A shift for a client the viewer doesn't see (CS-5): grey, with its times only, and nothing to open. */
.elsewhere {
  position: absolute; top: 4px; bottom: 4px;
  left: calc(var(--from) * var(--slot)); width: calc(var(--span) * var(--slot));
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  border-radius: var(--radius-sm); border: 1px dotted var(--border-strong); background: var(--surface-muted);
  color: var(--text-tertiary); font-size: 10px; font-weight: 600; white-space: nowrap; cursor: default;
}
.schedule--week .elsewhere { font-size: 0; }
.legend__swatch--elsewhere { background: var(--surface-muted); border: 1px dotted var(--border-strong); }
.time-off--unpaid { background-image: repeating-linear-gradient(-45deg, transparent 0 3px, color-mix(in srgb, currentColor 25%, transparent) 3px 5px); }
.schedule--week :is(.time-off, .exception) { font-size: 0; }
.legend__swatch--time-off { background: var(--time-off-bg); border: 1px dashed var(--time-off-text); }
.legend__swatch--exception { border: 1px solid var(--activity-sick-text); }

/* Coverage row: staffing heat against the requirement (status colours, no rainbow) */
.coverage { display: grid; grid-template-columns: repeat(var(--slots), var(--slot)); height: 100%; }
.coverage__cell { border-right: 1px solid var(--surface); }
.coverage__cell--under, .legend__swatch--under { background: var(--danger-tint); box-shadow: inset 0 -3px 0 var(--danger); }
.coverage__cell--short, .legend__swatch--short { background: var(--warning-tint); box-shadow: inset 0 -3px 0 var(--warning); }
.coverage__cell--over, .legend__swatch--over { background: var(--info-tint); }

.now-line { position: absolute; top: 0; bottom: 0; left: calc(var(--at) * var(--slot)); width: 2px; background: var(--accent); z-index: 2; }

.legend { display: flex; flex-wrap: wrap; gap: var(--space-3); font-size: var(--text-xs); color: var(--text-secondary); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__swatch { width: 14px; height: 14px; border-radius: var(--radius-sm); }
.legend__swatch--draft { border: 1px dashed var(--border-strong); }
.legend__swatch--token { background: var(--swatch); outline: 1px solid var(--border); } /* /design: --swatch is the token shown */

/* Full grid: scrolls inside the page with a sticky header, names and coverage */
.schedule--scroll { max-height: calc(100vh - 260px); }
.schedule__head { position: sticky; top: 0; z-index: 3; }
.schedule__head--coverage { top: 30px; }
.schedule__head .schedule__name { z-index: 4; }
.schedule--week { --slot: 4px; }
.schedule--week .schedule__lane { background-image: repeating-linear-gradient(to right, var(--border-strong) 0 1px, transparent 1px calc(var(--slot) * var(--day-slots))); }
.schedule--week .activity { font-size: 0; }
.shift { cursor: pointer; }
.shift:hover { border-color: var(--text); }
.activity { pointer-events: none; }
.schedule__rows { display: block; border-top: 1px solid var(--border); } /* a page of rows; a lazy frame needs a box to be seen */

/* What's in view, with its download and print beside it. */
.schedule__view { justify-content: space-between; }

/* Printing the grid (product-mvp/no-planner-downloads): landscape, a header saying what's in view, then everyone in it
   across the page's width; the rest of the page (filters, figures, buttons) stays on screen. Black and white: shifts
   outlined, activities in greys with their codes, unpaid ones hatched, and no row split between pages. The coverage
   strip, a heat map in colour, stays on screen with the figures. */
@page schedule { size: landscape; margin: 10mm; }

@media print {
  .content:has(> .schedule-sheet) { display: block; padding: 0; }
  .content:has(> .schedule-sheet) > :not(.schedule-sheet) { display: none; }

  .schedule-sheet {
    page: schedule;
    color-scheme: light;
    --surface: #fff; --surface-muted: #fff; --border: #c8c8c8; --border-strong: #000; --text: #000; --text-secondary: #333;
    color: #000;
    print-color-adjust: exact; -webkit-print-color-adjust: exact; /* the greys below, which a browser leaves out by default */
  }
  .schedule-sheet__header { margin-bottom: 8px; }
  .schedule-sheet__header h1 { font-size: 14pt; }
  .schedule-sheet__header p { font-size: 9pt; }

  /* A table on paper, so the hours or days head every page: each lane as wide as the page lets it, in slots of it. */
  .schedule { display: table; width: 100%; border: 0; border-radius: 0; border-collapse: collapse; overflow: visible; max-height: none; }
  .schedule__head { display: table-header-group; position: static; break-inside: avoid; }
  .schedule__rows { display: contents; } /* every page of rows, each frame inside the one before */
  .schedule__row:not(.schedule__head) { display: table-row; break-inside: avoid; }
  .schedule__row + .schedule__row, .schedule__rows > .schedule__row { border-top: 1px solid var(--border); }
  .schedule__name, .schedule__lane { display: table-cell; height: 30px; vertical-align: middle; }
  .schedule__name { position: static; width: 10rem; max-width: 10rem; }
  .schedule__pick input { display: none; }
  .schedule__lane { --slot: calc(100% / var(--slots)); }
  .schedule__head--coverage, .legend__item--coverage, .panel, .now-line { display: none; }
  .schedule__more .schedule__lane { padding-inline: 4px; font-weight: 600; }

  .shift, .shift--draft { background: #fff; border: 1px solid #000; border-style: solid; opacity: 1; }
  .activity { background-color: #dcdcdc; color: #000; }
  .activity--unpaid { background-image: repeating-linear-gradient(-45deg, transparent 0 3px, rgb(0 0 0 / .2) 3px 4px); }
  .activity--violation { box-shadow: inset 0 0 0 2px #000; }
  .time-off { background: rgb(255 255 255 / .6); border-color: #000; color: #000; }
  .exception { background-color: #fff; border-color: #000; color: #000; }
  .legend { color: #000; break-before: avoid; margin-top: 8px; }
  .legend__swatch[class*="activity--"] { background-color: #dcdcdc; } /* the key in the grid's greys too */
  .legend__swatch--time-off { background: #fff; border-color: #000; }
  .elsewhere, .legend__swatch--elsewhere { background: #f0f0f0; border-color: #000; color: #000; }
}

/* Finding someone in the grid (issue #103). */
.schedule__find { width: min(20rem, 100%); }

/* Scheduling an activity (issue #279): the times beside the names on a wide screen, below them on a narrow one. */
.booking { display: grid; gap: var(--space-5); align-items: start; }
@media (min-width: 1000px) {
  .booking { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
/* A time it fits: who it schedules beside it, and a Copy button for them. */
.booking__time { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }

/* Labor rules under the schedule, and before publishing (issue #650): a row for each rule broken, that opens to whom
   it's found for and on which days. The rule's name, its badge and its counts wrap onto lines of their own on a phone. */
.labour-issues { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.labour-issue { padding: var(--space-3) var(--space-4); }
.labour-issue + .labour-issue { border-top: 1px solid var(--border); }
.labour-issue summary {
  display: grid; grid-template-columns: var(--space-5) minmax(0, 1fr); list-style: none; cursor: pointer;
  &::-webkit-details-marker { display: none; }
  &::before { content: "›"; content: "›" / ""; align-self: start; justify-self: start; width: var(--space-3); text-align: center; color: var(--text-tertiary); transition: transform .15s ease; }
  &:hover .labour-issue__rule strong { text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--border-strong); }
}
.labour-issue[open] > summary::before { transform: rotate(90deg); }
.labour-issue__summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); }
.labour-issue__rule { flex: 1 1 20rem; min-width: 0; overflow-wrap: anywhere; }
.labour-issue__counts { font-size: var(--text-sm); }
.labour-issue__body { margin: var(--space-3) 0 var(--space-1) var(--space-5); }
.labour-issue__body p { margin: 0; }
.labour-issue__people {
  list-style: none; margin: var(--space-2) 0 0; padding: 0; display: grid; gap: var(--space-1); font-size: var(--text-sm);
  & li { display: grid; grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr); gap: var(--space-3); }
}
.labour-issue__person { font-weight: 500; }
.labour-issue__days { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .labour-issue__people li { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
/* Violations out of view, which stop publishing all the same. */
.labour-issues__hidden { color: var(--danger); }
.labour-issues__hidden .icon { vertical-align: -0.15em; }
