/* ============================================================
 *  cnc/history.css — History mode for the CNC page's left palette.
 *
 *  HAND-WRITTEN companion to the AUTO-GENERATED picking-list.css
 *  (never edit that file; this one is safe). Loaded after it and
 *  after mobile.css.
 *
 *  Mode model: option-31-cnc-script.js toggles `.cnc-history` on the
 *  tab root (#cnc-tab) via the Active/History toggle (#lcModes) that
 *  sits over the Currently Cutting + Queue columns. History mode
 *  hides those two halves (+ their splitter) and shows #historyHalf —
 *  a full-height, per-machine list of every picking list that has run
 *  at least one sheet (GET /api/cnc/history). The center pane and
 *  right panel stay — selecting a history card renders the normal
 *  detail view.
 * ============================================================ */

/* ── Active/History toggle strip (top of the left column) ───── */
#cnc-tab .lc-modes {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-surface);
}
#cnc-tab .lc-mode {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  padding: 7px 14px 8px;
  margin-bottom: -1px;          /* sit on the strip's border like a tab */
  font-family: var(--font-display);
  font-size:var(--fs-caption); font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg-3);
  cursor: pointer;
  transition: color 120ms, background 120ms, border-color 120ms;
}
#cnc-tab .lc-mode:hover { color: var(--fg-1); }
#cnc-tab .lc-mode.active {
  color: var(--brand);
  background: var(--bg-surface);
  border-color: var(--border);
  border-bottom: 1px solid var(--bg-surface);
}

/* ── History half (replaces the two active halves) ──────────── */
#cnc-tab .left-half#historyHalf { display: none; }

#cnc-tab.cnc-history .left-half#cuttingHalf,
#cnc-tab.cnc-history .h-splitter,
#cnc-tab.cnc-history .left-half#queueHalf { display: none; }

#cnc-tab.cnc-history .left-half#historyHalf {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Filter input under the section header. */
#cnc-tab .hist-filter {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 7px 10px;
  background: var(--bg-sunken);
  color: var(--fg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size:var(--fs-caption);
  box-sizing: border-box;
}
#cnc-tab .hist-filter:focus {
  outline: none;
  border-color: var(--brand);
}

/* ── History cards — extend the .pl-card look ───────────────── */
#cnc-tab .hist-card .hist-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  font-size:var(--fs-overline);
  color: var(--fg-3);
}
#cnc-tab .hist-card .hist-sheets .t-num {
  font-weight: 600; color: var(--fg-2);
}
#cnc-tab .hist-card .hist-cancelled { color: var(--danger); }
#cnc-tab .hist-card .hist-when { margin-left: auto; white-space: nowrap; }

/* Status pill on the card. */
#cnc-tab .hist-card .hist-status {
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid;
  font-family: var(--font-display);
  font-size:10px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  white-space: nowrap;
}
#cnc-tab .hist-card .hist-status.complete {
  color: var(--brand);
  border-color: var(--border-brand, var(--brand));
  background: var(--brand-subtle);
}
#cnc-tab .hist-card .hist-status.cutting {
  color: var(--ok, #2e7d4f);
  border-color: var(--ok, rgba(46, 125, 79, 0.55));
  background: var(--ok-bg, rgba(46, 125, 79, 0.10));
}
#cnc-tab .hist-card .hist-status.partial {
  color: var(--warn, #9a6b15);
  border-color: var(--warn, rgba(154, 107, 21, 0.5));
  background: var(--warn-bg, rgba(154, 107, 21, 0.10));
}

/* ── Phone (≤768px) — composes with cnc/mobile.css ──────────── */
@media (max-width: 768px) {

  /* mobile.css gives every .left-half height:auto/flex:none — that's
     already right for the stacked history list; just make sure the
     hidden halves stay hidden against its !important visibility. */
  #cnc-tab.cnc-history .left-half#cuttingHalf,
  #cnc-tab.cnc-history .left-half#queueHalf { display: none !important; }

  /* Toggle buttons need real tap targets. */
  #cnc-tab .lc-mode { min-height: 44px; padding: 10px 18px; }

  /* Filter input: 44px tap target. */
  #cnc-tab .hist-filter { min-height: 44px; font-size:var(--fs-sm); }
}
