/* NAS Driver portal - mobile-first, reuses the app's design tokens (css/styles.css). */

body.drv {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--label);
  -webkit-font-smoothing: antialiased;
  /* The shared office stylesheet locks body to height:100vh / display:flex /
     overflow:hidden for its fixed app shell. The portal is a normal scrolling
     page, so override all three here or tall forms get clipped (can't scroll). */
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: block;
  overflow-x: hidden;
  overflow-y: visible;
}

.hidden { display: none !important; }

.drv-view { max-width: 640px; margin: 0 auto; }
.drv-center {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.drv-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 24px;
}
.drv-login { width: 100%; max-width: 380px; text-align: center; }
.drv-login h1 { font-size: 22px; margin: 4px 0 18px; }
.drv-logo { height: 46px; width: auto; margin-bottom: 22px; }

/* forms */
label { display: block; text-align: left; font-size: 13px; color: var(--label-2); margin-bottom: 14px; font-weight: 600; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-weight: 400; color: var(--label);
  background: var(--bg); border: 1px solid var(--separator); border-radius: 10px;
  padding: 12px 14px; min-height: 46px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.drv-btn {
  display: block; width: 100%; min-height: 48px;
  font: inherit; font-weight: 600; border: none; border-radius: 10px;
  cursor: pointer; padding: 12px 16px;
}
.drv-btn-primary { background: var(--accent); color: #fff; }
.drv-btn-primary:disabled { opacity: 0.5; cursor: default; }
.drv-btn-ghost { background: var(--fill); color: var(--label); }

.drv-link { background: none; border: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 12px; margin-top: 8px; }
.drv-muted { color: var(--label-2); font-size: 14px; }
.drv-error { color: var(--red); font-size: 14px; margin: 0 0 12px; }
.drv-note { color: var(--label-2); font-size: 14px; background: var(--fill); border-radius: 8px; padding: 10px; }

/* top bar */
.drv-top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 20px 12px;
  background: var(--bg-topbar); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--topbar-border);
}
.drv-top-logo { height: 26px; }
.drv-top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.drv-who { font-size: 13px; color: var(--label-2); }
.drv-top .drv-link { margin: 0; padding: 6px; }

/* theme switch (sun / moon) */
.drv-switch {
  position: relative; width: 58px; height: 30px; flex: none;
  border: 1px solid var(--separator); border-radius: 999px; background: var(--fill);
  cursor: pointer; padding: 0; -webkit-tap-highlight-color: transparent;
}
#themeSwitchLogin { position: fixed; top: max(16px, env(safe-area-inset-top)); right: 16px; z-index: 20; }
.drv-switch-ic { position: absolute; top: 50%; transform: translateY(-50%); font-size: 13px; line-height: 1; }
.drv-switch-sun { left: 9px; color: var(--amber); }
.drv-switch-moon { right: 9px; color: var(--label-3); }
.drv-switch-knob {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--card); box-shadow: var(--card-shadow); transition: transform .18s ease;
}
.drv-switch[aria-checked="true"] .drv-switch-knob { transform: translateX(28px); }
.drv-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* home layout — override the office `main { display:flex; overflow:hidden }`
   rule that leaks in from styles.css so the greeting and grid stack normally */
#homeView { max-width: 1040px; }
.drv-home { display: block; overflow: visible; padding: 22px 20px 48px; }
.drv-hi { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 6px 0 18px; }
.drv-home-grid { display: grid; grid-template-columns: minmax(230px, 1fr) 2fr; gap: 20px; align-items: start; }

/* logo swaps with the theme (light = black lines, dark = light lines) */
:root[data-theme="light"] .theme-dark-only { display: none; }
:root[data-theme="dark"] .theme-light-only { display: none; }

/* left rail: 2×2 tile grid — equal rows so all four tiles are identical size */
.drv-rail { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 12px; align-content: start; }
.drv-action {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px; text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--separator); border-radius: 14px;
  box-shadow: var(--card-shadow); padding: 16px; cursor: pointer; min-height: 118px;
  color: var(--label); /* buttons don't inherit color — set it or dark-mode text goes black */
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.drv-action:hover { box-shadow: var(--card-shadow-hover); }
.drv-action:active { transform: scale(.99); }
.drv-action-ic { flex: none; width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; font-size: 22px; background: var(--accent-soft); }
.drv-action-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.drv-action-txt b { font-size: 15px; font-weight: 600; line-height: 1.2; }
.drv-action-txt small { font-size: 12px; color: var(--label-2); }

