/* The admin's Schedule — a week of planned shifts, day by day — and the
   Plan a shift form. Design: "Schedule page" and "Plan a shift" frames,
   approved 2026-10-19. */

:root {
  --schedule-ink: #1f2a37;
  --schedule-muted: #6b7280;
  --schedule-faint: #8b8f96;
  --schedule-line: #ece7df;
  --schedule-edge: #e2ddd5;
  --schedule-green: #2f7a4f;
  --schedule-red: #b91c1c;
  --schedule-amber: #a16207;
  --schedule-open-wash: #fadcdc;
  --schedule-open-dot: #e03e3e;
  --schedule-unplanned-wash: #f8ecd1;
  --schedule-unplanned-dot: #e0a526;
}

/* ---- Page shell ---------------------------------------------------- */

.schedule-page__back {
  margin-bottom: 1rem;
}

.schedule-page__header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 768px) {
  .schedule-page__header {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}

.schedule-page__title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--schedule-ink);
}
@media (min-width: 768px) {
  .schedule-page__title { font-size: 2rem; }
}

.schedule-page__subtitle {
  margin-top: 0.25rem;
  color: var(--schedule-muted);
}

.schedule-page__controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
@media (min-width: 768px) {
  .schedule-page__controls {
    flex-direction: row;
    align-items: center;
  }
}

/* The week switcher: ‹ Week of Oct 13 – 19 › in one bordered box. */
.schedule-week {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 2.5rem;
  background: #fff;
  border: 1px solid var(--schedule-edge);
  border-radius: 0.5rem;
}
.schedule-week__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 100%;
  color: var(--schedule-ink);
}
.schedule-week__arrow:hover { color: var(--schedule-green); }
.schedule-week__title {
  padding: 0 0.5rem;
  font-weight: 600;
  color: var(--schedule-ink);
  white-space: nowrap;
}

.schedule-page__today {
  background: #fff;
  border: 1px solid var(--schedule-edge);
  color: var(--schedule-ink);
}

/* On a phone: the title, then the week switcher, then the green button,
   each the full width. The Back link, the grey line and Today wait for a
   wider screen. */
@media (max-width: 767px) {
  .schedule-page__back,
  .schedule-page__subtitle,
  .schedule-page__today { display: none; }
}

/* ---- The week's card ----------------------------------------------- */

.schedule-card {
  background: #fff;
  border: 1px solid var(--schedule-edge);
  border-radius: 0.75rem;
  padding: 0 1.5rem 1.5rem;
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--schedule-ink);
}
.schedule-table th {
  text-align: left;
}
.schedule-table th,
.schedule-table td {
  vertical-align: middle;
}
.schedule-table thead th {
  padding: 1.25rem 0 0.875rem;
  border-bottom: 1px solid var(--schedule-line);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--schedule-faint);
}
.schedule-table th.schedule-table__status { text-align: right; }

/* Each day's heading: 36px above, 12px below. */
.schedule-day__heading th {
  padding: 2.25rem 0 0.75rem;
}
.schedule-day__heading h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--schedule-ink);
}
.schedule-day__count {
  margin-left: 0.5rem;
  font-weight: 400;
  color: var(--schedule-muted);
}
.schedule-day__weekday--narrow { display: none; }

.schedule-day__empty td {
  padding: 0.5rem 0 0.75rem;
  color: var(--schedule-faint);
}

