/* Truck APD Insurance Form - Emblem Protect branding */
:root {
  --color-bg: #e9eef4;
  --color-surface: #ffffff;
  --color-text: #111111;
  --color-text-muted: #334155;
  --color-accent: #ffd233;
  --color-accent-hover: #002b4c;
  --color-navy: #002b4c;
  --color-border: #d1d9e0;
  --color-error: #b91c1c;
  --color-success: #166534;
  --font-display: 'Figtree', sans-serif;
  --font-body: 'Roboto', sans-serif;
  --radius: 4px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --touch-min: 44px;
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.form-container {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-lg);
  min-height: 100vh;
}
@media (min-width: 768px) { .form-container { padding: var(--space-xl); } }

.form-header { margin-bottom: var(--space-xl); }
.brand { margin-bottom: var(--space-sm); }
.brand-name {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-navy);
}
.form-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 var(--space-sm);
  color: var(--color-text);
}
@media (min-width: 768px) { .form-header h1 { font-size: 2.5rem; } }
.subtitle { margin: 0; color: var(--color-text-muted); font-size: 1rem; }

/* Progress stepper */
.progress-stepper {
  margin-bottom: var(--space-xl);
}
.progress-stepper ol {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: step;
}
.stepper-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  text-align: center;
}
/* Connector line between steps */
.stepper-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 14px;
  left: calc(50% + 16px);
  width: calc(100% - 32px);
  height: 2px;
  background: var(--color-border);
}
.stepper-step.completed:not(:last-child)::after {
  background: var(--color-navy);
}
.stepper-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  color: var(--color-text-muted);
  position: relative;
  z-index: 1;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.stepper-step.active .stepper-number {
  background: var(--color-navy);
  border-color: var(--color-navy);
  color: #fff;
}
.stepper-step.completed .stepper-number {
  background: var(--color-navy);
  border-color: var(--color-navy);
  color: #fff;
}
.stepper-label {
  margin-top: var(--space-xs);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
}
.stepper-step.active .stepper-label {
  color: var(--color-navy);
  font-weight: 600;
}
.stepper-step.completed .stepper-label {
  color: var(--color-navy);
}
@media (max-width: 479px) {
  .stepper-label { display: none; }
}

.form-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  animation: sectionFade 0.3s ease;
}
@keyframes sectionFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.form-section h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-accent);
  color: var(--color-text);
}

.section-desc { margin: 0 0 var(--space-md); color: var(--color-text-muted); font-size: 0.9rem; }

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 var(--space-lg);
}
fieldset:last-child { margin-bottom: 0; }
legend {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

.field { margin-bottom: var(--space-md); }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: var(--space-xs);
  color: var(--color-text);
}
.hint { font-weight: 400; color: var(--color-text-muted); font-size: 0.8rem; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: var(--font-body);
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  min-height: var(--touch-min);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--color-navy);
  outline-offset: 2px;
  border-color: var(--color-navy);
}
input::placeholder, textarea::placeholder { color: var(--color-text-muted); }
textarea { min-height: 80px; resize: vertical; }

/* Readonly carrier fields */
input[readonly],
textarea[readonly] {
  background: var(--color-bg);
  color: var(--color-text-muted);
  cursor: default;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}
@media (max-width: 479px) { .field-row { grid-template-columns: 1fr; } }
.field-row .field { margin-bottom: 0; }
.field-row.three-cols { grid-template-columns: 1fr 1fr 1fr; }
.field-row.four-cols { grid-template-columns: repeat(5, 1fr); }
.field-row.five-cols { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 767px) { .field-row.three-cols { grid-template-columns: 1fr; } .field-row.four-cols, .field-row.five-cols { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 479px) { .field-row.four-cols, .field-row.five-cols { grid-template-columns: 1fr 1fr; } }

.confirmation-field { margin-top: var(--space-md); }
.confirmation-question { font-weight: 500; margin-bottom: var(--space-sm); }
.radio-group { display: flex; gap: var(--space-lg); flex-wrap: wrap; }
.radio-group.inline { gap: var(--space-md); }
.radio-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  min-height: var(--touch-min);
  font-size: 1rem;
}
.radio-label input { width: auto; min-height: auto; accent-color: var(--color-navy); }

