/* TROYAMOTORS 3.6.6 — Wizard de diagnóstico y solicitud de repuestos.
 * Sistema UI nativo, accesible, responsive y aislado de estilos del tema.
 */
#spec-native-site,
.spec-diag-overlay,
.spec-diag-floating {
  --spec-diag-red: #ed1018;
  --spec-diag-red-dark: #b90008;
  --spec-diag-ink: #111318;
  --spec-diag-ink-soft: #2c3037;
  --spec-diag-muted: #707681;
  --spec-diag-line: rgba(17, 19, 24, 0.11);
  --spec-diag-line-strong: rgba(17, 19, 24, 0.18);
  --spec-diag-surface: #ffffff;
  --spec-diag-surface-soft: #f7f8fa;
  --spec-diag-focus: 0 0 0 4px rgba(237, 16, 24, 0.10);
}

/* Aislamiento: evita que Elementor/Hello/otros temas alteren el box model del modal. */
.spec-diag-overlay,
.spec-diag-overlay *,
.spec-diag-overlay *::before,
.spec-diag-overlay *::after,
.spec-diag-floating,
.spec-diag-floating *,
.spec-diag-floating *::before,
.spec-diag-floating *::after {
  box-sizing: border-box;
}

body.spec-diag-modal-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

body.spec-diag-modal-open .spec-diag-floating,
body.spec-diag-modal-open .scrpc-quote-button {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

/* El atributo hidden siempre gana. Esto evita que display:grid del campo muestre
 * inputs manuales, agenda o servicio que JavaScript decidió ocultar. */
.spec-diag-overlay [hidden],
.spec-diag-field[hidden],
.spec-diag-other[hidden],
.spec-diag-step[hidden],
.spec-diag-progress[hidden],
.spec-diag-form[hidden],
.spec-diag-success[hidden] {
  display: none !important;
}

.spec-diag-live,
.spec-diag-honeypot {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* CTA flotante */
.spec-diag-floating {
  position: fixed;
  left: max(22px, env(safe-area-inset-left));
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 120000;
  min-height: 58px;
  padding: 8px 16px 8px 9px;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.96);
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--spec-diag-ink);
  box-shadow: 0 18px 50px rgba(17, 19, 24, 0.18);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, opacity 0.2s ease;
}

.spec-diag-floating:hover {
  transform: translateY(-3px);
  border-color: rgba(237, 16, 24, 0.28);
  box-shadow: 0 22px 58px rgba(237, 16, 24, 0.20);
}

.spec-diag-floating-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ff2028, var(--spec-diag-red-dark));
  color: #fff;
  box-shadow: 0 10px 22px rgba(237, 16, 24, 0.24);
}

.spec-diag-floating-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spec-diag-floating > span:last-child { display: grid; text-align: left; }
.spec-diag-floating strong { font: 900 11px/1.15 Montserrat, Inter, sans-serif; text-transform: uppercase; }
.spec-diag-floating small { margin-top: 3px; color: var(--spec-diag-muted); font-size: 9px; font-weight: 700; }

