/* ==========================================================================
   Scheduled reports
   The list of schedules, the form that sets one up, and a schedule's run
   history. Every class here starts sch, so nothing on another page can match
   it. Widths are never fixed: everything wraps from 1920 down to 320.
   ========================================================================== */

/* --- the list ------------------------------------------------------------- */

.sch-name { font-weight: var(--fw-semibold); color: var(--txt); overflow-wrap: anywhere; }

.sch-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.sch-meta {
  font-size: var(--fs-sm);
  color: var(--txt-3);
  overflow-wrap: anywhere;
}

.sch-strong { color: var(--txt-2); font-weight: var(--fw-medium); }

.sch-channels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: var(--fs-sm);
  color: var(--txt-2);
}

.sch-channel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.sch-channel svg { width: 14px; height: 14px; flex: none; color: var(--txt-3); }

.sch-problem {
  font-size: var(--fs-sm);
  color: var(--bad-fg);
  overflow-wrap: anywhere;
}

.sch-late {
  font-size: var(--fs-xs);
  color: var(--warn-fg);
}

/* --- the form ------------------------------------------------------------- */

/* The sentence that sums the schedule up, and its next three times. Kept in
   sight while the form is long enough to scroll, on a screen tall enough to
   spare the room; on a phone it scrolls with the rest. */
.sch-summary {
  margin: 0 0 var(--sp-5);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: var(--r-md);
  background: var(--primary-soft);
}
.sch-summary__text { margin: 0; font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--txt); }
.sch-summary__next {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-sm);
  color: var(--txt-2);
}
.sch-summary__covers { margin: 4px 0 0; font-size: var(--fs-sm); color: var(--txt-3); }

@media (width > 620px) and (height > 760px) {
  .sch-summary { position: sticky; top: calc(-1 * var(--sp-5)); z-index: 2; }
}

/* The weekdays, as a row of toggles that wraps on a phone. */
.sch-days {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sch-day {
  min-width: 46px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--txt-2);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.sch-day.is-on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-soft-fg); font-weight: var(--fw-semibold); }
.sch-day:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }

.sch-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* Two or three choices side by side that wrap: the formats, the channels. */
.sch-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--sp-5);
}

/* Who it goes to: the people picked, each with the channels they get it on. */
.sch-people {
  display: flex;
  flex-direction: column;
  margin: 0 0 var(--sp-3);
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.sch-person {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 8px 10px 8px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.sch-person:last-child { border-bottom: 0; }
.sch-person__who {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 180px;
  min-width: 0;
}
.sch-person__name { font-weight: var(--fw-medium); color: var(--txt); overflow-wrap: anywhere; }
.sch-person__how {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 14px;
}
.sch-person__how .checkbox { min-height: 34px; }

/* The search that finds somebody to add, and what it found. */
.sch-find { position: relative; margin-bottom: var(--sp-3); }
.sch-found {
  display: flex;
  flex-direction: column;
  max-height: 260px;
  margin: 6px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.sch-found__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 6px 12px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--txt);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.sch-found__item:last-child { border-bottom: 0; }
.sch-found__item:hover, .sch-found__item:focus-visible { background: var(--surface-2); outline: none; }
.sch-found__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }

/* Somebody new, typed in without leaving the form. */
.sch-new {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin: 0 0 var(--sp-3);
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
}
/* Each box a visible label over it, side by side while both fit, one to a line after. */
.sch-new__field { display: flex; flex: 1 1 13rem; flex-direction: column; gap: 4px; min-width: 0; }
.sch-new__field .input { width: 100%; }
.sch-new__actions { display: flex; flex: 0 0 auto; gap: 8px; }
/* Its own line, and shown: a .field__error is hidden outside an invalid .field. */
.sch-new__error { display: block; width: 100%; margin: 0; font-size: var(--fs-sm); color: var(--bad-fg); overflow-wrap: anywhere; }
.sch-new__note { width: 100%; margin: 0; font-size: var(--fs-xs); color: var(--txt-3); }

/* Who will get it, and who will be skipped and why, before saving. */
.sch-audience { margin: 0 0 var(--sp-4); }
.sch-audience__title { margin: 0 0 4px; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--txt-2); }
.sch-audience__list { margin: 0; padding: 0 0 0 18px; font-size: var(--fs-sm); color: var(--txt-2); }
.sch-audience__list li { margin: 2px 0; overflow-wrap: anywhere; }
.sch-audience--skipped .sch-audience__title { color: var(--warn-fg); }

/* The placeholders a subject or message can use, and what each fills in. */
.sch-placeholders {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-xs);
  color: var(--txt-3);
}
.sch-placeholders code { font-family: var(--font-mono); color: var(--txt-2); }

/* A test, sent from the footer: who to, and how it went. */
.sch-test {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 0 0;
}
.sch-test .select-wrap { flex: 1 1 12rem; min-width: 0; }
.sch-test__result { width: 100%; margin: 0; padding: 0 0 0 18px; font-size: var(--fs-sm); color: var(--txt-2); }

/* --- the history ---------------------------------------------------------- */

.sch-runs { margin: 0; padding: 0; list-style: none; }
.sch-run {
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.sch-run:first-child { padding-top: 0; }
.sch-run:last-child { border-bottom: 0; }
.sch-run__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.sch-run__when { font-weight: var(--fw-semibold); color: var(--txt); }
.sch-run__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin: 4px 0 0;
  font-size: var(--fs-sm);
  color: var(--txt-3);
}
.sch-run__note { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--txt-2); overflow-wrap: anywhere; }
.sch-run__problem { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--bad-fg); overflow-wrap: anywhere; }

.sch-outcomes { margin: 8px 0 0; padding: 0; list-style: none; }
.sch-outcome {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  padding: 4px 0;
  font-size: var(--fs-sm);
  color: var(--txt-2);
}
.sch-outcome__who { font-weight: var(--fw-medium); color: var(--txt); overflow-wrap: anywhere; }
.sch-outcome__why { flex: 1 1 100%; color: var(--txt-3); overflow-wrap: anywhere; }

.sch-badge--ok      { background: var(--ok-bg);   color: var(--ok-fg); }
.sch-badge--bad     { background: var(--bad-bg);  color: var(--bad-fg); }
.sch-badge--warn    { background: var(--warn-bg); color: var(--warn-fg); }
.sch-badge--waiting { background: var(--mute-bg); color: var(--mute-fg); }
/* Left out on a channel only as a note: they got it another way, or are turned off on purpose. */
.sch-badge--muted   { background: transparent; color: var(--mute-fg); border: 1px dashed var(--line-strong); }

/* Under touch, the toggles keep the app's control height. */
@media (pointer: coarse) {
  .sch-day { height: 42px; min-width: 48px; }
  .sch-found__item { min-height: 46px; }
}
