/* RARS Kiosk Demo — portrait, high contrast for outdoor glare, large touch targets */

:root {
  --ink: #0a0a0a;
  --paper: #ffffff;
  --surface: #f2f2f0;
  --muted: #46484c;
  --line-soft: #bbb;

  /* Structural brand color (topbar, buttons, panel heads, borders) —
     deep water blue/navy instead of plain black, so the chrome reads
     as water infrastructure rather than a generic dashboard. */
  --navy: #0b2e59;
  --navy-dark: #071d3a;

  --blue: #0057d8;
  --blue-bg: #e3edff;
  --amber: #a35400;
  --amber-bg: #fff1d9;
  --green: #036b3a;
  --green-bg: #e0f5e9;
  --red: #a81c1c;
  --red-bg: #fbe4e4;
}

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

/* Shared inline-SVG icon (views/partials/icon.ejs) — nudged to sit on the
   text baseline wherever it's dropped inline next to a label. */
.k-icon {
  vertical-align: -0.2em;
  margin-right: 4px;
  flex-shrink: 0;
}

/* Generic show/hide utility, reused by any component that toggles a block
   between two states via JS (see also .k-weigh-panel.k-hidden below). */
.k-hidden { display: none; }

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: #d7e2ee;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.kiosk-screen {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  border-left: 1px solid #ccc;
  border-right: 1px solid #ccc;
  position: relative;
  overflow: hidden;
}

/* ── Top bar ── */
.k-topbar {
  flex-shrink: 0;
  height: 60px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.k-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.k-brand-icon {
  flex-shrink: 0;
}
.k-logo {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: .06em;
}
.k-station {
  font-size: .85rem;
  color: #cfe0ff;
  border: 1px solid #33547f;
  border-radius: 3px;
  padding: 2px 7px;
}
.k-topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.k-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
  color: #cfe0ff;
}
.k-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #17c964;
  flex-shrink: 0;
}
.k-dot.busy { background: #f5a524; }
.k-dot.done { background: #17c964; }
.k-dot.error { background: var(--red); }

.k-help-btn {
  min-height: 48px;
  padding: 0 18px;
  margin-right: 2px;
  border-radius: 24px;
  border: 2px solid rgba(255, 255, 255, .85);
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}
.k-help-btn:active { background: rgba(255, 255, 255, .22); }

/* ── Water motif strip ── */
.k-wave {
  flex-shrink: 0;
  height: 9px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='10' viewBox='0 0 40 10'%3E%3Cpath d='M0 5 Q10 0 20 5 T40 5 V10 H0 Z' fill='%230b2e59'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-size: 40px 10px;
}

/* ── Step progress ── */
.k-progress {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 0;
}
.k-progress-dots { display: flex; gap: 6px; }
.k-progress-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--line-soft);
}
.k-progress-dot.active { background: var(--navy); border-color: var(--navy); }
.k-progress-label {
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Body ── */
.k-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 22px 20px;
  gap: 16px;
  overflow-y: auto;
}

