/* Booking calendar. Theme tokens only. Bars and rows take their size from the custom properties
   --cols, --lanes, --bar-left, --bar-width and --bar-lane that the components set (see TimelineStyle). */

.booking-timeline {
  --booking-name-width: 12rem;
  --booking-lane-height: 1.75rem;
  border: 1px solid var(--cosmos-border);
  border-radius: 6px;
  background: var(--cosmos-surface);
  overflow-x: auto;
}

.booking-timeline-head,
.booking-row {
  display: grid;
  grid-template-columns: var(--booking-name-width) minmax(0, 1fr);
  min-width: 48rem;
}

.booking-timeline-head {
  background: var(--cosmos-surface-raised);
  border-bottom: 1px solid var(--cosmos-border-strong);
  color: var(--cosmos-fg-muted);
  font-size: 0.75rem;
}

.booking-row {
  border-bottom: 1px solid var(--cosmos-border);
}

.booking-row:last-child {
  border-bottom: 0;
}

.booking-row-inactive {
  opacity: 0.6;
  background: var(--cosmos-canvas);
}

.booking-row-name {
  padding: 0.35rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.1rem;
  min-width: 0;
  border-right: 1px solid var(--cosmos-border);
  color: var(--cosmos-fg);
}

/* The title line: the resource's title (an aircraft's registration) and the "not verified" badge. */
.booking-row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
}

.booking-resource-title {
  padding: 0;
  text-align: left;
  color: var(--cosmos-fg);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

a.booking-resource-title:hover,
a.booking-resource-title:focus-visible {
  text-decoration: underline;
}

/* The smaller second line (an aircraft's type, otherwise the resource type); opens the resource's week. */
.booking-resource-subtitle {
  padding: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-size: 0.8rem;
  line-height: 1.2;
  color: var(--cosmos-fg-muted);
  text-decoration: none;
}

.booking-resource-subtitle:hover,
.booking-resource-subtitle:focus-visible {
  color: var(--cosmos-fg);
  text-decoration: underline;
}

.booking-not-verified {
  background: var(--cosmos-status-warn-soft);
  color: var(--cosmos-fg);
  border: 1px solid var(--cosmos-status-warn);
  font-weight: 500;
}

.booking-not-verified-text {
  color: var(--cosmos-fg-muted);
  font-size: 0.85rem;
}

.booking-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  min-height: calc(var(--lanes, 1) * var(--booking-lane-height) + 0.5rem);
}

.booking-track-head {
  min-height: 0;
}

.booking-col-label {
  padding: 0.3rem 0.2rem;
  text-align: center;
  border-left: 1px solid var(--cosmos-border);
  overflow: hidden;
  white-space: nowrap;
}

.booking-col-label.booking-col-major {
  color: var(--cosmos-fg);
  font-weight: 600;
}

.booking-cell.booking-col-major {
  border-left-color: var(--cosmos-border-strong);
}

.booking-bar-time {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.booking-now {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--now-left);
  width: 2px;
  background: var(--cosmos-fg);
  z-index: 2;
  pointer-events: none;
}

/* With the now line the header gets a second line, for its label: on the first it covered the hour label under it. */
.booking-track-head-now {
  padding-bottom: 1.1rem;
}

.booking-now-label {
  position: absolute;
  bottom: 0.15rem;
  left: var(--now-left);
  transform: translateX(-50%);
  padding: 0 0.3rem;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  background: var(--cosmos-fg);
  color: var(--cosmos-surface);
  border-radius: 3px;
  z-index: 2;
  pointer-events: none;
}

.booking-cell {
  border: 0;
  border-left: 1px solid var(--cosmos-border);
  background: transparent;
  padding: 0;
  min-height: 100%;
}

.booking-cell-free {
  cursor: pointer;
}

.booking-cell-free:hover,
.booking-cell-free:focus-visible {
  background: var(--cosmos-row-hover);
  outline: 2px solid var(--cosmos-focus-ring);
  outline-offset: -2px;
}

.booking-bar {
  position: absolute;
  left: var(--bar-left);
  width: var(--bar-width);
  top: calc(0.25rem + var(--bar-lane) * var(--booking-lane-height));
  height: calc(var(--booking-lane-height) - 0.25rem);
  box-sizing: border-box;
  padding: 0 0.4rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
  font-size: 0.8rem;
  line-height: calc(var(--booking-lane-height) - 0.35rem);
  border: 1px solid var(--cosmos-border-strong);
  border-radius: 4px;
  background: var(--cosmos-surface-raised);
  color: var(--cosmos-fg);
  z-index: 1;
}

button.booking-bar-open {
  cursor: pointer;
}

