/* ==========================================================================
   HJT Components — shared by web app, driver app mockup, and guideline.
   Requires tokens.css.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { margin: 0; line-height: var(--leading-tight); font-weight: var(--weight-semibold); }
b, strong, th { font-weight: var(--weight-semibold); }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
a { color: var(--color-primary); }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: -0.01em; }
.muted { color: var(--color-text-muted); }
.eyebrow {
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--color-text-muted);
}

/* ---- Brand motif: slanted speed stripe (from logo angle) ---- */
.slant-stripe {
  display: inline-flex; gap: 4px; height: 12px;
}
.slant-stripe i {
  width: 6px; height: 100%; background: var(--color-accent);
  transform: skewX(var(--slant)); border-radius: 1px;
}
.slant-stripe i:nth-child(2) { opacity: .6; }
.slant-stripe i:nth-child(3) { opacity: .3; }

/* ---- Buttons ---- */
.btn {
  --_bg: var(--color-surface); --_fg: var(--color-text); --_bd: var(--color-border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 40px; padding: 0 var(--space-4);
  background: var(--_bg); color: var(--_fg); border: 1px solid var(--_bd);
  border-radius: var(--radius-sm); font-weight: var(--weight-semibold); font-size: var(--text-sm);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--duration-fast), transform var(--duration-fast), box-shadow var(--duration-fast);
}
.btn:hover { background: var(--color-surface-2); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { --_bg: var(--color-primary); --_fg: var(--color-on-primary); --_bd: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); box-shadow: inset 0 -2px 0 var(--color-accent); }
.btn-signal { --_bg: var(--signal-500); --_fg: var(--navy-900); --_bd: var(--signal-500); }
.btn-signal:hover { background: var(--signal-400); }
.btn-ghost { --_bg: transparent; --_bd: transparent; }
.btn-ghost:hover { background: var(--color-primary-soft); }
.btn-danger { --_bg: var(--status-alert); --_fg: #fff; --_bd: var(--status-alert); }
.btn-sm { min-height: 32px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-lg { min-height: 52px; padding: 0 var(--space-6); font-size: var(--text-base); }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }

/* ---- Status badge ---- */
.badge {
  --_c: var(--status-draft);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px 2px 6px; border-radius: var(--radius-xs);
  font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: 20px;
  color: var(--_c); background: color-mix(in srgb, var(--_c) 11%, transparent);
  white-space: nowrap;
}
.badge::before {
  content: ""; width: 4px; height: 12px; background: var(--_c);
  transform: skewX(var(--slant)); border-radius: 1px;
}
.badge[data-s="draft"]   { --_c: var(--status-draft); }
.badge[data-s="active"]  { --_c: var(--status-active); }
.badge[data-s="done"]    { --_c: var(--status-done); }
.badge[data-s="invoice"] { --_c: var(--status-invoice); }
.badge[data-s="paid"]    { --_c: var(--status-paid); }
.badge[data-s="maint"]   { --_c: var(--status-maint); }
.badge[data-s="alert"]   { --_c: var(--status-alert); }

/* ---- Commercial plate (plat kuning angkutan barang) ---- */
.plate {
  display: inline-block; padding: 1px 6px;
  font-family: var(--font-mono); font-weight: 600; font-size: var(--text-xs); letter-spacing: 0.04em;
  color: #111; background: #f6c500; border: 1.5px solid #111; border-radius: 3px;
  box-shadow: inset 0 0 0 1px #f6c500, inset 0 0 0 2px #111; white-space: nowrap;
}

/* ---- Form ---- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-text-muted); }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 18%, transparent);
}
.textarea { min-height: 88px; resize: vertical; }
/* Own chevron instead of the browser's (which hugs the right edge): drawn in currentColor so it follows light/dark. */
.select {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select:disabled { cursor: not-allowed; opacity: .6; }
.select::-ms-expand { display: none; }
.input-group { position: relative; }
.input-group svg { position: absolute; left: 10px; top: 50%; translate: 0 -50%; width: 16px; color: var(--color-text-muted); }
.input-group .input { padding-left: 34px; }
.hint { font-size: var(--text-xs); color: var(--color-text-muted); }
.form-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.dropzone {
  display: grid; place-items: center; gap: 6px; padding: var(--space-5); text-align: center;
  border: 1.5px dashed var(--color-border-strong); border-radius: var(--radius-md);
  background: var(--color-surface-2); color: var(--color-text-muted); cursor: pointer;
}
.dropzone:hover { border-color: var(--color-primary); color: var(--color-primary); }
.dropzone svg { width: 22px; height: 22px; }

/* ---- Card / surface ---- */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
}
.card-pad { padding: var(--space-5); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border);
}
.card-head h3 { font-size: var(--text-base); }

