/* ============================================================
   WOHub Components — Re-imagined migration foundation
   Ported verbatim from prototype WOHub.html lines 73–365.
   Depends on design-tokens.css for CSS variables.
   ============================================================ */

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-feature-settings: 'tnum'; }

/* === Buttons === */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  background: var(--bg-3); border: 1px solid var(--border-2); color: var(--text);
  cursor: pointer; transition: all .12s; font-family: inherit; line-height: 1;
}
.btn:hover { background: var(--bg-4); border-color: var(--border-3); }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover { background: var(--text-2); border-color: var(--text-2); }
.btn-blue { background: var(--blue); color: var(--text-inverted); border-color: var(--blue); }
.btn-blue:hover { background: #2563eb; border-color: #2563eb; }
.btn-green { background: var(--green); color: var(--text-inverted); border-color: var(--green); }
.btn-red { background: var(--red); color: var(--text-inverted); border-color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* === Cards === */
.card {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }

/* === Inputs === */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], textarea, select {
  background: var(--bg-2); border: 1px solid var(--border-2); color: var(--text);
  padding: 7px 12px; border-radius: 7px; font-size: 13px; font-family: inherit;
  outline: none; transition: border-color .12s;
  width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--text-3); }
input::placeholder, textarea::placeholder { color: var(--text-4); }
label { font-size: 12px; color: var(--text-2); font-weight: 500; }

