/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ASA Locadora — paleta oficial */
  --navy:      #141517;   /* @black  — header, footer, títulos */
  --navy-mid:  #1e2224;
  --navy-light:#3e494d;   /* @silver */
  --orange:    #e80911;   /* @red    — cor primária de ação */
  --orange-dk: #c5070f;   /* vermelho escuro */
  --orange-lt: #f9efde;   /* @yellowLight — fundo dos ícones */
  --yellow:    #fec42b;   /* @yellow — acento secundário */
  --green:     #1a9e5c;
  --green-bg:  #eafbf3;
  --red:       #e80911;   /* @red — erros e validação */
  --red-bg:    #fde8e9;
  --gray-50:   #fafafa;   /* @white */
  --gray-100:  #f3f3f3;   /* @shadow */
  --gray-200:  #e4e4e4;   /* @border */
  --gray-300:  #dbdbdb;   /* @line */
  --gray-400:  #8a9092;   /* @gray */
  --gray-500:  #8a9092;   /* @gray */
  --gray-700:  #3e494d;   /* @silver */
  --gray-900:  #141517;   /* @black */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.03);
  --shadow:    0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 40px rgba(20,21,23,.14);
  --transition: 200ms ease;
}

/* ── Tema escuro ─────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  /* Estrutura (cinzas/preto) → invertida para superfícies escuras */
  --navy:      #f1f3f5;   /* títulos passam a ser claros */
  --navy-mid:  #e3e6e8;
  --navy-light:#c7ccd1;
  --gray-50:   #202327;   /* superfície sutil */
  --gray-100:  #1b1e21;
  --gray-200:  #2e3237;   /* bordas */
  --gray-300:  #3c4046;
  --gray-400:  #6f757b;   /* placeholder */
  --gray-500:  #9aa0a6;   /* hints / descrições */
  --gray-700:  #c2c7cd;   /* labels */
  --gray-900:  #e8eaed;   /* texto principal */

  /* Cores de marca ASA — MANTIDAS iguais ao tema claro */
  --orange:    #e80911;   /* vermelho ASA */
  --orange-dk: #c5070f;
  --yellow:    #fec42b;   /* amarelo ASA */
  --green:     #1a9e5c;

  /* Apenas fundos de status viram tons escuros (o conteúdo continua na cor de marca) */
  --orange-lt: #202327;   /* fundo do ícone (o creme não funciona no escuro; o ícone segue vermelho) */
  --green-bg:  #15281d;
  --red:       #e80911;   /* vermelho ASA */
  --red-bg:    #2a1618;
}

/* Superfícies que usam branco fixo — sobrescritas no escuro */
[data-theme="dark"] body            { background: #141517; }
[data-theme="dark"] .site-header    { background: #1b1e21; box-shadow: 0 2px 12px rgba(0,0,0,.45); }
[data-theme="dark"] .form-card      { background: #1b1e21; }
[data-theme="dark"] .field-input    { background: #202327; }
[data-theme="dark"] .step-circle    { background: #202327; }
[data-theme="dark"] .btn-secondary  { background: #202327; }
[data-theme="dark"] .success-screen { background: #141517; }
[data-theme="dark"] .success-card   { background: #1b1e21; }
[data-theme="dark"] .site-footer    { background: #1b1e21; }
[data-theme="dark"] #toast          { background: #2e3237; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #f3f3f3;
  color: var(--gray-900);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.6;
}

/* Anima a troca de tema claro/escuro */
body,
.site-header,
.form-card,
.field-input,
.step-circle,
.btn-secondary,
.success-card,
.site-footer {
  transition: background-color .25s ease, border-color .25s ease, color .25s ease;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(0,0,0,.10);
  border-bottom: 3px solid var(--orange);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  position: relative;
}

/* ── Botão de tema (claro/escuro) ────────────────────────────────────────── */
.theme-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--gray-200);
  background: transparent;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--orange); color: var(--orange); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }

[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }

/* Coluna vazia à direita — equilibra a centralização do título */
.header-spacer { width: 80px; }

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: start;
  min-width: 0;
}

.logo-img {
  height: 48px;
  width: auto;
  display: block;
}

.logo-text {
  justify-self: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: .5px;
  white-space: nowrap;
}

.logo-accent { color: var(--orange); }

.header-tagline {
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 500;
  letter-spacing: .3px;
}

/* ── Main ────────────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 36px 16px 60px;
}

/* ── Card ────────────────────────────────────────────────────────────────── */
.form-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  overflow: hidden;
  border-top: 4px solid var(--orange);
}

/* ── Progress Steps ──────────────────────────────────────────────────────── */
.progress-steps {
  display: flex;
  align-items: center;
  padding: 20px 28px 0;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 20px;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-400);
  transition: all var(--transition);
  position: relative;
}

.step-num { display: block; }
.step-check { display: none; width: 18px; height: 18px; }

.step-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-400);
  transition: color var(--transition);
  white-space: nowrap;
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--gray-200);
  margin: 0 6px;
  margin-bottom: 20px;
  border-radius: 2px;
  transition: background var(--transition);
}