.status, .error {
  display: block;
  margin-top: var(--space-xs);
  font-size: 0.85rem;
}
.status { color: var(--color-text-muted); }
.status-warning { color: var(--color-navy); font-weight: 500; }
.error { color: var(--color-error); }
.error:not(:empty) {
  background: #fef2f2;
  border-left: 3px solid var(--color-error);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  margin-top: var(--space-sm);
}

/* Small CTA button variant */
.btn-sm {
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  min-height: 36px;
}
.carrier-actions {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

/* Truck accordion */
.truck-accordion {
  margin-bottom: var(--space-sm);
}
.truck-accordion-item {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: var(--space-sm);
  overflow: hidden;
}
.truck-accordion-item.expanded {
  overflow: visible;
}
.truck-accordion-item:last-child { margin-bottom: 0; }
.truck-accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--color-text);
  transition: background 0.2s;
}
.truck-accordion-header:hover { background: rgba(0,0,0,0.04); }
.truck-accordion-header .chevron {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-left: var(--space-sm);
  transition: transform 0.2s;
}
.truck-accordion-item.expanded .truck-accordion-header .chevron { transform: rotate(180deg); }
.truck-accordion-summary {
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}
.truck-accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.truck-accordion-item.expanded .truck-accordion-body {
  max-height: 4000px;
  overflow: visible;
}
.truck-accordion-inner {
  padding: 0 var(--space-lg) var(--space-lg);
  border-top: 1px solid var(--color-border);
}
.truck-accordion-inner .field { margin-bottom: var(--space-sm); }
.truck-accordion-inner .field-row { gap: var(--space-sm); }
/* Per-year mileage N/A checkbox */
.mileage-na {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-top: 2px;
  cursor: pointer;
}
.mileage-na input {
  width: auto;
  min-height: auto;
  accent-color: var(--color-navy);
}
/* Loan field disabled state (always visible, greyed when not financed) */
.truck-loan-field input:disabled {
  opacity: 0.4;
  background: var(--color-bg);
}

/* Switch field and toggle pill */
.switch-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.switch-field > label { margin-bottom: 0; }
.toggle-pill {
  display: inline-flex;
  position: relative;
  background: var(--color-border);
  border-radius: 999px;
  padding: 2px;
  min-width: 88px;
  width: 100%;
}
.toggle-pill .toggle-option {
  position: relative;
  z-index: 1;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: color 0.2s;
  min-width: 36px;
  user-select: none;
}
.toggle-pill input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}
/* Default state: "No" selected (first option active) */
.toggle-pill .toggle-option:first-of-type { color: var(--color-text); }
/* When "Yes" is checked, flip colors */
.toggle-pill:has(input[value="yes"]:checked) .toggle-option:first-of-type { color: var(--color-text-muted); }
.toggle-pill:has(input[value="yes"]:checked) .toggle-option:last-of-type { color: var(--color-text); }
/* Sliding indicator */
.toggle-pill::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(50% - 2px);
  height: calc(100% - 4px);
  background: var(--color-surface);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}
.toggle-pill:has(input[value="yes"]:checked)::before {
  transform: translateX(100%);
}

/* Compact truck layout */
.truck-compact-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.5fr 1fr;
  gap: var(--space-sm);
  align-items: end;
}
@media (max-width: 599px) {
  .truck-compact-row { grid-template-columns: 1fr 1fr; }
}

/* Multi-select dropdown */
.multi-select { position: relative; }
.multi-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: var(--font-body);
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  text-align: left;
  min-height: var(--touch-min);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.multi-select-trigger:hover { border-color: var(--color-navy); }