/* === Pills / Badges === */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500;
  border: 1px solid var(--border-2); background: var(--bg-3); color: var(--text-2);
  line-height: 1.5; white-space: nowrap;
}
.pill-blue   { background: var(--blue-bg);   color: var(--blue-2); border-color: rgba(59,130,246,0.3); }
.pill-green  { background: var(--green-bg);  color: #4ade80;       border-color: rgba(34,197,94,0.3); }
.pill-amber  { background: var(--amber-bg);  color: #fbbf24;       border-color: rgba(245,158,11,0.3); }
.pill-red    { background: var(--red-bg);    color: #fca5a5;       border-color: rgba(239,68,68,0.3); }
.pill-orange { background: var(--orange-bg); color: #fb923c;       border-color: rgba(249,115,22,0.3); }
.pill-purple { background: var(--purple-bg); color: #c084fc;       border-color: rgba(168,85,247,0.3); }
html[data-theme="light"] .pill-green  { color: #15803d; }
html[data-theme="light"] .pill-amber  { color: #b45309; }
html[data-theme="light"] .pill-red    { color: #b91c1c; }
html[data-theme="light"] .pill-orange { color: #c2410c; }
html[data-theme="light"] .pill-purple { color: #7e22ce; }
html[data-theme="light"] .pill-blue   { color: #1d4ed8; }

/* === Layout === */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: var(--bg-1); border-right: 1px solid var(--border);
  padding: 16px 0; display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 30;
}
.main {
  flex: 1; min-width: 0; margin-left: 232px; display: flex; flex-direction: column;
}
.content { min-width: 0; }
/* Cards that contain wide tables get horizontal scroll — overrides inline overflow:hidden. */
.card:has(table.tbl) { overflow-x: auto !important; overflow-y: visible !important; }
.modal, .modal-body { overflow-x: hidden; }
.topbar {
  height: 56px; background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.content { padding: 24px; flex: 1; }

/* === Sidebar nav === */
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 4px 20px 20px;
  text-decoration: none;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
  display: grid; place-items: center;
  color: var(--text-inverted); flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.35), inset 0 1px 0 rgba(255,255,255,0.15);
}
.brand-mark svg { width: 60%; height: 60%; }
html[data-theme="light"] .brand-mark {
  background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
  color: var(--text-inverted);
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}
.brand-text { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }

.nav-section { padding: 12px 12px 4px; font-size: 10px; font-weight: 600; color: var(--text-4);
  text-transform: uppercase; letter-spacing: 0.08em; }
.nav { flex: 1; overflow-y: auto; padding: 4px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 12px;
  border-radius: 7px; color: var(--text-2); text-decoration: none; font-size: 13px;
  font-weight: 500; cursor: pointer; margin-bottom: 1px;
  transition: background .1s, color .1s; border: none; background: none;
  width: 100%; text-align: left; font-family: inherit;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: var(--bg-3); color: var(--text); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.8; }
.nav-item .nav-badge { margin-left: auto; font-size: 10px; padding: 1px 6px; border-radius: 999px;
  background: var(--bg-4); color: var(--text-2); font-weight: 600; }
.nav-item.active .nav-badge { background: var(--text); color: var(--bg); }
.nav-sub { padding-left: 28px; }
.nav-sub .nav-item { padding: 5px 12px; font-size: 12px; color: var(--text-3); }

/* === Topbar === */
.topbar-title { font-size: 14px; font-weight: 600; color: var(--text); }
.topbar-sub { font-size: 12px; color: var(--text-3); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 7px; background: var(--bg-1);
  border: 1px solid var(--border); color: var(--text-2); cursor: pointer;
  display: grid; place-items: center; transition: all .12s; position: relative;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }
.icon-btn .icon-dot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--red); }
.role-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 10px 5px 8px; font-size: 12px; color: var(--text-2);
  cursor: pointer; font-family: inherit;
}
.role-pill:hover { background: var(--bg-3); color: var(--text); }
.role-pill .role-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

/* === Tables === */
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { padding: 10px 14px; text-align: left; }
table.tbl th { font-size: 10px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border); background: var(--bg);
  position: sticky; top: 0;
}
table.tbl td { border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr.row-click { cursor: pointer; }
table.tbl tr.row-click:hover td { background: var(--bg-3); }

/* === Tabs === */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  padding: 9px 16px; font-size: 13px; font-weight: 500;
  background: none; border: none; cursor: pointer; color: var(--text-3);
  border-bottom: 2px solid transparent; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }
.tab-count {
  display: inline-block; margin-left: 6px; padding: 0 6px; min-width: 18px;
  background: var(--bg-3); border-radius: 999px; font-size: 10px; line-height: 16px;
  font-weight: 600; text-align: center; color: var(--text-2);
}
.tab.active .tab-count { background: var(--text); color: var(--bg); }

/* === Segmented toggle — supports both <button> and <a> children === */
.segmented {
  display: inline-flex; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; padding: 3px; gap: 3px;
}
.segmented button,
.segmented a {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: none; border: none; padding: 6px 12px; font-size: 12px; line-height: 1;
  border-radius: 6px; color: var(--text-3); cursor: pointer; font-family: inherit; font-weight: 500;
  text-decoration: none; transition: color .12s, background .12s;
  white-space: nowrap;
}
.segmented button.active,
.segmented a.active { background: var(--bg-1); color: var(--text); box-shadow: 0 0 0 1px var(--border-2); }
.segmented button:hover:not(.active),
.segmented a:hover:not(.active) { color: var(--text); background: var(--bg-2); }

/* === Skeleton === */
.skeleton { background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%; animation: skel 1.4s infinite; border-radius: 6px; }
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* === KPI === */
.kpi {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px;
}
.kpi-label { font-size: 10px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text); margin-top: 6px;
  font-family: 'JetBrains Mono', monospace; letter-spacing: -0.02em; }
.kpi-spark { height: 28px; margin-top: 8px; }

/* === Modal === */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(2px);
  z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  background: var(--bg-1); border: 1px solid var(--border-2); border-radius: 14px;
  max-width: 540px; width: 100%; box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
}
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }
.modal-hdr { padding: 18px 22px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 15px; font-weight: 600; color: var(--text); margin: 0; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--bg); }

/* === Drawer === */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 90; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 95vw;
  background: var(--bg-1); border-left: 1px solid var(--border-2); z-index: 91;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* === Pagination ===
   Reusable pagination bar. Pairs with templates/macros/pagination.html.
   The wrapping <div id="<screen>-pagebox"> sits OUTSIDE this .pagination
   element so HTMX can swap a region that includes table + pagination. */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; padding: 14px; border-top: 1px solid var(--border);
}
.pagination .page-info { font-size: 13px; color: var(--text-3); }
.pagination .disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .btn-sm { font-family: inherit; }

/* === Misc === */
.empty {
  text-align: center; padding: 48px 20px; color: var(--text-3); font-size: 13px;
}
.empty-icon { font-size: 32px; margin-bottom: 8px; opacity: 0.5; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-4 { color: var(--text-4); }

.grid { display: grid; gap: 12px; }
.flex { display: flex; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; min-width: 0; }
.flex-wrap { flex-wrap: wrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12px; }
.text-md { font-size: 14px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 28px; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }

/* === Scrollbars === */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-3); }

/* === Login page — full-bleed === */
.no-shell .sidebar, .no-shell .topbar { display: none; }
.no-shell .main { margin-left: 0; }
.no-shell .content { padding: 0; }

