/* ═══════════════════════════════════════════════════════════════
   Bread Run — Route Checklist
   style.css
   ─────────────────────────────────────────────────────────────
   Fonts:   Barlow Condensed (headings/UI), DM Mono (data/numbers)
   Palette: dark olive base · yellow-gold accent · green check
   ═══════════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ──────────────────────────────────────────── */
:root {
  --bg:         #1a1a18;
  --surface:    #252520;
  --border:     #3a3a32;
  --accent:     #e8c840;
  --accent-dim: #b09a28;
  --text:       #f0ede0;
  --muted:      #888878;
  --done-bg:    #1a3520;   /* dark green — checked order card background */
  --done-text:  #888878;
  --check:      #5abf6a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow Condensed', sans-serif;
  min-height: 100vh;
  overscroll-behavior: none; /* prevent rubber-band scroll revealing white behind header */
}

/* ── HEADER ─────────────────────────────────────────────────── */
header {
  background: var(--accent);
  color: #1a1a18;
  padding: 18px 20px 14px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  border-bottom: 3px solid #c8a820;
}

.logo-icon { font-size: 32px; line-height: 1; }

.header-text h1 {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
}

.header-text p {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  opacity: 0.65;
  text-transform: uppercase;
  font-family: 'DM Mono', monospace;
}