.multi-select-trigger[aria-expanded="true"] {
  outline: 2px solid var(--color-navy);
  outline-offset: 2px;
  border-color: var(--color-navy);
}
.multi-select-label {
  flex: 1;
  color: var(--color-text-muted);
}
.multi-select-label.has-selection { color: var(--color-text); }
.multi-select-trigger .chevron {
  width: 16px;
  height: 16px;
  margin-left: var(--space-sm);
  opacity: 0.6;
  transition: transform 0.2s;
}
.multi-select.open .multi-select-trigger .chevron { transform: rotate(180deg); }
.multi-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  padding: var(--space-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
}
.multi-select-dropdown[hidden] { display: none !important; }
.multi-select-dropdown label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  border-radius: 4px;
  margin-bottom: 0;
}
.multi-select-dropdown label:hover { background: var(--color-bg); }
.multi-select-dropdown label:last-child { margin-bottom: 0; }
.multi-select-dropdown input { width: auto; min-height: auto; accent-color: var(--color-navy); }

/* Upload checklist within each truck accordion */
.upload-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-md);
  margin-bottom: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}
.upload-section-header label {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0;
}
.btn-add-upload {
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  min-height: 36px;
}

.upload-checklist {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xs) var(--space-md);
}
@media (max-width: 479px) { .upload-checklist { grid-template-columns: 1fr; } }

.upload-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.upload-check .check-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.75rem;
  border: 1.5px solid var(--color-border);
  color: var(--color-border);
}
.upload-check.uploaded .check-icon {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}
.upload-check.uploaded {
  color: var(--color-text);
}
.upload-check .upload-filename {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-left: auto;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Upload modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-md);
}
.modal-overlay[hidden] { display: none !important; }
.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  padding: var(--space-lg);
  width: 100%;
  max-width: 420px;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.modal h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 var(--space-md);
}
.modal .field { margin-bottom: var(--space-md); }
.modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-md);
}

.output-summary {
  margin-bottom: var(--space-md);
  font-size: 0.9rem;
}
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
@media (max-width: 479px) { .summary-grid { grid-template-columns: 1fr; } }
.summary-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-md);
}
.summary-card-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}
.summary-card-value {
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text);
}
.summary-highlight {
  background: var(--color-navy);
  border-radius: var(--radius);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}
.summary-highlight-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.8);
}
.summary-highlight-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
}

.btn {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: var(--touch-min);
  transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible {
  outline: 2px solid var(--color-navy);
  outline-offset: 2px;
}
.truck-accordion-header:focus-visible {
  outline: 2px solid var(--color-navy);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--color-accent);
  color: #111111;
}
.btn-primary:hover { background: var(--color-accent-hover); color: #ffffff; }
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.form-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: space-between;
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

/* Submission progress */
.submission-progress {
  margin-top: var(--space-lg);
}
.progress-status {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
#progress-phase {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text);
}
#progress-detail {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.progress-bar-track {
  width: 100%;
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--color-navy);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.progress-file-status {
  margin-top: var(--space-sm);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

[hidden] { display: none !important; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: var(--space-xs);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading { opacity: 0.7; pointer-events: none; }
/* Field validation error states */
.field-invalid input,
.field-invalid textarea,
.field-invalid select {
  border-color: var(--color-error) !important;
}
.field-invalid .multi-select-trigger {
  border-color: var(--color-error) !important;
}
.field-error-msg {
  display: block;
  color: var(--color-error);
  font-size: 0.8rem;
  margin-top: var(--space-xs);
}
/* Upload check missing state (red X) */
.upload-check.missing .check-icon {
  background: var(--color-error);
  border-color: var(--color-error);
  color: #fff;
}
.upload-check.missing {
  color: var(--color-error);
}

.uploaded { color: var(--color-success); font-size: 0.85rem; }