/* === Dept colors ===
   Slug rule: dept_chip macro lowercases the name and replaces ' - ' then ' '
   with '-'. So "METAL FAB - MONUMENTS" → .dept-metal-fab-monuments,
   "VINYL APP" → .dept-vinyl-app, etc.
   Any dept name without a matching variant falls back to the neutral
   .dept-chip base style. */
.dept-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 5px;
  font-size: 10px; font-weight: 600; line-height: 1.6; letter-spacing: 0.04em;
  background: var(--bg-3); color: var(--text-2); white-space: nowrap; }

/* — Prototype legacy slugs (kept so any template using them stays styled) — */
.dept-chip.dept-fab        { background: rgba(59,130,246,0.12);  color: #60a5fa; }
.dept-chip.dept-paint      { background: rgba(168,85,247,0.12);  color: #c084fc; }
.dept-chip.dept-electrical { background: rgba(245,158,11,0.12);  color: #fbbf24; }
.dept-chip.dept-install    { background: rgba(34,197,94,0.12);   color: #4ade80; }
.dept-chip.dept-qc         { background: rgba(236,72,153,0.12);  color: #f472b6; }
.dept-chip.dept-router     { background: rgba(180,83,9,0.16);    color: #fbbf24; }
.dept-chip.dept-flatbed    { background: rgba(8,145,178,0.16);   color: #22d3ee; }

/* — WOHub real dept names (PRODUCTION_DEPARTMENTS_FULL + EXTERNAL) — */
.dept-chip.dept-roland     { background: rgba(22,163,74,0.14);   color: #4ade80; }
.dept-chip.dept-epson      { background: rgba(124,58,237,0.14);  color: #c084fc; }
.dept-chip.dept-laser      { background: rgba(202,138,4,0.16);   color: #facc15; }
.dept-chip.dept-sanding    { background: rgba(249,115,22,0.12);  color: #fb923c; }
.dept-chip.dept-dryroom    { background: rgba(14,165,233,0.14);  color: #38bdf8; }
.dept-chip.dept-ada        { background: rgba(139,92,246,0.14);  color: #a78bfa; }
.dept-chip.dept-braille    { background: rgba(167,139,250,0.14); color: #c4b5fd; }
.dept-chip.dept-vinyl-app  { background: rgba(16,185,129,0.14);  color: #34d399; }
.dept-chip.dept-plotter    { background: rgba(56,189,248,0.14);  color: #7dd3fc; }
.dept-chip.dept-paintmask  { background: rgba(217,70,239,0.14);  color: #e879f9; }
.dept-chip.dept-metal-fab-monuments  { background: rgba(100,116,139,0.16); color: #cbd5e1; }
.dept-chip.dept-metal-fab-structural { background: rgba(59,130,246,0.14);  color: #60a5fa; }
.dept-chip.dept-metal-fab-handicap   { background: rgba(20,184,166,0.14);  color: #5eead4; }
.dept-chip.dept-electrical-assembly  { background: rgba(245,158,11,0.12);  color: #fbbf24; }
.dept-chip.dept-channel-letter       { background: rgba(234,88,12,0.14);   color: #fb923c; }
.dept-chip.dept-handicap-assembly    { background: rgba(20,184,166,0.14);  color: #5eead4; }
.dept-chip.dept-kiss-print           { background: rgba(244,63,94,0.14);   color: #fb7185; }
.dept-chip.dept-photopolymer         { background: rgba(6,182,212,0.14);   color: #67e8f9; }
.dept-chip.dept-digital-print        { background: rgba(59,130,246,0.14);  color: #60a5fa; }
.dept-chip.dept-final-assembly       { background: rgba(132,204,22,0.14);  color: #a3e635; }
.dept-chip.dept-finished-goods       { background: rgba(34,197,94,0.14);   color: #4ade80; }
.dept-chip.dept-central-station      { background: rgba(100,116,139,0.14); color: #94a3b8; }
.dept-chip.dept-inventory            { background: rgba(168,162,158,0.14); color: #d6d3d1; }
.dept-chip.dept-scheduling           { background: rgba(99,102,241,0.14);  color: #818cf8; }
.dept-chip.dept-sales                { background: rgba(217,119,6,0.14);   color: #fbbf24; }
.dept-chip.dept-metal-fab            { background: rgba(100,116,139,0.14); color: #cbd5e1; }

/* Sparkline */
.spark-line { fill: none; stroke-width: 1.5; }

.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
