/* ============================================================
   vehicle-modal.css
   Selector de vehículo (año → marca → modelo).
   Reutiliza las variables de tema definidas en styles.css.
   ============================================================ */

/* ---------- Campo que abre el modal ---------- */
.vm-trigger { cursor: pointer; }
.vm-trigger:hover { border-color: #3a3d44; }
.vm-trigger:focus-visible { outline: none; border-color: var(--accent); }

/* ============================================================
   Overlay
   ============================================================ */
.vm-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 5, 6, .78);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity .24s ease;
}
.vm-overlay[hidden] { display: none; }
.vm-overlay.is-open { opacity: 1; }

/* ============================================================
   Diálogo
   ============================================================ */
.vm-dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 460px;
  max-height: min(640px, calc(100vh - 48px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  overflow: hidden;
  transform: translateY(14px) scale(.97);
  opacity: 0;
  transition: transform .26s cubic-bezier(.22, 1, .36, 1), opacity .2s ease;
}
.vm-overlay.is-open .vm-dialog { transform: none; opacity: 1; }

/* ---------- Encabezado ---------- */
.vm-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
}
.vm-head h2 {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  margin-right: auto;
}
.vm-head p {
  margin-top: 3px;
  font-size: .84rem;
  color: var(--muted);
}

.vm-close {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease;
}
.vm-close:hover { color: var(--text); border-color: var(--text); }

/* ---------- Pasos ---------- */
.vm-steps {
  display: flex;
  gap: 8px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.vm-step {
  flex: 1;
  min-width: 0;
  padding: 9px 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: .78rem;
  text-align: center;
  cursor: default;
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.vm-step strong {
  display: block;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .65;
  margin-bottom: 2px;
}
.vm-step span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Paso ya completado: se puede volver a él */
.vm-step.is-done { color: var(--text); cursor: pointer; }
.vm-step.is-done:hover { border-color: #3a3d44; }
/* Paso actual */
.vm-step.is-active {
  background: rgba(230, 57, 70, .1);
  border-color: var(--accent);
  color: var(--text);
}

/* ---------- Cuerpo ---------- */
.vm-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.vm-search-wrap { padding: 16px 22px 10px; }
.vm-search {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: .92rem;
  transition: border-color .2s ease;
}
.vm-search::placeholder { color: #5f636b; }
.vm-search:focus { outline: none; border-color: var(--accent); }
.vm-search-wrap[hidden] { display: none; }

/* ---------- Lista de opciones ---------- */
.vm-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 14px 16px;
  scrollbar-width: thin;
  scrollbar-color: #3a3d44 transparent;
}
.vm-list::-webkit-scrollbar { width: 8px; }
.vm-list::-webkit-scrollbar-thumb {
  background: #3a3d44;
  border-radius: 99px;
}

.vm-option {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: .95rem;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.vm-option:hover,
.vm-option:focus-visible {
  outline: none;
  background: var(--bg);
  border-color: #3a3d44;
}
.vm-option[aria-selected="true"] {
  background: rgba(230, 57, 70, .12);
  border-color: var(--accent);
  font-weight: 600;
}

/* Encabezado de grupo dentro de la lista */
.vm-group {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 14px 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.vm-group:first-child { padding-top: 4px; }

/* Buscador sin coincidencias */
.vm-vacio-busqueda {
  padding: 28px 14px;
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
}

/* ---------- Estados: cargando / error / vacío ---------- */
.vm-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  padding: 40px 24px;
  text-align: center;
}
.vm-state.is-visible { display: flex; }
.vm-state p { color: var(--muted); font-size: .9rem; max-width: 30ch; }

.vm-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: vm-spin .8s linear infinite;
}
@keyframes vm-spin { to { transform: rotate(360deg); } }

.vm-retry {
  padding: 9px 20px;
  background: none;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.vm-retry:hover { background: var(--accent); color: #fff; }

/* ---------- Pie ---------- */
.vm-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: var(--bg-alt);
}
.vm-summary {
  margin-right: auto;
  min-width: 0;
  font-size: .86rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vm-summary.is-complete { color: var(--text); font-weight: 600; }

.vm-btn {
  flex-shrink: 0;
  padding: 11px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, opacity .2s ease;
}
.vm-btn--cancel {
  background: none;
  border-color: var(--line);
  color: var(--muted);
}
.vm-btn--cancel:hover { border-color: var(--text); color: var(--text); }

.vm-btn--confirm { background: var(--accent); color: #fff; }
.vm-btn--confirm:hover:not(:disabled) { background: var(--accent-dk); }
.vm-btn--confirm:disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================
   Móvil: el diálogo se convierte en hoja inferior
   ============================================================ */
@media (max-width: 600px) {
  .vm-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .vm-dialog {
    max-width: none;
    max-height: 90vh;
    height: 90vh;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    transform: translateY(100%);
  }
  .vm-head,
  .vm-steps,
  .vm-search-wrap,
  .vm-foot { padding-inline: 18px; }

  .vm-foot { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .vm-summary { display: none; }
  .vm-btn { flex: 1; }
}

/* ============================================================
   Accesibilidad: sin animación si el usuario la desactivó
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .vm-overlay,
  .vm-dialog { transition: none; }
  .vm-spinner { animation-duration: 1.6s; }
}