/* right: recent safety checks */
.drv-recents { background: var(--card); border: 1px solid var(--separator); border-radius: 14px; box-shadow: var(--card-shadow); overflow: hidden; }
.drv-recents-head { display: flex; align-items: baseline; gap: 8px; padding: 15px 18px 13px; border-bottom: 1px solid var(--separator); }
.drv-recents-head h3 { font-size: 15px; font-weight: 600; margin: 0; }
.drv-recents-count { font-size: 12.5px; color: var(--label-3); }
.drv-more { margin-left: auto; background: none; border: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer; padding: 2px 4px; }
.drv-recents-list { display: flex; flex-direction: column; }
.drv-recents-empty { padding: 24px 18px; margin: 0; }
/* combined history rows (checks, fuel, timesheets) */
.drv-hist-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 12px 18px; border: none; border-bottom: 1px solid var(--separator);
  width: 100%; text-align: left; font: inherit; color: inherit; background: none;
}
.drv-hist-row:last-child { border-bottom: none; }
.drv-hist-row.clickable { cursor: pointer; }
.drv-hist-row.clickable:hover { background: var(--fill); }
.drv-badge { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; background: var(--fill); }
.drv-badge-defect { background: color-mix(in srgb, var(--amber) 24%, transparent); }
.drv-hist-main { min-width: 0; }
.drv-hist-title { font-weight: 600; font-size: 14.5px; }
.drv-hist-sub { font-size: 12.5px; color: var(--label-2); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drv-hist-right { display: flex; align-items: center; gap: 8px; }
.drv-chip { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.chip-clear, .chip-approved { background: color-mix(in srgb, var(--green) 16%, transparent); color: color-mix(in srgb, var(--green) 60%, var(--label)); }
.chip-defect, .chip-pending { background: color-mix(in srgb, var(--amber) 22%, transparent); color: color-mix(in srgb, var(--amber) 60%, var(--label)); }
.chip-rejected { background: color-mix(in srgb, var(--red) 20%, transparent); color: color-mix(in srgb, var(--red) 62%, var(--label)); }
.chip-info { background: var(--fill); color: var(--label-2); }
.drv-chev { color: var(--label-3); opacity: .6; }
/* full-page history list */
.drv-hist-page { background: var(--card); border: 1px solid var(--separator); border-radius: 14px; box-shadow: var(--card-shadow); overflow: hidden; margin-top: 8px; }

/* detail view: read-only check + locked edit */
.drv-detail-items { border: 1px solid var(--separator); border-radius: 12px; overflow: hidden; margin-top: 6px; }
.drv-detail-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--separator); font-size: 14.5px; }
.drv-detail-item:last-child { border-bottom: none; }
.drv-ck { font-weight: 700; }
.drv-ck-pass { color: var(--green); }
.drv-ck-fail { color: var(--red); }
.drv-ck-na { color: var(--label-3); font-weight: 600; font-size: 12px; }
.drv-locked-note { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--label-2); background: var(--fill); border-radius: 10px; padding: 12px 14px; margin: 16px 0; }
.drv-btn-locked { background: var(--fill); color: var(--label-3); cursor: not-allowed; }

/* form pages */
.drv-form { padding: 0 0 40px; }
.drv-form-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 12px 12px;
  background: var(--bg-topbar); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--topbar-border);
}
.drv-form-head h2 { font-size: 17px; margin: 0; }
.drv-back { background: var(--fill); border: none; border-radius: 8px; font: inherit; font-weight: 600; color: var(--label); padding: 8px 12px; cursor: pointer; }
.drv-form-body { padding: 18px 16px; }
.drv-fieldnote { font-size: 12px; color: var(--label-3); margin: -8px 0 14px; }
.drv-missing {
  font-size: 13.5px; line-height: 1.4;
  color: color-mix(in srgb, var(--amber) 60%, var(--label));
  background: color-mix(in srgb, var(--amber) 13%, transparent);
  border-radius: 10px; padding: 11px 14px; margin: 4px 0 16px;
}
/* stacked Save / Submit (and Back / Confirm on the review page) */
.drv-ts-actions { display: grid; gap: 10px; padding: 2px 16px 10px; }

/* readonly (auto-filled) field pill */
.drv-readonly {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--fill); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px;
}
.drv-readonly .k { font-size: 13px; color: var(--label-2); font-weight: 600; }
.drv-readonly .v { font-weight: 600; }