/* Active step */
.step.active .step-circle {
  border-color: var(--orange);
  background: var(--orange);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(232,9,17,.18);
}
.step.active .step-label { color: var(--orange-dk); font-weight: 600; }

/* Completed step */
.step.completed .step-circle {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}
.step.completed .step-num { display: none; }
.step.completed .step-check { display: block; }
.step.completed .step-label { color: var(--green); }
.step.completed + .step-line { background: var(--green); }

/* ── Form Sections ───────────────────────────────────────────────────────── */
.form-section { padding: 28px 32px; }
.form-section.hidden { display: none; }

.section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--gray-100);
}

.section-icon {
  width: 44px;
  height: 44px;
  background: var(--orange-lt);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(254,196,43,.3);
}

.section-icon svg {
  width: 22px;
  height: 22px;
  stroke: var(--orange-dk);
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}

.section-desc {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ── Fields Grid ─────────────────────────────────────────────────────────── */
.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 520px) {
  .fields-grid { grid-template-columns: 1fr; }
  .fields-grid > * { grid-column: 1 !important; }
}

.field-group { display: flex; flex-direction: column; gap: 5px; }
.cep-group { grid-column: 1; }

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

.required { color: var(--red); margin-left: 1px; }

.field-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--gray-900);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  outline: none;
}

.field-input::placeholder { color: var(--gray-400); }

.field-input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(232,9,17,.12);
}

.field-input[readonly] {
  background: var(--gray-50);
  color: var(--gray-500);
  cursor: not-allowed;
}

.field-input.is-valid {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26,158,92,.10);
}

.field-input.is-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(232,9,17,.10);
}

.field-error {
  font-size: 12px;
  color: var(--red);
  font-weight: 500;
  min-height: 16px;
  display: block;
}

.field-hint {
  font-size: 12px;
  color: var(--gray-500);
  display: block;
}

/* Input with inline action button */
.input-with-action {
  display: flex;
  gap: 8px;
}

.input-with-action .field-input { flex: 1; }

.btn-inline {
  flex-shrink: 0;
  white-space: nowrap;
}

/* Code input */
.code-input-wrapper {
  display: flex;
  gap: 8px;
}

.code-input {
  letter-spacing: 6px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  max-width: 160px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  font-family: inherit;
  line-height: 1;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 3px 10px rgba(232,9,17,.28);
}
.btn-primary:hover { background: var(--orange-dk); transform: translateY(-1px); box-shadow: 0 5px 16px rgba(232,9,17,.38); }
.btn-primary:active { transform: none; }

.btn-secondary {
  background: #ffffff;
  color: var(--navy);
  border: 1.5px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-100); border-color: var(--orange); color: var(--orange-dk); }

.btn-ghost {
  background: transparent;
  color: var(--gray-500);
  border: 1.5px solid var(--gray-200);
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-700); }

.btn-submit {
  background: var(--orange);
  color: #fff;
  padding: 12px 28px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(232,9,17,.32);
}
.btn-submit:hover { background: var(--orange-dk); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(232,9,17,.42); }
.btn-submit:active { transform: none; }

.link-btn {
  background: none;
  border: none;
  color: var(--orange);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
  padding: 0;
  line-height: inherit;
}
.link-btn:hover { color: var(--orange-dk); }
.link-btn.small { font-size: 12px; }
.link-btn.hidden { display: none; }

/* ── Section Nav ─────────────────────────────────────────────────────────── */
.section-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-100);
}

/* ── Verified badge ──────────────────────────────────────────────────────── */
.verified-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(26,158,92,.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
}
.verified-badge svg { width: 18px; height: 18px; flex-shrink: 0; stroke: var(--green); }
.verified-badge.hidden { display: none; }

/* ── Resend row ──────────────────────────────────────────────────────────── */
.resend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ── Verify box ──────────────────────────────────────────────────────────── */
.verify-box { grid-column: 1 / -1; }
.verify-box.hidden { display: none; }

/* ── CNH Upload ──────────────────────────────────────────────────────────── */
.cnh-upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition), background var(--transition);
  overflow: hidden;
}

.cnh-upload-area.drag-over {
  border-color: var(--orange);
  background: rgba(232,9,17,.04);
}