button.booking-bar-open:focus-visible,
button.booking-bar-open:hover {
  outline: 2px solid var(--cosmos-focus-ring);
}

.booking-mine {
  background: var(--cosmos-accent);
  border-color: var(--cosmos-accent);
  color: var(--cosmos-fg-on-accent);
}

.booking-other {
  background: var(--cosmos-brand-soft);
  border-color: var(--cosmos-brand-muted);
}

.booking-occupied {
  background: var(--cosmos-surface-raised);
  border-style: dashed;
  color: var(--cosmos-fg-muted);
}

.booking-block {
  background: var(--cosmos-status-bad-soft);
  border-color: var(--cosmos-status-bad);
}

.booking-downtime {
  background: var(--cosmos-status-info-soft);
  border-color: var(--cosmos-status-info);
}

.booking-flagged {
  background: var(--cosmos-status-warn-soft);
  border: 2px solid var(--cosmos-status-warn);
  color: var(--cosmos-fg);
}

/* Narrow screens show the agenda; wide ones the timeline. Both are rendered, CSS picks one (the md breakpoint, 768px). */
.booking-agenda-wrap {
  display: none;
}

@media (max-width: 767.98px) {
  .booking-timeline-wrap {
    display: none;
  }

  .booking-agenda-wrap {
    display: block;
  }
}

.booking-agenda-date {
  margin: 1rem 0 0.4rem;
  font-size: 0.95rem;
  color: var(--cosmos-fg-muted);
}

.booking-agenda-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

/* The defaults sit in :where() (specificity 0): the kind classes above (.booking-mine, .booking-flagged, ...) are
   written once for bars and agenda items alike and must win here whatever the source order. Each kind sets its own
   background and, where it needs one, its own foreground; the default foreground is the theme's own. */
:where(.booking-agenda-item) {
  border: 1px solid var(--cosmos-border-strong);
  background: var(--cosmos-surface-raised);
  color: var(--cosmos-fg);
}

.booking-agenda-item {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
}

.booking-agenda-button {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.booking-agenda-time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.booking-agenda-resource {
  font-weight: 600;
}

/* Week view: one grid per resource, a name column and seven day columns; bands span columns above the cells. */
.booking-week {
  --booking-name-width: 12rem;
  border: 1px solid var(--cosmos-border);
  border-radius: 6px;
  background: var(--cosmos-surface);
  overflow-x: auto;
}

.booking-week-row {
  display: grid;
  grid-template-columns: var(--booking-name-width) repeat(7, minmax(0, 1fr));
  min-width: 62rem;
  border-bottom: 1px solid var(--cosmos-border);
}

.booking-week-row:last-child {
  border-bottom: 0;
}

.booking-week-head {
  background: var(--cosmos-surface-raised);
  border-bottom: 1px solid var(--cosmos-border-strong);
  color: var(--cosmos-fg-muted);
  font-size: 0.75rem;
}

.booking-week-day {
  padding: 0.3rem 0.4rem;
  border-left: 1px solid var(--cosmos-border);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.booking-week-day-label {
  color: var(--cosmos-fg);
  font-weight: 600;
}

.booking-week-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
}

.booking-week-name {
  display: flex;
}

.booking-week-name .booking-row-name {
  flex: 1;
}

.booking-today {
  background: var(--cosmos-brand-soft);
}

.booking-week-cell {
  position: relative;
  min-height: 5rem;
  border-left: 1px solid var(--cosmos-border);
}

.booking-week-free {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.booking-week-free:hover,
.booking-week-free:focus-visible {
  background: var(--cosmos-row-hover);
  outline: 2px solid var(--cosmos-focus-ring);
  outline-offset: -2px;
}

/* The content sits over the free-cell button but lets clicks through; only chips and "+N more" take them. */
.booking-week-content {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  height: 100%;
  padding: 0.9rem 0.25rem 0.25rem;
  box-sizing: border-box;
  pointer-events: none;
}

/* The band lanes' background: the day columns' lines and today's tint, under the bands. */
.booking-week-lane {
  border-left: 1px solid var(--cosmos-border);
}

.booking-chip {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0 0.3rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
  font-size: 12.5px;
  line-height: 1.5;
  border-radius: 4px;
  pointer-events: auto;
}

/* The defaults sit in :where() (specificity 0), as for the agenda items: the kind classes (.booking-mine, .booking-flagged, ...)
   must win over them whatever the source order. */
:where(.booking-chip) {
  border: 1px solid var(--cosmos-border-strong);
  background: var(--cosmos-surface-raised);
  color: var(--cosmos-fg);
}

button.booking-chip-open {
  cursor: pointer;
}

button.booking-chip-open:hover,
button.booking-chip-open:focus-visible {
  outline: 2px solid var(--cosmos-focus-ring);
}

.booking-chip-time {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.booking-more {
  align-self: flex-start;
  padding: 0;
  font-size: 12.5px;
  color: var(--cosmos-brand);
  text-decoration: underline;
  pointer-events: auto;
}

.booking-band {
  box-sizing: border-box;
  margin: 0.25rem 0.25rem 0;
  padding: 0 0.4rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
  font-size: 12.5px;
  line-height: 1.5;
  border-radius: 4px;
  z-index: 1;
}

:where(.booking-band) {
  border: 1px solid var(--cosmos-border-strong);
  background: var(--cosmos-surface-raised);
  color: var(--cosmos-fg);
}

button.booking-band-open {
  cursor: pointer;
}

button.booking-band-open:hover,
button.booking-band-open:focus-visible {
  outline: 2px solid var(--cosmos-focus-ring);
}

/* At the top of the cell, above the chips (board C). */
.booking-strip {
  position: absolute;
  left: 0.25rem;
  right: 0.25rem;
  top: 0.25rem;
  height: 8px;
  border-radius: 2px;
  background: var(--cosmos-border);
  overflow: hidden;
  pointer-events: auto;
}

.booking-strip-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--seg-left);
  width: var(--seg-width);
  min-width: 2px;
  border: 0;
  border-radius: 0;
}

.booking-strip .booking-other {
  background: var(--cosmos-brand);
}

/* Mine is also marked by shape, a foreground line along the top edge: brand and accent differ by hue only. */
.booking-strip .booking-mine {
  background: var(--cosmos-accent);
  box-shadow: inset 0 2px 0 var(--cosmos-fg);
}

.booking-strip .booking-occupied {
  background: var(--cosmos-fg-muted);
}

/* Warn darkened toward the foreground: the plain token is 2.39:1 on the Light strip ground, this is 4.06:1 or more in all three themes. */
.booking-strip .booking-flagged {
  background: color-mix(in srgb, var(--cosmos-status-warn) 70%, var(--cosmos-fg));
}

.booking-strip .booking-block {
  background: repeating-linear-gradient(135deg, var(--cosmos-status-bad) 0 2px, var(--cosmos-status-bad-soft) 2px 4px);
}

.booking-strip .booking-downtime {
  background: repeating-linear-gradient(135deg, var(--cosmos-status-info) 0 2px, var(--cosmos-status-info-soft) 2px 4px);
}

.booking-strip-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--seg-left);
  width: 1px;
  background: var(--cosmos-surface);
  opacity: 0.8;
}