.header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.info-btn {
  background: rgba(0,0,0,0.10);
  border: 2px solid rgba(0,0,0,0.15);
  color: rgba(26,26,24,0.70);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.info-btn:active { background: rgba(0,0,0,0.25); }

.refresh-btn {
  background: rgba(0, 0, 0, 0.15);
  border: 2px solid rgba(0, 0, 0, 0.2);
  color: #1a1a18;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 16px;
  border-radius: 3px;
  cursor: pointer;
  min-width: 44px;   /* comfortable touch target */
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.refresh-btn:active { background: rgba(0, 0, 0, 0.3); }

/* Missing items icon button — always visible on mobile */
.missing-icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(191, 64, 64, 0.2);
  border: 2px solid #7a3030;
  color: #e07070;
  font-family: 'DM Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  border-radius: 3px;
  text-decoration: none;
  flex-shrink: 0;
}
.missing-icon-btn:active { background: rgba(191, 64, 64, 0.4); }

/* ── ROUTE SELECTOR ─────────────────────────────────────────── */
.route-selector {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.route-selector label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
}

select {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 12px 36px 12px 14px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888878' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  min-height: 48px;  /* comfortable touch target */
}
select:focus { outline: none; border-color: var(--accent); }

/* ── STATS BAR ──────────────────────────────────────────────── */
.stats-bar {
  padding: 10px 20px;
  display: flex;
  gap: 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
}

.stat { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.stat strong { color: var(--text); font-size: 14px; }
.stat-divider { color: var(--border); }
.stat.completed strong { color: var(--check); }

/* ── SORTING STAGE (SUMMARY BOX) ────────────────────────────── */
.summary-box {
  background: var(--surface);
  border-bottom: 3px solid var(--accent);
  overflow: hidden;
}

.summary-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
  background: #2a2a20;
  min-height: 48px;
}
.summary-toggle:active { background: #303028; }

.summary-toggle-left { display: flex; align-items: center; gap: 10px; }

.summary-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: 'DM Mono', monospace;
  color: var(--accent);
}

.summary-subtitle {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.summary-sort-btn {
  background: rgba(232,200,64,0.12);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 44px;
  min-width: 44px;
}
.summary-sort-btn:active {
  background: rgba(232,200,64,0.25);
}

.summary-chevron { color: var(--muted); font-size: 14px; transition: transform 0.2s; }
.summary-chevron.open { transform: rotate(180deg); }

.summary-items { padding: 8px 12px 12px; display: none; }
.summary-items.open { display: block; }

/* Each summary row — label wraps the entire row (full-width tap target) */
.summary-row { border-bottom: 1px solid var(--border); }
.summary-row:last-child { border-bottom: none; }

.summary-row label {
  display: flex;
  align-items: center;
  cursor: pointer;
  min-height: 52px;  /* large touch target */
}

.summary-checkbox-area {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.summary-label-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 10px 0;
  gap: 10px;
}

.summary-ware { font-size: 16px; font-weight: 600; letter-spacing: 0.02em; }
.summary-row.s-checked .summary-ware { color: var(--done-text); text-decoration: line-through; }

.summary-qty {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  background: #1a1a12;
  padding: 3px 10px;
  border-radius: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}
.summary-row.s-checked .summary-qty { color: var(--done-text); background: #222; }

/* ── SYNC OVERLAY — full-screen block during post-customer fetch ── */
.sync-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(26, 26, 24, 0.55);
  align-items: center;
  justify-content: center;
}
.sync-overlay.open { display: flex; }

.sync-label {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 4px;
}

/* ── CONTENT AREA ───────────────────────────────────────────── */
.content { padding: 14px 16px; max-width: 680px; margin: 0 auto; }

.placeholder { text-align: center; padding: 60px 20px; color: var(--muted); }
.placeholder .big { font-size: 64px; margin-bottom: 12px; }
.placeholder p { font-size: 16px; letter-spacing: 0.05em; text-transform: uppercase; }

/* ── CUSTOMER GROUP ─────────────────────────────────────────── */
.customer-group {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.customer-group.cg-done { border-color: #2a2a25; opacity: 0.7; }

.customer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #2e2e28;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.cg-done .customer-header { background: #222220; border-bottom-color: #2a2a25; }

.customer-name {
  font-size: 14px;   /* smaller to handle long all-caps names */
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1.3;
  flex: 1;
  min-width: 0;      /* allow wrapping for very long names */
}
.cg-done .customer-name { color: #555545; }

.customer-tally {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.customer-tally.tally-done { color: var(--check); background: #1a2a1a; }

/* ── CUSTOMER GROUP — IN PROGRESS ───────────────────────────── */
.customer-group.cg-in-progress { border-color: var(--accent-dim); }

.cg-in-progress .customer-header {
  background: #2a2700;
  border-bottom-color: var(--accent-dim);
}

/* Amber dot indicator shown next to customer name */
.status-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  align-self: center;
}

/* ── ORDER CARDS ────────────────────────────────────────────── */
.order-card {
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s, opacity 0.15s;
}
.order-card:last-child { border-bottom: none; }

.order-card.checked {
  border-left-color: var(--check);
  background: var(--done-bg);
  opacity: 0.75;
}

/* Entire card row is the touch target */
.order-card label {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 0;
  min-height: 64px;  /* comfortable touch height */
}
.order-card:active { background: #2a2a24; }

.checkbox-area {
  width: 56px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}
.order-card.checked .checkbox-area { border-right-color: #333; }

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
  flex-shrink: 0;
}
input[type="checkbox"]:checked { background: var(--check); border-color: var(--check); }
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 6px; top: 2px;
  width: 9px; height: 13px;
  border: 2.5px solid white;
  border-top: none; border-left: none;
  transform: rotate(40deg);
}

.order-info { flex: 1; padding: 12px 14px; min-width: 0; }

.order-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.ware-name { font-size: 18px; font-weight: 700; letter-spacing: 0.02em; line-height: 1.2; }
.order-card.checked .ware-name { color: var(--done-text); text-decoration: line-through; }

.qty-badge {
  background: var(--accent);
  color: #1a1a18;
  font-size: 13px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 2px;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.order-card.checked .qty-badge { background: #333; color: var(--done-text); }

.order-meta { display: flex; gap: 14px; flex-wrap: wrap; }

.meta-item {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.order-card.checked .meta-item { color: #666; }
.meta-label { text-transform: uppercase; letter-spacing: 0.06em; }
.meta-value { color: var(--text); }
.order-card.checked .meta-value { color: #777; }

/* ── ALL DONE BANNER ────────────────────────────────────────── */
.all-done { text-align: center; padding: 28px 20px; }
.all-done .icon { font-size: 48px; margin-bottom: 8px; }
.all-done p {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--check);
}

/* ── RESET BUTTON ───────────────────────────────────────────── */
.reset-btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  margin-bottom: 32px;
  padding: 16px;   /* large touch target */
  background: transparent;
  border: 2px solid var(--border);
  color: var(--muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}
.reset-btn:active { border-color: var(--accent); color: var(--accent); }

/* ── RESET CONFIRMATION DIALOG ──────────────────────────────── */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.confirm-overlay.open { display: flex; }

.confirm-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  width: 100%;
  max-width: 500px;
  padding: 24px 20px 32px;
}

.confirm-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.confirm-body {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.confirm-actions { display: flex; gap: 10px; }

.confirm-cancel {
  flex: 1;
  padding: 16px;
  background: transparent;
  border: 2px solid var(--border);
  color: var(--muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 4px;
}

.confirm-ok {
  flex: 1;
  padding: 16px;
  background: #3a1a1a;
  border: 2px solid #6a2a2a;
  color: #ff7070;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 4px;
}

/* ── DEPARTMENT DIVIDER ──────────────────────────────────────── */
.dept-divider {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 12px 4px;
  border-top: 1px solid #2a2a28;
  margin-top: 4px;
}
.dept-divider:first-child {
  border-top: none;
  margin-top: 0;
}

/* ── SUPPLIER ICON ───────────────────────────────────────────── */
.supplier-icon {
  height: 30px;
  width: auto;
  max-width: 80px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 0 2px rgba(255,255,255,0.8)) drop-shadow(0 0 5px rgba(255,255,255,0.4));
}
.order-card.checked .supplier-icon { opacity: 0.35; }

/* ── ACCEPT ALTERNATIVES BADGE ───────────────────────────────── */
.alts-badge {
  font-size: 12px;
  color: #b8b5a0;
  padding-top: 4px;
}

/* ── MISSING STATE ──────────────────────────────────────────── */
.order-card.missing {
  border-left-color: #bf4040;
  background: #281818;
}
.order-card.missing-resolved {
  border-left-color: var(--accent);
  background: #26230e;
}

/* Suppress long-press context menu on mobile */
.order-card .checkbox-area {
  -webkit-touch-callout: none;
  user-select: none;
}

/* Checkbox border on missing card; show ! instead of checkmark */
.order-card.missing input[type="checkbox"],
.order-card.missing-resolved input[type="checkbox"] {
  border-color: #bf4040;
}
.order-card.missing-resolved input[type="checkbox"] {
  border-color: var(--accent-dim);
}
.order-card.missing input[type="checkbox"]::after,
.order-card.missing-resolved input[type="checkbox"]::after {
  content: '!';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: #bf4040;
  border: none;
  width: auto;
  height: auto;
}
.order-card.missing-resolved input[type="checkbox"]::after {
  color: var(--accent);
}

/* Ware name on missing card — red tint, no strikethrough */
.order-card.missing .ware-name {
  color: #e07070;
  text-decoration: none;
}
.order-card.missing-resolved .ware-name {
  color: var(--accent);
  text-decoration: none;
}

/* Row below card label showing missing info + action button */
/* Left-pad to align with .order-info (checkbox-area width = 56px) */
.missing-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 10px 56px;
  flex-wrap: wrap;
}

/* Inline summary text: "No alternatives · 2 missing" or "Missing 2 → Ciabatta" */
.missing-info {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  flex: 1;
}

/* Small action button inside the missing row */
.missing-detail-btn {
  background: rgba(191, 64, 64, 0.15);
  border: 1px solid #7a3030;
  color: #e07070;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  white-space: nowrap;
  flex-shrink: 0;
}
.missing-detail-btn:active { background: rgba(191, 64, 64, 0.3); }

.missing-resolved .missing-detail-btn {
  background: rgba(232, 200, 64, 0.12);
  border-color: var(--accent-dim);
  color: var(--accent);
}
.missing-resolved .missing-detail-btn:active {
  background: rgba(232, 200, 64, 0.25);
}

/* ── MISSING DETAIL SHEET ───────────────────────────────────── */
.missing-detail-sheet .confirm-title {
  margin-bottom: 4px;
}

#detailWareName {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
  letter-spacing: 0.04em;
}

.missing-detail-field {
  margin-bottom: 16px;
}

.missing-detail-label {
  display: block;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.missing-detail-sheet input[type="number"],
.missing-detail-sheet input[type="text"] {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  font-family: 'DM Mono', monospace;
  font-size: 16px;
  letter-spacing: 0.03em;
  min-height: 48px;
}
.missing-detail-sheet input[type="number"]:focus,
.missing-detail-sheet input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── FOOTER LEGEND ──────────────────────────────────────────── */
.app-footer {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  border-top: 1px solid var(--border);
}

.footer-key {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.key-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
}

/* Mini card swatch: left border + background shows the full visual state */
.key-swatch {
  width: 28px;
  height: 18px;
  border-left: 3px solid;
  border-radius: 2px;
}
.swatch-pending  { border-color: var(--accent); background: var(--surface); }
.swatch-packed   { border-color: var(--check);  background: var(--done-bg); }
.swatch-missing  { border-color: #bf4040;        background: #281818; }
.swatch-replaced { border-color: var(--accent); background: #26230e; }

.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.footer-link {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.04em;
}
.footer-link:hover { color: var(--text); }

.footer-meta {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: #555545;
  letter-spacing: 0.04em;
}

/* ── RESPONSIVE (small phones) ──────────────────────────────── */
@media (max-width: 600px) {
  .info-btn       { display: none; }
}

@media (max-width: 380px) {
  .ware-name      { font-size: 16px; }
  .header-text h1 { font-size: 22px; }
  .customer-name  { font-size: 12px; }
}
