/* ═══════════════════════════════════════════════════════════════════════════
   Daily Schedule Tool — SHARED styles for BOTH floor surfaces:
     public/daily-schedule.html        (view-only)
     public/daily-schedule-setup.html  (PIN'd setup surface — Phase 2)
   Any change here applies to BOTH pages by design.
   Light mode, mobile-first — it replaces a paper schedule.
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* The hidden attribute must ALWAYS win. Without this, any class that sets its
   own display (e.g. .ds-sheet-backdrop { display:flex }) overrides the
   browser's built-in [hidden]{display:none} and the element can never be
   hidden from JS — the exact bug that shipped the picker sheet stuck open. */
[hidden] { display: none !important; }

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e3e5e9;
  --text: #1d1f23;
  --muted: #6b7079;
  --accent: #D94F2B;
  --red: #DC2626;
  --yellow: #F59E0B;
  --green: #16A34A;
  --complete: #2563EB;   /* Run Complete — blue, deliberately NOT a stoplight color */
  --pressed: #eef0f3;
}

/* Dark mode — Merit IQ dashboard palette; toggled by the header button
   (body.ds-dark, persisted in localStorage 'daily-schedule-color-mode'). */
body.ds-dark {
  --bg: #141414;
  --surface: #1e1e1e;
  --border: #2a2a2a;
  --text: #f2f2f2;
  --muted: #9a9a9a;
  --pressed: #27272b;
}
body.ds-dark .ds-dot { border-color: rgba(255, 255, 255, 0.12); }
body.ds-dark .ds-hint { background: #2b1c12; border-color: #4A1B0C; color: #F0997B; }
body.ds-dark .ds-note { background: #2b2413; }
body.ds-dark .banner-error { background: #2b1512; border-color: #5c221b; color: #F0997B; }
body.ds-dark .banner-warn { background: #2b2413; border-color: #5a4a1a; color: #e8c987; }
body.ds-dark .mode-view { background: #26262a; }

html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Inter', system-ui, sans-serif; font-size: 16px; line-height: 1.4;
  min-height: 100vh; padding-bottom: 48px;
}
#app { max-width: 640px; margin: 0 auto; padding: 0 14px; }

/* ── Header ────────────────────────────────────────────────────────────── */
.ds-header { padding: 18px 0 4px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
/* Merit IQ wordmark — matches the dashboard header ("Merit" bold, "IQ" light orange) */
.ds-brand { font-family: 'Inter', sans-serif; font-size: 21px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.ds-brand span { color: #FF6535; font-weight: 300; }
.ds-title { font-size: 20px; font-weight: 700; margin-top: 8px; line-height: 1.25; }
.ds-theme-btn {
  flex: 0 0 auto; width: 42px; height: 42px; margin-top: 2px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  display: inline-flex; align-items: center; justify-content: center;
}
.ds-theme-btn:active { background: var(--pressed); }

/* ── Tap hint (setup surface, dismissible) ─────────────────────────────── */
.ds-hint {
  display: flex; align-items: center; gap: 9px; margin: 10px 0 2px;
  background: #FFF3ED; border: 1px solid #F0997B; color: #712B13;
  font-size: 13.5px; padding: 10px 12px; border-radius: 10px;
}
.ds-hint span { flex: 1; }
.ds-hint-x {
  flex: 0 0 auto; border: none; background: none; color: inherit; opacity: 0.6;
  font-size: 14px; padding: 4px 6px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.ds-mode-chip {
  display: inline-block; vertical-align: 3px; margin-left: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
}
.mode-view { background: #e7e9ee; color: var(--muted); border: 1px solid var(--border); }
.mode-setup { background: var(--accent); color: #fff; }

/* Divider above the grouped idle lines */
.ds-divider {
  display: flex; align-items: center; gap: 10px; margin: 18px 2px 10px;
  color: var(--muted); font-size: 11px; font-weight: 700;
  letter-spacing: 0.10em; text-transform: uppercase; white-space: nowrap;
}
.ds-divider::before, .ds-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Date/shift navigation ─────────────────────────────────────────────── */
.ds-nav { display: flex; gap: 8px; margin: 14px 0 10px; }
.ds-arrow {
  flex: 0 0 56px; min-height: 60px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 28px; line-height: 1; border-radius: 10px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ds-arrow:active { background: var(--pressed); }
.ds-slot {
  flex: 1; min-height: 60px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: 'Inter', sans-serif; color: var(--text);
}
.ds-slot:active { background: var(--pressed); }
.ds-slot-date { font-size: 17px; font-weight: 700; }
.ds-slot-date em {
  font-style: normal; font-size: 11px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.08em; margin-left: 4px;
}
.ds-slot-shift { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.10em; }

/* ── Filter chips ──────────────────────────────────────────────────────── */
.ds-filters { display: flex; gap: 8px; margin-bottom: 12px; }
.ds-chip {
  flex: 1; min-height: 42px; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600;
  border-radius: 999px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.ds-chip b { font-weight: 700; margin-left: 2px; }
.ds-chip.active { color: #fff; border-color: transparent; }
.ds-chip.active.chip-all { background: var(--text); color: var(--bg); }
.ds-chip.active.chip-red { background: var(--red); }
.ds-chip.active.chip-yellow { background: var(--yellow); }
.ds-chip.active.chip-green { background: var(--green); }
.ds-chip.active.chip-complete { background: var(--complete); }

/* ── Collapsible color key (view-only floor schedule) ───────────────────── */
.ds-color-key {
  margin: -2px 0 12px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 12px; overflow: hidden;
}
.ds-color-key summary {
  list-style: none; cursor: pointer; min-height: 42px; padding: 0 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  color: var(--text); -webkit-tap-highlight-color: transparent;
}
.ds-color-key summary::-webkit-details-marker { display: none; }
.ds-color-key summary span { font-size: 13px; font-weight: 700; }
.ds-color-key summary b { font-size: 11px; color: var(--muted); font-weight: 600; }
.ds-color-key summary::after {
  content: '\25BE'; color: var(--muted); font-size: 13px; transition: transform 0.16s ease;
}
.ds-color-key[open] summary { border-bottom: 1px solid var(--border); }
.ds-color-key[open] summary::after { transform: rotate(180deg); }
.ds-key-grid {
  display: grid; grid-template-columns: 1fr; gap: 9px; padding: 11px 12px 12px;
}
.ds-key-item { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--muted); font-size: 12.5px; }
.ds-key-item span { display: flex; flex-direction: column; min-width: 0; }
.ds-key-item b { color: var(--text); font-size: 12.5px; line-height: 1.15; }
@media (min-width: 520px) {
  .ds-key-grid { grid-template-columns: 1fr 1fr; }
}
/* View-only floor page: the collapsed Color key bar gets a deep-purple fill
   with white text so it stands out from the white line cards. Only the bar
   (summary) is recolored — the expanded legend body keeps the surface color. */
body.ds-viewonly .ds-color-key summary { background: #5B21B6; color: #fff; }
body.ds-viewonly .ds-color-key summary b { color: rgba(255,255,255,0.9); font-size: 13px; }
body.ds-viewonly .ds-color-key summary::after { color: #fff; }
body.ds-viewonly .ds-color-key[open] summary { border-bottom-color: rgba(255,255,255,0.25); }

/* ── Banners / empty / footer ──────────────────────────────────────────── */
.ds-banner { border-radius: 10px; padding: 12px 14px; font-size: 14px; margin-bottom: 12px; }
.banner-error { background: #FDECEA; border: 1px solid #F5C6C0; color: #8C2318; }
.banner-warn { background: #FFF7E6; border: 1px solid #F5DFAE; color: #7A5A0F; }
.ds-empty { text-align: center; color: var(--muted); padding: 42px 10px; font-size: 15px; }
.ds-foot { text-align: center; color: var(--muted); font-size: 12px; padding-top: 16px; }

/* ── Line cards ────────────────────────────────────────────────────────── */
.ds-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px;
}
.ds-line {
  font-family: 'Bebas Neue', sans-serif; font-size: 21px; letter-spacing: 0.06em;
  color: var(--accent); padding-bottom: 6px; border-bottom: 1px solid var(--border);
  margin-bottom: 8px; font-weight: 400;
}
/* View-only floor page only (body.ds-viewonly, set by daily-schedule-core.js):
   line names stay plain black (default text color) rather than the orange
   accent that Setup/Admin use. */
body.ds-viewonly .ds-line { color: var(--text); }
.ds-run { display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; }
.ds-run + .ds-run { border-top: 1px dashed var(--border); }
.ds-run-none { color: var(--muted); font-size: 14px; }
.ds-run-main { flex: 1; min-width: 0; }
.ds-product { font-size: 16px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.ds-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ds-note {
  margin-top: 6px; font-size: 13.5px; color: var(--text);
  background: #FFF7E6; border-left: 3px solid var(--yellow);
  padding: 6px 9px; border-radius: 0 8px 8px 0; overflow-wrap: anywhere;
}

/* ── Note editor (admin backend) ───────────────────────────────────────── */
.ds-noteedit { margin-top: 6px; }
.ds-note-btn {
  border: 1px dashed var(--border); background: none; color: var(--muted);
  font-family: 'Inter', sans-serif; font-size: 12.5px; font-weight: 600;
  border-radius: 8px; padding: 5px 10px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.ds-note-btn:hover { border-color: var(--accent); color: var(--accent); }
.ds-noteedit .ds-note + .ds-note-btn { margin-top: 6px; }
.ds-note-input {
  width: 100%; font-family: 'Inter', sans-serif; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; resize: vertical; min-height: 52px;
}
.ds-note-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217,79,43,0.14); }
.ds-note-actions { display: flex; gap: 8px; margin-top: 8px; }
.ds-note-save, .ds-note-cancel {
  border: 1px solid var(--border); font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600;
  border-radius: 8px; padding: 8px 14px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.ds-note-save { background: var(--accent); color: #fff; border-color: transparent; }
.ds-note-cancel { background: var(--surface); color: var(--muted); }

/* ── Stoplight dots ────────────────────────────────────────────────────── */
.ds-dot {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; margin-top: 2px;
  border: 2px solid rgba(0, 0, 0, 0.08);
}
.ds-dot.dot-sm { width: 14px; height: 14px; margin-top: 0; }
.dot-red { background: var(--red); }
.dot-yellow { background: var(--yellow); }
.dot-green { background: var(--green); }
.dot-complete { background: var(--complete); }
/* Option A (Callie, 2026-07-16): tappable lights are bigger, get a soft halo
   ring in their own color, and a chevron pip so they read as pressable. */
.dot-tap { cursor: pointer; position: relative; width: 34px; height: 34px; }
.dot-tap.dot-red    { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.16); }
.dot-tap.dot-yellow { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18); }
.dot-tap.dot-green  { box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.16); }
.dot-tap.dot-complete { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18); }
.dot-tap::after {
  content: '\25BE'; position: absolute; right: -9px; bottom: -4px;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  font-size: 10px; line-height: 15px; text-align: center;
}
.dot-tap:active { transform: scale(0.94); }

/* ── "Updated by" attribution line ─────────────────────────────────────── */
.ds-updated {
  display: flex; align-items: center; gap: 5px;
  margin-top: 6px; font-size: 12px; color: var(--muted);
}

/* ── Toast (save results) ──────────────────────────────────────────────── */
.ds-toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  max-width: 92vw; z-index: 60;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600;
  padding: 12px 18px; border-radius: 999px; box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}
.ds-toast.toast-error { background: var(--red); color: #fff; }
.ds-toast.toast-warn { background: #B45309; color: #fff; }
.ds-toast.toast-ok { background: var(--green); color: #fff; }

/* ── Status picker sheet (setup surface) ───────────────────────────────── */
.ds-sheet-backdrop {
  position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.ds-sheet {
  width: 100%; max-width: 640px; background: var(--surface);
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.ds-sheet-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; overflow-wrap: anywhere; }
.ds-sheet-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-family: 'Inter', sans-serif; font-size: 15px; font-weight: 600; text-align: left;
  border-radius: 12px; padding: 0 14px; margin-bottom: 8px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ds-sheet-btn:active { background: var(--pressed); }
.ds-sheet-btn .ds-dot { margin-top: 0; }
.ds-sheet-cancel { justify-content: center; color: var(--muted); margin-bottom: 0; }

/* ── PIN gate (setup surface) ──────────────────────────────────────────── */
.ds-pin-wrap { max-width: 360px; margin: 8vh auto 0; text-align: center; padding: 0 16px; }
.ds-pin-title { font-size: 18px; font-weight: 700; margin: 18px 0 6px; }
.ds-pin-sub { font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.ds-pin-input {
  width: 100%; text-align: center; letter-spacing: 0.6em; font-size: 28px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 0 14px 0.6em; min-height: 64px; font-family: 'Inter', sans-serif; color: var(--text);
  -webkit-appearance: none; appearance: none;
}
.ds-pin-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217,79,43,0.14); }
.ds-pin-msg { min-height: 22px; font-size: 14px; color: var(--red); margin-top: 12px; font-weight: 600; }
.ds-userbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; margin: 0 0 12px; font-size: 13px;
}
.ds-userbar b { font-weight: 700; }
.ds-userbar button {
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 600;
  border-radius: 8px; padding: 7px 12px; cursor: pointer;
}

/* ── Up Next row ───────────────────────────────────────────────────────── */
.ds-upnext {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  padding: 8px 10px; background: var(--bg); border-radius: 8px; min-width: 0;
}
.ds-upnext-tag {
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.09em; flex: 0 0 auto;
}
.ds-upnext-product {
  flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ds-upnext-when { flex: 0 0 auto; font-size: 12px; color: var(--muted); }