/* Legend */
.booking-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--cosmos-fg-muted);
}

.booking-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.booking-legend-swatch {
  display: inline-block;
  width: 1.1rem;
  height: 0.7rem;
  border-radius: 2px;
}

:where(.booking-legend-swatch) {
  border: 1px solid var(--cosmos-border-strong);
}

.booking-legend-now {
  display: inline-block;
  width: 2px;
  height: 0.9rem;
  background: var(--cosmos-fg);
}

.booking-legend-dot {
  display: inline-block;
  box-sizing: border-box;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cosmos-accent);
  border: 2px solid var(--cosmos-fg);
}

.booking-legend-outline {
  background: transparent;
  border: 2px solid var(--cosmos-fg);
  box-shadow: inset 0 0 0 1px var(--cosmos-status-warn);
}

.booking-legend-stripes {
  background: repeating-linear-gradient(135deg, var(--cosmos-status-info) 0 2px, var(--cosmos-status-info-soft) 2px 4px);
}

.booking-legend-underline {
  text-decoration: underline;
  text-decoration-color: var(--cosmos-status-bad);
  text-decoration-thickness: 2px;
}

/* Month view: one grid per resource, a name column and one column per day; time-slot days are shaded buttons. */
.booking-month {
  --booking-name-width: 12rem;
  /* The nights rows are a TimelineTrack, which takes its height and bar positions from this. */
  --booking-lane-height: 1.75rem;
  border: 1px solid var(--cosmos-border);
  border-radius: 6px;
  background: var(--cosmos-surface);
  overflow-x: auto;
}

/* The shading steps, defined once for the grid and the legend (both sit inside the wrap). */
.booking-timeline-wrap {
  --booking-step-0: var(--cosmos-surface);
  --booking-step-1: color-mix(in srgb, var(--cosmos-brand-muted) 15%, var(--cosmos-surface));
  --booking-step-2: color-mix(in srgb, var(--cosmos-brand-muted) 35%, var(--cosmos-surface));
  --booking-step-3: color-mix(in srgb, var(--cosmos-brand-muted) 55%, var(--cosmos-surface));
  --booking-step-4: color-mix(in srgb, var(--cosmos-brand-muted) 75%, var(--cosmos-surface));
}