.file-input-hidden {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.upload-placeholder {
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.upload-icon {
  width: 64px;
  height: 64px;
  background: var(--gray-100);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.upload-icon svg {
  width: 38px;
  height: 38px;
  stroke: var(--gray-400);
}

.upload-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-700);
}

.upload-sub { font-size: 13px; color: var(--gray-500); margin-top: 6px; }
.upload-types { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

/* Botões de ação do upload (tirar foto / escolher arquivo) */
.upload-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 8px 0 2px;
}

/* O botão de câmera só aparece em dispositivos com toque (celular/tablet) */
.upload-btn-camera { display: none; }
@media (pointer: coarse) {
  .upload-btn-camera { display: inline-flex; }
}

/* Preview */
.upload-preview {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.upload-preview.hidden { display: none; }

.upload-preview img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
}

.preview-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.preview-filename {
  font-size: 13px;
  color: var(--gray-700);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* PDF preview */
.pdf-preview-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px;
  color: var(--orange-dk);
  font-size: 13px;
  font-weight: 600;
}
.pdf-preview-icon.hidden { display: none; }
.pdf-preview-icon svg { width: 52px; height: 52px; stroke: var(--orange); }

/* CNH status area */
.cnh-status { display: flex; align-items: center; gap: 10px; }
.cnh-status-idle { display: flex; gap: 8px; }

/* OCR result */
.ocr-result {
  margin: 12px 0 0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.ocr-result.hidden { display: none; }

.ocr-result svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.ocr-result.success {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(26,158,92,.2);
}
.ocr-result.success svg { stroke: var(--green); }

.ocr-result.error {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(232,9,17,.2);
}
.ocr-result.error svg { stroke: var(--red); }

.ocr-result.info {
  background: var(--orange-lt);
  color: var(--orange-dk);
  border: 1px solid rgba(254,196,43,.3);
}
.ocr-result.info svg { stroke: var(--orange-dk); }

/* Spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
.spinner.dark {
  border-color: rgba(232,9,17,.15);
  border-top-color: var(--orange);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Success Screen ──────────────────────────────────────────────────────── */
.success-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f3f3f3;
  z-index: 200;
  padding: 24px;
  animation: fadeIn .3s ease;
}
.success-screen.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.success-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border-top: 4px solid var(--orange);
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 460px;
  width: 100%;
  animation: popIn .4s cubic-bezier(.175, .885, .32, 1.275);
}

.success-icon { margin-bottom: 8px; }
.success-icon svg { width: 80px; height: 80px; }

@keyframes popIn {
  from { transform: scale(.85); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.success-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  margin-top: 16px;
}

.success-msg {
  font-size: 15px;
  color: var(--gray-500);
  line-height: 1.7;
  margin-top: 10px;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--navy);
  padding: 14px 24px;
  text-align: center;
  border-top: 3px solid var(--orange);
}
.site-footer p { font-size: 12px; color: rgba(255,255,255,.4); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  transition: all .3s ease;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(80px);
  opacity: 0;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.toast-success { background: var(--green); }
#toast.toast-error   { background: var(--red); }
#toast.toast-info    { background: var(--orange); }

/* ── Section slide-in animation ──────────────────────────────────────────── */
@keyframes slideIn {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}
.form-section:not(.hidden) { animation: slideIn .25s ease; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

/* Tablets e telas médias */
@media (max-width: 680px) {
  .main-content { padding: 24px 12px 48px; }
  .form-section { padding: 24px 22px; }
  .header-inner { padding: 12px 18px; }
  .logo-img { height: 42px; }
  .logo-text { font-size: 22px; }
}

/* Celulares */
@media (max-width: 640px) {
  .form-section { padding: 20px 18px; }
  .progress-steps { padding: 16px 14px 14px; gap: 0; }
  .step-label { display: none; }
  .step-circle { width: 32px; height: 32px; font-size: 13px; }
  .step-line { margin-bottom: 0; }
  .header-tagline { display: none; }

  /* Evita o zoom automático do iOS ao focar um campo (precisa ser >= 16px) */
  .field-input { font-size: 16px; padding: 12px 14px; }

  /* Botões de navegação ocupam a largura toda e ficam fáceis de tocar */
  .section-nav { flex-wrap: wrap; gap: 10px; }
  .section-nav button { flex: 1; justify-content: center; padding: 13px 16px; }
  .btn-submit { width: 100%; justify-content: center; }

  /* Toast ocupa a largura da tela com margens */
  #toast { left: 12px; right: 12px; bottom: 16px; max-width: none; }
}

/* Celulares: empilha a logo e o título — impossível sobrepor em qualquer largura */
@media (max-width: 520px) {
  .header-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 6px;
  }
  .logo { justify-self: center; }
  .logo-img { height: 40px; }
  .logo-text { justify-self: center; font-size: 20px; }
  .header-spacer { display: none; }

  /* Campo + botão de ação empilham verticalmente (CEP/Buscar, E-mail/Enviar código) */
  .input-with-action { flex-direction: column; }
  .input-with-action .btn-inline { width: 100%; justify-content: center; padding: 12px; }

  /* Código de verificação ocupa a largura toda */
  .code-input { max-width: none; flex: 1; }

  /* Card de sucesso com menos padding lateral */
  .success-card { padding: 40px 24px; }
  .success-title { font-size: 22px; }
}

/* Telas muito estreitas */
@media (max-width: 360px) {
  .logo-text { font-size: 18px; }
  .section-title { font-size: 16px; }
  .section-icon { width: 38px; height: 38px; }
}