/* Overlay y modal */
.spec-diag-overlay {
  position: fixed;
  inset: 0;
  z-index: 160000;
  padding: 18px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(10, 12, 16, 0.64);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overscroll-behavior: contain;
  isolation: isolate;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.spec-diag-overlay[hidden] { display: none !important; }

.spec-diag-modal {
  width: min(1000px, 100%);
  max-width: 100%;
  max-height: calc(100dvh - 36px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(255, 255, 255, 0.96);
  border-radius: 28px;
  background: linear-gradient(180deg, #fff 0%, #f7f8fa 100%);
  box-shadow: 0 35px 110px rgba(0, 0, 0, 0.34);
  color: var(--spec-diag-ink);
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(17, 19, 24, 0.30) transparent;
}

.spec-diag-modal::-webkit-scrollbar { width: 9px; }
.spec-diag-modal::-webkit-scrollbar-track { background: transparent; }
.spec-diag-modal::-webkit-scrollbar-thumb { background: rgba(17, 19, 24, 0.25); border: 3px solid transparent; border-radius: 99px; background-clip: padding-box; }

.spec-diag-modal-head {
  position: sticky;
  top: 0;
  z-index: 8;
  padding: 22px 26px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  border-bottom: 1px solid var(--spec-diag-line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.spec-diag-kicker {
  display: block;
  color: var(--spec-diag-red);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.spec-diag-modal-head h2 {
  margin: 5px 0;
  font: 900 italic clamp(25px, 3vw, 36px)/1 Montserrat, Inter, sans-serif;
  letter-spacing: -0.04em;
}

.spec-diag-modal-head p {
  margin: 0;
  max-width: 650px;
  color: var(--spec-diag-muted);
  font-size: 11px;
  line-height: 1.6;
}

.spec-diag-close {
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  flex: 0 0 42px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--spec-diag-ink);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.spec-diag-close:hover { background: var(--spec-diag-red); transform: rotate(4deg); }

/* Stepper */
.spec-diag-progress {
  padding: 18px 26px 6px;
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto;
  align-items: center;
  gap: 11px;
}

.spec-diag-progress button {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  color: #8a8f97;
  display: flex;
  align-items: center;
  gap: 8px;
  font: 850 10px/1.2 Inter, system-ui, sans-serif;
  cursor: pointer;
}

.spec-diag-progress button span {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(17, 19, 24, 0.14);
  background: #fff;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.spec-diag-progress button.active { color: var(--spec-diag-ink); }
.spec-diag-progress button.active span {
  border-color: var(--spec-diag-red);
  background: var(--spec-diag-red);
  color: #fff;
  box-shadow: 0 8px 20px rgba(237, 16, 24, 0.18);
}

.spec-diag-progress > i { height: 2px; min-width: 0; border-radius: 2px; background: #e7e9ed; }
.spec-diag-progress > i.is-complete { background: var(--spec-diag-red); }

/* Formulario */
.spec-diag-form {
  width: 100%;
  min-width: 0;
  padding: 18px 26px 26px;
  margin: 0;
}

.spec-diag-form[aria-busy="true"] { cursor: progress; }
.spec-diag-step { width: 100%; min-width: 0; animation: specDiagIn 0.22s ease both; }

.spec-diag-step-title {
  margin: 0 0 20px;
  display: flex;
  align-items: center;
  gap: 13px;
}

.spec-diag-step-title > span {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--spec-diag-ink);
  color: #fff;
  font: 900 12px/1 Montserrat, Inter, sans-serif;
}

.spec-diag-step-title h3 {
  margin: 0;
  font: 900 19px/1.2 Montserrat, Inter, sans-serif;
  letter-spacing: -0.03em;
}

.spec-diag-step-title p {
  margin: 4px 0 0;
  color: var(--spec-diag-muted);
  font-size: 11px;
  line-height: 1.5;
}

.spec-diag-grid {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 18px 20px;
}

.spec-diag-span-2 { grid-column: 1 / -1; }

.spec-diag-field {
  width: 100%;
  min-width: 0;
  margin: 0 !important;
  padding: 0 !important;
  display: grid;
  align-content: start;
  gap: 8px;
  color: var(--spec-diag-ink);
}

.spec-diag-field > span {
  display: block;
  margin: 0;
  color: #30343b;
  font-size: 10px;
  font-weight: 850;
  line-height: 1.35;
}

.spec-diag-field > span em {
  color: #858a92;
  font-style: normal;
  font-weight: 700;
}

/* Normalización fuerte de controles: neutraliza estilos globales del tema. */
.spec-diag-field input:not([type="file"]),
.spec-diag-field select,
.spec-diag-field textarea {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  border: 1px solid rgba(17, 19, 24, 0.14) !important;
  outline: 0 !important;
  border-radius: 15px !important;
  background: #fff !important;
  color: #15181d !important;
  font: 650 12px/1.4 Inter, system-ui, sans-serif !important;
  box-shadow: 0 8px 24px rgba(18, 20, 24, 0.035) !important;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.spec-diag-field input:not([type="file"]),
.spec-diag-field select {
  height: 54px !important;
  min-height: 54px !important;
  padding: 0 16px !important;
}

.spec-diag-field textarea {
  min-height: 126px !important;
  height: auto !important;
  padding: 15px 16px !important;
  resize: vertical;
  overflow-wrap: anywhere;
}

.spec-diag-field textarea[name="notes"] { min-height: 104px !important; }

.spec-diag-field input::placeholder,
.spec-diag-field textarea::placeholder { color: #a1a5ac !important; opacity: 1; }

.spec-diag-field select:disabled,
.spec-diag-field input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  background: #f0f1f3 !important;
}

.spec-diag-field input:not([type="file"]):hover:not(:disabled),
.spec-diag-field select:hover:not(:disabled),
.spec-diag-field textarea:hover:not(:disabled) {
  border-color: rgba(17, 19, 24, 0.24) !important;
}

.spec-diag-field input:not([type="file"]):focus,
.spec-diag-field select:focus,
.spec-diag-field textarea:focus {
  border-color: rgba(237, 16, 24, 0.82) !important;
  background: #fff !important;
  box-shadow: var(--spec-diag-focus) !important;
}

.spec-diag-field input[aria-invalid="true"],
.spec-diag-field select[aria-invalid="true"],
.spec-diag-field textarea[aria-invalid="true"],
.spec-diag-field .is-invalid {
  border-color: var(--spec-diag-red) !important;
  box-shadow: 0 0 0 4px rgba(237, 16, 24, 0.09) !important;
}

/* Neutraliza el azul de autocompletado de navegadores Chromium/WebKit. */
.spec-diag-field input:-webkit-autofill,
.spec-diag-field input:-webkit-autofill:hover,
.spec-diag-field input:-webkit-autofill:focus,
.spec-diag-field textarea:-webkit-autofill,
.spec-diag-field select:-webkit-autofill {
  -webkit-text-fill-color: #15181d !important;
  -webkit-box-shadow: 0 0 0 1000px #fff inset !important;
  box-shadow: 0 0 0 1000px #fff inset !important;
  caret-color: #15181d;
  transition: background-color 9999s ease-out 0s;
}

/* Carga de archivos */
.spec-diag-upload {
  position: relative;
  min-height: 116px;
  padding: 15px !important;
  border: 1px dashed rgba(17, 19, 24, 0.20);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.72);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.spec-diag-upload:hover,
.spec-diag-upload:focus-within {
  border-color: rgba(237, 16, 24, 0.42);
  background: #fff;
  box-shadow: 0 10px 26px rgba(17, 19, 24, 0.045);
}

.spec-diag-upload.has-files {
  border-style: solid;
  border-color: rgba(237, 16, 24, 0.30);
  background: rgba(237, 16, 24, 0.035);
}

.spec-diag-upload input[type="file"] {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 42px !important;
  margin: 0 !important;
  padding: 6px !important;
  border: 1px solid rgba(17, 19, 24, 0.10) !important;
  border-radius: 12px !important;
  background: #fff !important;
  color: #525862 !important;
  font: 700 10px/1.3 Inter, system-ui, sans-serif !important;
  box-shadow: none !important;
  cursor: pointer;
}

.spec-diag-upload input[type="file"]::file-selector-button {
  min-height: 34px;
  margin: 0 10px 0 0;
  padding: 0 13px;
  border: 0;
  border-radius: 9px;
  background: var(--spec-diag-ink);
  color: #fff;
  font: 850 9px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
  transition: background 0.18s ease;
}

.spec-diag-upload input[type="file"]:hover::file-selector-button { background: var(--spec-diag-red); }

.spec-diag-upload small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  color: #7b8088;
  font-size: 9px;
  line-height: 1.5;
}

.spec-diag-privacy {
  margin-top: 18px;
  padding: 13px 15px;
  border: 1px solid rgba(17, 19, 24, 0.06);
  border-radius: 14px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: rgba(17, 19, 24, 0.035);
  color: #646a72;
}

.spec-diag-privacy span { color: var(--spec-diag-red); font-weight: 900; }
.spec-diag-privacy p { margin: 0; font-size: 10px; line-height: 1.55; }

.spec-diag-error {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(185, 0, 8, 0.22);
  border-radius: 13px;
  background: rgba(237, 16, 24, 0.07);
  color: #8c0006;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.5;
}

/* Acciones siempre accesibles: no obliga a recorrer de nuevo todo el modal. */
.spec-diag-actions {
  position: sticky;
  bottom: 0;
  z-index: 7;
  min-width: 0;
  margin: 24px -26px -26px;
  padding: 15px 26px 18px;
  border-top: 1px solid var(--spec-diag-line);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(250, 250, 251, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 -12px 32px rgba(17, 19, 24, 0.035);
}

.spec-diag-actions-spacer { flex: 1; min-width: 0; }

.spec-diag-btn {
  min-height: 46px;
  max-width: 100%;
  padding: 0 18px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
  font: 850 10px/1.15 Montserrat, Inter, sans-serif;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.spec-diag-btn:hover { transform: translateY(-1px); }
.spec-diag-btn:disabled { cursor: wait; opacity: 0.70; transform: none; }
.spec-diag-btn-red { background: var(--spec-diag-red); color: #fff; box-shadow: 0 10px 24px rgba(237, 16, 24, 0.20); }
.spec-diag-btn-red:hover { background: #c90008; color: #fff; }
.spec-diag-btn-dark { background: var(--spec-diag-ink); color: #fff; }
.spec-diag-btn-dark:hover { background: var(--spec-diag-red); color: #fff; }
.spec-diag-btn-ghost { border-color: rgba(17, 19, 24, 0.12); background: #fff; color: #3e434b; }
.spec-diag-btn-ghost:hover { border-color: rgba(237, 16, 24, 0.28); color: var(--spec-diag-red); }

.spec-diag-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: specDiagSpin 0.7s linear infinite;
}

/* Estado final */
.spec-diag-success {
  padding: 42px 28px 38px;
  text-align: center;
  animation: specDiagIn 0.24s ease both;
}

.spec-diag-success-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ff2028, #b90008);
  color: #fff;
  font-size: 30px;
  font-weight: 900;
  box-shadow: 0 18px 38px rgba(237, 16, 24, 0.24);
}

.spec-diag-success h3 { margin: 8px 0; font: 900 clamp(23px, 3vw, 32px)/1.08 Montserrat, Inter, sans-serif; letter-spacing: -0.04em; }
.spec-diag-success > p { max-width: 580px; margin: 0 auto; color: var(--spec-diag-muted); font-size: 12px; line-height: 1.6; }
.spec-diag-success > strong { display: inline-block; margin-top: 16px; padding: 8px 12px; border-radius: 10px; background: var(--spec-diag-ink); color: #fff; font-size: 11px; letter-spacing: 0.04em; }
.spec-diag-success-warning { margin-top: 14px !important; color: #8a5200 !important; }
.spec-diag-success-actions { margin-top: 22px; display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }

.spec-diag-floating:focus-visible,
.spec-diag-close:focus-visible,
.spec-diag-progress button:focus-visible,
.spec-diag-btn:focus-visible,
.spec-diag-upload input[type="file"]:focus-visible {
  outline: 3px solid rgba(237, 16, 24, 0.30);
  outline-offset: 3px;
}

@keyframes specDiagIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@media (max-width: 760px) {
  .spec-diag-overlay { padding: 0; align-items: end; }

  .spec-diag-modal {
    width: 100%;
    max-height: 96dvh;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    scrollbar-gutter: auto;
  }

  .spec-diag-modal-head { padding: 18px 18px 15px; gap: 14px; }
  .spec-diag-modal-head p { font-size: 10px; }
  .spec-diag-close { width: 39px; height: 39px; min-width: 39px; min-height: 39px; flex-basis: 39px; }

  .spec-diag-progress { padding: 15px 18px 4px; gap: 7px; }
  .spec-diag-progress button b { display: none; }
  .spec-diag-progress button span { width: 30px; height: 30px; flex-basis: 30px; }

  .spec-diag-form { padding: 16px 18px calc(22px + env(safe-area-inset-bottom)); }
  .spec-diag-grid { grid-template-columns: 1fr; gap: 16px; }
  .spec-diag-span-2 { grid-column: auto; }
  .spec-diag-step-title { margin-bottom: 17px; }

  .spec-diag-actions {
    margin: 22px -18px calc(-22px - env(safe-area-inset-bottom));
    padding: 13px 18px calc(13px + env(safe-area-inset-bottom));
  }

  .spec-diag-actions .spec-diag-btn { flex: 1; min-width: 0; padding-inline: 12px; white-space: normal; text-align: center; }
  .spec-diag-actions-spacer { display: none; }
  .spec-diag-success { padding: 34px 18px calc(30px + env(safe-area-inset-bottom)); }
}

@media (max-width: 520px) {
  .spec-diag-floating {
    left: max(10px, env(safe-area-inset-left));
    bottom: max(10px, env(safe-area-inset-bottom));
    width: calc(50% - 15px);
    min-height: 54px;
    padding: 7px 9px 7px 8px;
    border-radius: 16px;
  }

  .spec-diag-floating-icon { width: 36px; height: 36px; flex-basis: 36px; border-radius: 11px; }
  .spec-diag-floating strong { font-size: 8.5px; line-height: 1.15; }
  .spec-diag-floating small { display: none; }

  .spec-diag-modal-head h2 { font-size: 24px; }
  .spec-diag-step-title > span { width: 40px; height: 40px; flex-basis: 40px; }
  .spec-diag-field input:not([type="file"]), .spec-diag-field select { height: 52px !important; min-height: 52px !important; }

  .spec-diag-actions { flex-wrap: wrap; }
  .spec-diag-actions .spec-diag-btn-ghost { flex: 0 0 auto; }
  .spec-diag-actions .spec-diag-btn-dark,
  .spec-diag-actions .spec-diag-btn-red { flex: 1 1 180px; }
}

@media (prefers-reduced-motion: reduce) {
  .spec-diag-floating,
  .spec-diag-close,
  .spec-diag-btn,
  .spec-diag-step,
  .spec-diag-success,
  .spec-diag-field input,
  .spec-diag-field select,
  .spec-diag-field textarea {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
  .spec-diag-spinner { animation-duration: 1.4s; }
}