/* structured (multi-line) address block */
.drv-addr-block { background: var(--fill); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.drv-addr-label { display: block; font-size: 13px; color: var(--label-2); font-weight: 600; margin-bottom: 4px; }
.drv-addr-block > div { line-height: 1.45; font-weight: 600; }

/* check-item rows with 3-state segmented control */
.chk-item { padding: 12px 0; border-bottom: 1px solid var(--separator); }
.chk-item .chk-label { font-size: 15px; margin-bottom: 8px; }
.seg3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.seg3 button {
  min-height: 44px; border: 1px solid var(--separator); background: var(--card);
  border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; color: var(--label-2);
}
.seg3 button[aria-pressed="true"][data-v="pass"] { background: var(--green); border-color: var(--green); color: #fff; }
.seg3 button[aria-pressed="true"][data-v="fail"] { background: var(--red); border-color: var(--red); color: #fff; }
.seg3 button[aria-pressed="true"][data-v="na"]   { background: var(--fill-strong); color: var(--label); }

.drv-section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--label-3); margin: 22px 2px 6px; }

/* toast */
.drv-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--label); color: var(--bg); padding: 14px 20px; border-radius: 12px;
  font-weight: 600; box-shadow: var(--card-shadow-hover); z-index: 50; max-width: 90%; text-align: center;
}

/* stack the home into a single column on narrow screens (phones) */
@media (max-width: 720px) {
  .drv-home-grid { grid-template-columns: 1fr; }
  .drv-hi { font-size: 23px; }
}

/* My Jobs — status advance cards */
.drv-job { border: 1px solid var(--separator); border-radius: 12px; padding: 12px 14px; margin: 0 0 12px; background: var(--card); text-align: left; }
.drv-job-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.drv-job-h b { font-size: 15px; }
.drv-job-st { font-size: 12px; font-weight: 700; color: var(--accent); }
.drv-job-route { font-size: 13px; color: var(--label-2); margin: 4px 0 12px; }
.drv-job-btn { width: 100%; }

/* capture sheet — mandatory job photos (load / unload+POD gates) */
.drv-capture-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.drv-capture { background: var(--card); color: var(--label); border-radius: var(--radius); box-shadow: var(--card-shadow); width: 100%; max-width: 460px; max-height: 90dvh; overflow-y: auto; padding: 18px; }
.drv-capture-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.drv-capture-head b { font-size: 18px; }
.drv-capture-x { border: none; background: none; font-size: 26px; line-height: 1; color: var(--label-2); cursor: pointer; padding: 0 4px; }
.drv-capslot { border: 1px solid var(--separator); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.drv-capslot-lbl { font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.drv-capslot-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.drv-capthumb, .drv-capadd { width: 68px; height: 68px; border-radius: 10px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; background-size: cover; background-position: center; }
.drv-capadd { border: 1.5px dashed var(--separator); cursor: pointer; font-size: 24px; background: var(--bg); }
.drv-capthumb { background-color: var(--bg); color: var(--label-2); }
.drv-capthumb.ready { color: transparent; position: relative; }
/* remove-photo × — corner-pinned on the thumbnail, kept a full 24px so it is tappable in a
   cab with gloves on, and dark-on-light so it stays visible over any photo */
.drv-capbin { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.72); color: #fff; font-size: 15px;
  line-height: 24px; text-align: center; cursor: pointer; }
.drv-capbin:disabled { opacity: .4; }
.drv-capover { margin-top: 10px; width: 100%; }
.drv-capslot select { margin-top: 10px; }
.drv-capture-done { width: 100%; margin-top: 4px; }

/* guided job flow */
.drv-jobpick { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--card); color: var(--label); border: 1px solid var(--separator); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.drv-jobpick-l b { display: block; font-size: 15px; }
.drv-jobpick-l small { color: var(--label-2); }
.drv-jobpick-r { text-align: right; white-space: nowrap; }
.drv-jobpick-r small { display: block; color: var(--label-2); }
.drv-badge { font-size: 12px; font-weight: 700; color: var(--accent); }
.drv-wiz { display: flex; flex-direction: column; gap: 12px; }
.drv-wiz-block { background: var(--card); border: 1px solid var(--separator); border-radius: 12px; padding: 12px 14px; }
.drv-wiz-block b { display: block; margin-bottom: 4px; color: var(--label-2); font-size: 13px; }
.drv-wiz-chk { background: var(--card); border: 1px solid var(--separator); border-radius: 12px; padding: 12px 14px; }
.drv-wiz-chk.done { border-color: var(--accent); }
.drv-btn-row { display: flex; gap: 8px; }
.drv-btn-row .drv-btn { flex: 1; }
/* in-progress jobs: pulsing orange, sat at the top of the list */
.drv-jobpick.inprogress { border-color: #ff9500; }
.drv-jobpick.inprogress .drv-jobpick-r small { color: #ff9500; font-weight: 700; }
@keyframes drvPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 149, 0, .5); } 50% { box-shadow: 0 0 0 6px rgba(255, 149, 0, 0); } }
@media (prefers-reduced-motion: no-preference) { .drv-jobpick.inprogress { animation: drvPulse 1.6s ease-in-out infinite; } }
.drv-jobpick.submitted { opacity: .55; }
.drv-jobpick.submitted .drv-jobpick-r small { color: var(--label-2); font-weight: 600; }