/* A row of the day. */
.schedule-row > td {
  padding: 0.875rem 0.75rem 0.875rem 0;
  border-bottom: 1px solid var(--schedule-line);
  font-size: 0.9375rem;
}
.schedule-row > td:last-child { padding-right: 0; }
.schedule-row__time { color: var(--schedule-muted); white-space: nowrap; }
.schedule-row__client { font-weight: 600; white-space: nowrap; }
.schedule-row__dsp { color: #4b5563; white-space: nowrap; }
.schedule-row__planned { font-weight: 600; font-variant-numeric: tabular-nums; }
.schedule-row__planned--none { color: var(--schedule-muted); }
.schedule-row__status { text-align: right; white-space: nowrap; }
.schedule-row__edit { text-align: right; width: 1.5rem; }
.schedule-time--narrow { display: none; }

.schedule-row__pencil {
  display: inline-flex;
  color: #9ca3af;
}
.schedule-row__pencil svg { width: 1.125rem; height: 1.125rem; }
.schedule-row__pencil:hover { color: var(--schedule-ink); }

/* An open shift (no DSP yet) is washed red with a red dot before the
   client; a clock-in nobody planned is washed amber with an amber dot. They
   are the two rows the office is looking for. */
.schedule-row--open > td { background: var(--schedule-open-wash); border-bottom-color: transparent; }
.schedule-row--not-planned > td { background: var(--schedule-unplanned-wash); border-bottom-color: transparent; }
.schedule-row--open > td:first-child,
.schedule-row--not-planned > td:first-child { border-radius: 0.5rem 0 0 0.5rem; }
.schedule-row--open > td:last-child,
.schedule-row--not-planned > td:last-child { border-radius: 0 0.5rem 0.5rem 0; }
.schedule-row--open > td,
.schedule-row--not-planned > td { padding-left: 0; }
.schedule-row--open .schedule-row__client::before,
.schedule-row--not-planned .schedule-row__client::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.625rem;
  border-radius: 9999px;
  vertical-align: middle;
  background: var(--schedule-open-dot);
}
.schedule-row--not-planned .schedule-row__client::before { background: var(--schedule-unplanned-dot); }

.schedule-row__no-dsp {
  display: none;
  color: var(--schedule-red);
  font-weight: 600;
}
.schedule-row__picker {
  background-color: #fff;
  min-width: 14rem;
}
.schedule-row__assign { display: inline; }

/* Status words, in the dashboard's colours. */
.schedule-status { font-weight: 600; }
.schedule-status--done,
.schedule-status--planned,
.schedule-status--not-covered,
.schedule-status--starts-today { font-weight: 400; color: var(--schedule-muted); }
.schedule-status--in-progress { color: var(--schedule-green); }
.schedule-status--ended-early,
.schedule-status--note-missing,
.schedule-status--late,
.schedule-status--not-planned { color: var(--schedule-amber); }
.schedule-status--never-clocked-in { color: var(--schedule-red); }

/* "+N more sessions this day", centred and green. */
.schedule-day__more td {
  padding: 1rem 0 0.25rem;
  text-align: center;
}
.schedule-day__toggle {
  font-weight: 600;
  color: var(--schedule-green);
  cursor: pointer;
}
.schedule-day__toggle:hover { text-decoration: underline; }
.schedule-table tr[hidden] { display: none !important; }

/* ---- The week on a phone ------------------------------------------- */