.booking-month-row {
  display: grid;
  grid-template-columns: var(--booking-name-width) repeat(var(--cols), minmax(1.6rem, 1fr));
  min-width: 62rem;
  border-bottom: 1px solid var(--cosmos-border);
}

.booking-month-row:last-child {
  border-bottom: 0;
}

.booking-month-head {
  background: var(--cosmos-surface-raised);
  border-bottom: 1px solid var(--cosmos-border-strong);
  color: var(--cosmos-fg-muted);
  font-size: 0.75rem;
}

.booking-month-head > .booking-row-name {
  color: var(--cosmos-fg-muted);
}

.booking-month-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.25rem 0;
  border-left: 1px solid var(--cosmos-border);
}

.booking-month-daynumber {
  color: var(--cosmos-fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* In the body today is two lines down its column, never a fill: a fill means hours booked, and the today tint
   matched the "under 3 h" step in all three themes. Before the weekend rule, so a weekend today keeps its tint. */
.booking-month-slot.booking-today,
.booking-month-track .booking-cell.booking-today {
  position: relative;
  background: transparent;
}

.booking-month-slot.booking-today::after,
.booking-month-track .booking-cell.booking-today::after {
  content: "";
  position: absolute;
  inset: 0;
  border-left: 2px solid var(--cosmos-brand);
  border-right: 2px solid var(--cosmos-brand);
  pointer-events: none;
  z-index: 1;
}

.booking-month-day.booking-weekend,
.booking-month-slot.booking-weekend,
.booking-month-track .booking-cell.booking-weekend {
  background: var(--cosmos-canvas);
}

.booking-month-day.booking-monday,
.booking-month-slot.booking-monday,
.booking-month-track .booking-cell.booking-monday {
  border-left: 2px solid var(--cosmos-border-strong);
}

.booking-month-day.booking-today {
  background: var(--cosmos-brand-soft);
}

.booking-month-name {
  display: flex;
}

.booking-month-name .booking-row-name {
  flex: 1;
}

.booking-month-slot {
  border-left: 1px solid var(--cosmos-border);
  display: flex;
}

.booking-month-track {
  grid-column: 2 / -1;
  min-width: 0;
}

.booking-month-cell {
  position: relative;
  flex: 1;
  min-height: 2.6rem;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--cosmos-fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

/* Step 0 stays transparent so the weekend and today tints of the day show through. */
.booking-month-cell.booking-step-0 { background: transparent; }
.booking-month-cell.booking-step-1 { background: var(--booking-step-1); }
.booking-month-cell.booking-step-2 { background: var(--booking-step-2); }
.booking-month-cell.booking-step-3 { background: var(--booking-step-3); }
.booking-month-cell.booking-step-4 { background: var(--booking-step-4); }

.booking-month-cell:hover,
.booking-month-cell:focus-visible {
  outline: 2px solid var(--cosmos-focus-ring);
  outline-offset: -2px;
}

.booking-month-flagged {
  /* The outer ring is the foreground colour (3:1 on every step); the warn ring inside names the cause. */
  box-shadow: inset 0 0 0 2px var(--cosmos-fg), inset 0 0 0 4px var(--cosmos-status-warn);
}

/* Planned downtime is an edge treatment, a hatched band along the top: never a fill under the count. */
.booking-month-downtime::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: repeating-linear-gradient(135deg, var(--cosmos-status-info) 0 2px, var(--cosmos-status-info-soft) 2px 4px);
  pointer-events: none;
}

.booking-month-block::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--cosmos-status-bad);
  pointer-events: none;
}

/* On a flagged cell the underline sits inside the two rings, where they do not swallow it. */
.booking-month-flagged.booking-month-block::after {
  left: 4px;
  right: 4px;
  bottom: 4px;
}

.booking-month-mine {
  position: absolute;
  right: 5px;
  bottom: 6px;
  width: 9px;
  height: 9px;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--cosmos-accent);
  border: 2px solid var(--cosmos-fg);
  pointer-events: none;
}

/* Legend swatches take the same step variables as the grid. */
.booking-legend .booking-step-0 { background: var(--booking-step-0); }
.booking-legend .booking-step-1 { background: var(--booking-step-1); }
.booking-legend .booking-step-2 { background: var(--booking-step-2); }
.booking-legend .booking-step-3 { background: var(--booking-step-3); }
.booking-legend .booking-step-4 { background: var(--booking-step-4); }
