/* As-Run page. Builds on style.css and schedule.css (layout, cards, tool buttons). */

body.asrun-page {
  --ar-ok: rgba(16, 185, 129, 0.42);
  --ar-maintenance: rgba(234, 179, 8, 0.55);
  --ar-down: rgba(239, 68, 68, 0.55);
  --ar-live: rgba(59, 130, 246, 0.5);
  --ar-base: rgba(148, 163, 184, 0.14);
  --ar-border: rgba(148, 163, 184, 0.22);
}

/* Range controls */
.asrun-range {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-top: 16px;
}
.asrun-range label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 0;
}
.asrun-range input,
.asrun-range select {
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  max-width: 100%;
}
.asrun-zone-label { flex: 1 1 240px; }
.asrun-zone-label select { width: 100%; }
.asrun-range-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.asrun-show { padding: 7px 16px; }

/* Legend */
.asrun-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-secondary);
}
.asrun-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 18px; height: 10px; border-radius: 3px; border: 1px solid var(--ar-border); }
.sw.ok { background: var(--ar-ok); }
.sw.maintenance { background: var(--ar-maintenance); }
.sw.down { background: var(--ar-down); }
.sw.live { background: var(--ar-live); }
.sw.future { background: var(--ar-base); }

/* The list: one day heading per day, chips under it; the list scrolls on its own */
.asrun-chips {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 4px;
}
.asrun-day {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 10px 0 4px;
  padding: 4px 2px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: #0f1624;
}
.asrun-day:first-child { margin-top: 0; }

/* A chip: start left, file name centred (shrunk to fit), end right, over a fill painted by status */
.chip {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid var(--ar-border);
  border-radius: 6px;
  background: var(--ar-base);
  overflow: hidden;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.chip:focus-visible { outline: 2px solid var(--accent-purple); outline-offset: 1px; }
.chip-fill { position: absolute; inset: 0; pointer-events: none; }
.chip > span { position: relative; z-index: 1; }
.chip-start, .chip-end { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-secondary); }
.chip.state-onair .chip-start, .chip.state-onair .chip-end,
.chip.state-done .chip-start, .chip.state-done .chip-end { color: var(--text-primary); }
.chip-name {
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.chip.state-future .chip-name { font-weight: 400; color: var(--text-secondary); }
.chip.state-onair { border-color: rgba(16, 185, 129, 0.7); box-shadow: 0 0 10px rgba(16, 185, 129, 0.25); }

/* Detail under a chip (click to open) */
.chip-detail {
  margin: 0 0 6px;
  padding: 10px 12px;
  border: 1px solid var(--ar-border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  font-size: 12px;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.chip-detail dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0 0 8px; }
.chip-detail dt { color: var(--text-secondary); }
.chip-detail dd { margin: 0; color: var(--text-primary); }
.chip-detail ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.chip-detail time { font-variant-numeric: tabular-nums; color: var(--text-primary); margin-right: 8px; }
.chip-detail .issue { color: #fca5a5; }

@media (max-width: 600px) {
  .chip { gap: 8px; padding: 0 8px; font-size: 12px; }
  .asrun-range label { flex: 1 1 100%; }
}