.k-title {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}
.k-subtitle {
  font-size: .95rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Notice banner ── */
.k-notice {
  border: 2px solid var(--amber);
  background: var(--amber-bg);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .82rem;
  color: #5a3300;
  line-height: 1.4;
}
.k-notice.info {
  border-color: var(--blue);
  background: var(--blue-bg);
  color: #002d80;
}

/* ── Flow tiles (home screen) ── */
.k-tiles {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 4px;
}
.k-tile {
  display: flex;
  align-items: center;
  gap: 16px;
  border: 2.5px solid var(--navy);
  border-radius: 10px;
  padding: 18px;
  background: var(--paper);
  text-align: left;
  cursor: pointer;
  width: 100%;
  font: inherit;
  color: inherit;
}
.k-tile:active { background: var(--surface); }
.k-tile.recommended { border-color: var(--blue); background: var(--blue-bg); }
.k-tile-icon { font-size: 2.1rem; line-height: 1; flex-shrink: 0; }
.k-tile-label { font-size: 1.15rem; font-weight: 700; }
.k-tile-sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.k-tile.disabled {
  border-color: var(--line-soft);
  color: var(--muted);
  cursor: not-allowed;
}
.k-tile.disabled .k-tile-icon { opacity: .35; }

/* Compact variant for not-yet-available services — visually recedes below
   the one working tile instead of competing with it at equal weight. */
.k-tiles-compact { gap: 8px; margin-top: 2px; }
.k-tile-compact { padding: 12px 14px; gap: 10px; }
.k-tile-compact .k-tile-label { font-size: .92rem; }
.k-badge-soon {
  margin-left: auto;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  background: #e4e4e4;
  color: #5a5d63;
  border: 1px solid #bbb;
  border-radius: 4px;
  padding: 3px 8px;
  flex-shrink: 0;
}
.k-tile-tag {
  margin-left: auto;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  background: var(--blue);
  color: #fff;
  border-radius: 4px;
  padding: 3px 8px;
  flex-shrink: 0;
}

/* ── Data panel ── */
.k-panel {
  border: 2px solid var(--navy);
  border-radius: 10px;
  overflow: hidden;
}
.k-panel-head {
  background: var(--navy);
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 8px 14px;
}
.k-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid #e5e5e5;
  font-size: 1.05rem;
}
.k-row:last-child { border-bottom: none; }
.k-row-label { color: var(--muted); font-weight: 600; }
.k-row-value { font-weight: 700; text-align: right; }
.k-row-value.blue { color: var(--blue); }
.k-row-value.amber { color: var(--amber); }
.k-row-value.green { color: var(--green); }

/* Identity-critical rows (e.g. PO Number, Chemical, Vehicle Plate) — the
   fields a driver actually needs to cross-check against paperwork, made
   visually dominant rather than uniform with the rest of the panel. */
.k-row.k-row-emphasis {
  padding: 14px;
  background: var(--surface);
}
.k-row.k-row-emphasis .k-row-label {
  font-size: .88rem;
  font-weight: 700;
  color: var(--navy);
}
.k-row.k-row-emphasis .k-row-value {
  font-size: 1.3rem;
}

/* Secondary/reference rows (e.g. Valid Until, Charging Port, Supplier) —
   still legible, but visually demoted below the identity-critical rows. */
.k-row.k-row-muted .k-row-label,
.k-row.k-row-muted .k-row-value {
  font-size: .82rem;
  font-weight: 600;
}

/* ── Weigh screen panels (normal capture vs. failed-capture retry state) ── */
.k-weigh-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}
.k-weigh-panel.k-hidden { display: none; }

/* ── Weight readout (primary, on the Weigh screen) ── */
.k-weight-box {
  border: 3px solid var(--navy);
  border-radius: 12px;
  padding: 22px 16px;
  text-align: center;
  margin-top: auto;
}
.k-weight-label {
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.k-weight-value {
  font-variant-numeric: tabular-nums;
  font-size: 3.6rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.01em;
}
.k-weight-unit {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
}
.k-weight-status {
  margin-top: 10px;
  font-size: 1rem;
  font-weight: 700;
}
.k-weight-status.amber { color: var(--amber); }
.k-weight-status.green { color: var(--green); }
.k-weight-bar {
  height: 10px;
  border-radius: 5px;
  background: #eee;
  margin-top: 10px;
  overflow: hidden;
}
.k-weight-bar-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--amber);
  width: 30%;
  transition: width .15s linear, background .3s ease;
}
.k-weight-bar-fill.done { background: var(--green); width: 100%; }
.k-weight-countdown {
  margin-top: 6px;
  font-size: .85rem;
  font-weight: 700;
  color: var(--muted);
  min-height: 1.2em;
}