/* ---- KPI tile ---- */
.kpi { position: relative; padding: var(--space-5); overflow: hidden; }
.kpi .kpi-label { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-text-muted); }
.kpi .kpi-value { font-size: var(--text-3xl); font-weight: var(--weight-semibold); letter-spacing: -0.02em; line-height: 1.1; margin-top: 6px; }
.kpi .kpi-meta { font-size: var(--text-xs); margin-top: 4px; color: var(--color-text-muted); }
.kpi .kpi-meta b { color: var(--status-done); }
.kpi::after {
  content: ""; position: absolute; right: -10px; top: 0; bottom: 0; width: 36px;
  background: var(--_kc, var(--color-primary)); opacity: .08; transform: skewX(var(--slant));
}
.kpi-hero { background: var(--navy-700); color: var(--gray-50); border-color: var(--navy-700); }
.kpi-hero .kpi-label, .kpi-hero .kpi-meta { color: var(--navy-200); }
.kpi-hero .kpi-meta b { color: var(--signal-400); }
.kpi-hero::after { background: var(--signal-500); opacity: 1; width: 10px; right: 18px; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
  position: sticky; top: 0; z-index: 1; text-align: left; white-space: nowrap;
  padding: 10px 12px; background: var(--color-surface-2);
  font-size: var(--text-2xs); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-caps);
  text-transform: uppercase; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border);
}
.table td { padding: 12px; border-bottom: 1px solid var(--color-border); white-space: nowrap; vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background var(--duration-fast); }
.table tbody tr:hover { background: var(--color-primary-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Tabs & chips ---- */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-border); overflow-x: auto; scrollbar-width: none; }
.tab {
  position: relative; padding: 10px 14px; background: none; border: 0; cursor: pointer;
  font-weight: var(--weight-semibold); color: var(--color-text-muted); white-space: nowrap;
}
.tab[aria-selected="true"] { color: var(--color-primary); }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px;
  background: var(--color-primary); transform: skewX(var(--slant));
}
.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-pill);
  background: var(--color-surface); cursor: pointer; font-size: var(--text-xs); font-weight: var(--weight-semibold);
}
.chip[aria-pressed="true"] { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.chip .count { opacity: .7; font-weight: 400; }

/* ---- Avatar ---- */
.avatar {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: var(--radius-md); background: var(--navy-100); color: var(--navy-800);
  font-weight: var(--weight-semibold); font-size: var(--text-xs);
}

/* ---- Stepper (trip progress) ---- */
.stepper { display: grid; grid-template-columns: repeat(var(--steps, 6), 1fr); gap: 4px; }
.stepper i { height: 6px; background: var(--color-border); transform: skewX(var(--slant)); border-radius: 1px; }
.stepper i.on { background: var(--color-primary); }
.stepper i.now { background: var(--color-accent); }

/* ---- Timeline ---- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { position: relative; padding: 0 0 var(--space-4) 24px; }
.timeline li::before {
  content: ""; position: absolute; left: 4px; top: 6px; width: 10px; height: 10px;
  background: var(--color-border-strong); transform: skewX(var(--slant));
}
.timeline li::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 2px; background: var(--color-border); }
.timeline li:last-child::after { display: none; }
.timeline li.done::before { background: var(--color-primary); }
.timeline li.now::before { background: var(--color-accent); }

/* ---- Drawer / sheet ---- */
.scrim {
  position: fixed; inset: 0; z-index: 50; background: rgb(8 10 46 / .45);
  opacity: 0; pointer-events: none; transition: opacity var(--duration-normal);
}
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; z-index: 51; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--color-surface); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform var(--duration-slow) var(--ease-out);
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--space-5); display: grid; gap: var(--space-5); align-content: start; }
.drawer-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--color-border); }

/* ---- Key-value list ---- */
.kv { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 8px 16px; font-size: var(--text-sm); }
.kv dt { color: var(--color-text-muted); }
.kv dd { margin: 0; font-weight: var(--weight-semibold); }

/* ---- Map pin (unit marker) ---- */
.unit-pin {
  display: grid; place-items: center; width: 30px; height: 30px;
  background: var(--_c, var(--navy-700)); color: #fff; border: 2px solid #fff;
  border-radius: 6px 6px 6px 0; transform: rotate(-45deg); box-shadow: var(--shadow-2);
}
.unit-pin svg { transform: rotate(45deg); width: 14px; height: 14px; }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 80; translate: -50% 0;
  padding: 10px 16px; border-radius: var(--radius-sm); background: var(--navy-900); color: var(--gray-50);
  box-shadow: var(--shadow-3); font-weight: var(--weight-semibold);
  opacity: 0; transform: translateY(8px); transition: opacity var(--duration-normal), transform var(--duration-normal) var(--ease-out);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

/* ---- Map tiles: monochrome in brand navy hue (OSM raster, recolored in CSS) ---- */
.tiles-light { filter: grayscale(1) sepia(1) hue-rotate(180deg) saturate(1.5) brightness(1.02) contrast(.92); }
.tiles-dark { filter: invert(1) grayscale(1) sepia(1) hue-rotate(180deg) saturate(2.2) brightness(.62) contrast(1.15); }

/* Inline notice and segmented choice — shared by HJT Ops and HJT Driver */
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--radius-md); font-size: 12px; font-weight: 600; }
.banner svg { width: 18px; flex: none; }
.banner.warn { background: color-mix(in srgb, var(--signal-500) 18%, transparent); color: var(--color-text); }
.banner.info { background: var(--color-primary-soft); color: var(--color-primary); }
.seg { display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); gap: 6px; }
.seg button { min-height: 44px; border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-text); border-radius: var(--radius-sm); font-weight: 600; font-size: 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