@media (max-width: 639px) {
  .schedule-card { padding: 0 1rem 1rem; }
  .schedule-table thead { display: none; }
  .schedule-table tbody,
  .schedule-table tr,
  .schedule-table th,
  .schedule-table td { display: block; }

  .schedule-day__heading th { padding: 1.5rem 0 0.5rem; }
  .schedule-day__heading h2 { font-size: 0.8125rem; }
  .schedule-day__weekday--wide { display: none; }
  .schedule-day__weekday--narrow { display: inline; }

  /* Client and the pencil on the first line, then the time, the DSP, and the
     type pill left with the status right. The planned column waits for a
     wider screen. */
  .schedule-table .schedule-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "client edit"
      "time time"
      "dsp dsp"
      "type status";
    row-gap: 0.25rem;
    align-items: center;
    padding: 0.75rem 0;
  }
  .schedule-row > td {
    padding: 0;
    border-bottom: 0;
    background: none;
  }
  .schedule-row__client { grid-area: client; }
  .schedule-row__edit { grid-area: edit; width: auto; }
  .schedule-row__time { grid-area: time; }
  .schedule-row__dsp { grid-area: dsp; white-space: normal; }
  .schedule-row__type { grid-area: type; margin-top: 0.25rem; }
  .schedule-row__status { grid-area: status; margin-top: 0.25rem; font-size: 0.875rem; }
  .schedule-table .schedule-row__planned { display: none; }
  .schedule-time--wide { display: none; }
  .schedule-time--narrow { display: inline; }

  .schedule-row--open,
  .schedule-row--not-planned {
    padding: 0.75rem;
    border-radius: 0.5rem;
  }
  .schedule-row--open { background: var(--schedule-open-wash); }
  .schedule-row--not-planned { background: var(--schedule-unplanned-wash); }
  .schedule-row--open > td:first-child,
  .schedule-row--not-planned > td:first-child,
  .schedule-row--open > td:last-child,
  .schedule-row--not-planned > td:last-child { border-radius: 0; }

  .schedule-row__no-dsp { display: block; }
  .schedule-row__picker { width: 100%; min-width: 0; margin-top: 0.375rem; }

  .schedule-day__more td { padding: 0.75rem 0 0.5rem; }
}

/* ---- Plan a shift / Edit shift ------------------------------------- */

.plan-shift-page__heading { margin-bottom: 1.5rem; }
.plan-shift-page__back {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-weight: 600;
  color: var(--schedule-green);
}
.plan-shift-page__title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--schedule-ink);
}
@media (min-width: 768px) {
  .plan-shift-page__title { font-size: 2rem; }
}
.plan-shift-page__subtitle {
  margin-top: 0.25rem;
  color: var(--schedule-muted);
}

/* A 640px white card, left-aligned. */
.plan-shift-card {
  max-width: 40rem;
  background: #fff;
  border: 1px solid var(--schedule-edge);
  border-radius: 0.75rem;
  padding: 1.5rem;
}
@media (min-width: 768px) {
  .plan-shift-card { padding: 2rem; }
}

.plan-shift { display: flex; flex-direction: column; gap: 1.25rem; }
.plan-shift__field { display: flex; flex-direction: column; }
.plan-shift__label {
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--schedule-ink);
}
.plan-shift__hint {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--schedule-faint);
}

/* Date | Start | End on one row; Date, then Start | End, on a phone. */
.plan-shift__when {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.plan-shift__field--date { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .plan-shift__when { grid-template-columns: 1fr 1fr 1fr; }
  .plan-shift__field--date { grid-column: auto; }
}

/* The session type as three pills; the chosen one is green. */
.plan-shift__types { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.plan-shift__type {
  display: inline-flex;
  align-items: center;
  padding: 0.625rem 1.25rem;
  border: 1px solid var(--schedule-edge);
  border-radius: 9999px;
  font-weight: 600;
  color: #4b5563;
  cursor: pointer;
}
.plan-shift__type:has(:checked) {
  border-color: var(--schedule-green);
  background: #eaf4ee;
  color: var(--schedule-green);
}
.plan-shift__type:has(:focus-visible) { outline: 2px solid var(--schedule-green); outline-offset: 2px; }
.plan-shift__hours {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--schedule-faint);
}
.plan-shift__hours:empty { display: none; }

.plan-shift__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}
.plan-shift__delete-form { margin-left: auto; }
.plan-shift__delete {
  font-weight: 600;
  color: var(--schedule-red);
  cursor: pointer;
}
.plan-shift__delete:hover { text-decoration: underline; }

/* On a phone the green button fills the width, with Cancel centred under it
   and the delete under that. */
@media (max-width: 639px) {
  .plan-shift-page__subtitle-lead { display: none; }
  .plan-shift__hint { display: none; }
  .plan-shift__actions { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .plan-shift__save { width: 100%; }
  .plan-shift__cancel { width: 100%; }
  .plan-shift__delete-form { margin: 0.5rem 0 0; text-align: center; }
}