/* ── Weight highlight (secondary — e.g. Net Delivered on the Receipt screen) ── */
.k-weight-highlight {
  border: 3px solid var(--navy);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.k-weight-highlight-label {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.k-weight-highlight-value {
  font-variant-numeric: tabular-nums;
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--green);
  line-height: 1;
  margin-top: 4px;
}
.k-weight-highlight-unit {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 4px;
}

/* ── Alerts ── */
.k-alert {
  border-left: 5px solid;
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  font-size: .88rem;
  line-height: 1.4;
}
.k-alert-title { display: block; font-weight: 700; margin-bottom: 2px; font-size: .95rem; }
.k-alert.amber { background: var(--amber-bg); border-color: var(--amber); color: #5a3300; }
.k-alert.blue { background: var(--blue-bg); border-color: var(--blue); color: #002d80; }
.k-alert.green { background: var(--green-bg); border-color: var(--green); color: #013b20; }
.k-alert.red { background: var(--red-bg); border-color: var(--red); color: #5c0f0f; }
.k-alert-icon {
  flex-shrink: 0;
  vertical-align: -3px;
  margin-right: 4px;
}

/* ── Buttons ── */
.k-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 6px;
}
.k-btn {
  flex: 1;
  min-height: 64px;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .01em;
  border: 2.5px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  font-family: inherit;
}
.k-btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.k-btn-outline { background: #fff; color: var(--navy); border-color: var(--navy); }
.k-btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.k-btn-danger { background: #fff; color: var(--red); border-color: var(--red); }
.k-btn:disabled {
  background: #d7d7d7;
  color: #5b5b5b;
  border-color: #bdbdbd;
  cursor: not-allowed;
}
.k-btn:active:not(:disabled) { transform: translateY(1px); }

.k-btn-link {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
  text-decoration: underline;
  padding: 10px;
  cursor: pointer;
  font-family: inherit;
}

/* ── Idle / completion centered blocks ── */
.k-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
}
.k-idle-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--navy);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--navy);
}
.k-check {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
}
.k-check.warn {
  background: var(--amber);
}
.k-ticket {
  font-family: monospace;
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--blue-bg);
  border: 2px solid var(--navy);
  color: var(--navy);
  border-radius: 6px;
  padding: 8px 16px;
  letter-spacing: .04em;
}
.k-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: .8rem;
  margin: 2px 0;
}
.k-divider::before, .k-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #ddd;
}

/* ── Scanning / lookup overlay ── */
.k-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 29, 58, .94);
  color: #fff;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 50;
}
.k-overlay.show { display: flex; }
.k-scan-icon {
  font-size: 3.2rem;
  animation: k-pulse 1s ease-in-out infinite;
}
.k-overlay-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .04em;
}
@keyframes k-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .55; transform: scale(.92); }
}

.k-clock { font-variant-numeric: tabular-nums; }

/* ── Modal (PO entry, Help) ── */
.k-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 29, 58, .82);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
}
.k-modal-backdrop.show { display: flex; }
.k-modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 22px 20px 26px;
  border-top: 3px solid var(--navy);
}
.k-modal-title { font-size: 1.25rem; font-weight: 700; }
.k-modal-sub { font-size: .85rem; color: var(--muted); margin: 4px 0 16px; line-height: 1.5; }
.k-modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.k-modal-actions .k-btn { flex: 1; }
.k-modal.k-modal-warn { border-top-color: var(--amber); }

/* ── Help modal video (YouTube embed, with offline-safe fallback) ── */
.k-help-video { margin: 4px 0 14px; }
.k-help-video-frame {
  position: relative;
  width: min(220px, 55%);
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  background: var(--navy);
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--line-soft);
}
.k-help-video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.k-help-video-fallback {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  text-align: center;
  background: var(--navy);
  color: #cfe0ff;
  font-size: .74rem;
  font-weight: 600;
  line-height: 1.4;
}
.k-help-video-frame.video-error iframe { display: none; }
.k-help-video-frame.video-error .k-help-video-fallback { display: flex; }
.k-help-video-caption {
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  margin-top: 8px;
}
.k-timeout-countdown {
  text-align: center;
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  margin: 6px 0 4px;
}
.k-input {
  width: 100%;
  min-height: 56px;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0 14px;
  border: 2.5px solid var(--navy);
  border-radius: 10px;
  font-family: inherit;
  color: inherit;
}
.k-input:focus { outline: 3px solid var(--blue); outline-offset: 1px; }
.k-input-hint {
  font-size: .82rem;
  color: var(--muted);
  margin-top: 6px;
}

/* ── Print (Receipt screen "Print Receipt" button) ── */
@media print {
  body { background: #fff; }
  .kiosk-screen { max-width: 100%; min-height: 0; border: none; }
  .k-topbar, .k-wave, .k-progress, .k-actions,
  .k-modal-backdrop, .k-overlay { display: none !important; }
  .k-body { overflow: visible; }
}