/* wizard: fill the screen so the action bar sits at the bottom */
#jobsView { display: flex; flex-direction: column; min-height: 100dvh; }
#jobsView .drv-wiz { flex: 1 1 auto; }
/* bottom-anchored action bar: [Break | Fuel] above the step-forward button */
.drv-wiz-actions { position: sticky; bottom: 0; z-index: 5; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; padding: 12px 0 max(12px, env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--separator); }
.drv-act-row { display: flex; gap: 8px; }
.drv-act-row .drv-btn { flex: 1; }
/* vehicle-check Yes/No: blue, smaller, side by side */
.drv-check-half { padding: 11px 10px; font-size: 14px; }
/* gated fields + buttons */
.drv-wiz input:disabled, .drv-btn:disabled { opacity: .45; cursor: not-allowed; }
/* On Break pane — minute-only countdown */
.drv-break-pane { text-align: center; padding: 48px 16px; }
.drv-break-pane h2 { margin: 0 0 6px; }
.drv-break-count { font-size: 46px; font-weight: 800; color: var(--accent); margin: 10px 0 6px; font-variant-numeric: tabular-nums; }
.drv-break-note { color: var(--label-2); margin: 0 0 22px; }
.drv-break-pane .drv-btn { max-width: 280px; margin: 0 auto; }

/* legibility: larger, clearer type on the guided-flow job screens (cab-readable) */
.drv-wiz label { font-size: 15px; }
.drv-wiz input, .drv-wiz select { font-size: 16px; }
.drv-wiz .drv-fieldnote { font-size: 14.5px; margin: -4px 0 12px; }
.drv-wiz .drv-readonly { font-size: 16px; }
.drv-wiz .drv-readonly .k { font-size: 14px; }
.drv-wiz .drv-readonly .v { font-size: 16px; font-weight: 600; }
.drv-wiz-block b { font-size: 14px; }
.drv-wiz-block div { font-size: 16px; }
.drv-form-head h2 { font-size: 19px; }
.drv-jobpick-l small { font-size: 13.5px; }

/* Start page: label inline (left) with its control (right) */
.drv-inline-field { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.drv-inline-field > span { flex: none; font-size: 15px; font-weight: 600; color: var(--label-2); }
.drv-inline-field > select, .drv-inline-field > input { flex: 1; min-width: 0; margin-top: 0; }
/* Assignment: taller, scrollable box */
.drv-assign { margin-bottom: 14px; }
.drv-assign-lbl { font-size: 14px; font-weight: 600; color: var(--label-2); margin-bottom: 6px; }
.drv-assign-box { min-height: 66px; max-height: 120px; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--fill); border: 1px solid var(--separator); border-radius: 10px; padding: 12px 14px; font-size: 16px; line-height: 1.45; }
/* standard "needs attention" cue — the same amber pulse/glow lozenge the office app uses
   (replicated from #driverUpdatesBtn.du-attn so the portal doesn't depend on the office sheet) */
.drv-lozenge { display: inline-block; }
.drv-attn {
  padding: 3px 10px; border-radius: 999px;
  color: color-mix(in srgb, var(--amber) 85%, var(--label));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--amber) 55%, transparent);
  animation: drv-attn-pulse 1.7s ease-in-out infinite;
}
@keyframes drv-attn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--amber) 42%, transparent); }
  50%      { box-shadow: 0 0 9px 1px color-mix(in srgb, var(--amber) 60%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .drv-attn { animation: none; box-shadow: 0 0 6px color-mix(in srgb, var(--amber) 45%, transparent); }
}
