/**
 * Estilos para el Detector y Decodificador de Hot Wheels
 * Paleta deportiva de carreras, compatible con temas claro y oscuro
 * Estándares fijate.com (Mobile-first, botones >= 40px, selects anti-desbordamiento)
 */

:root {
  --font-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Colores tema oscuro */
  --bg-page: #0a0d14;
  --bg-surface: #111722;
  --bg-surface-elevated: #1a2233;
  --bg-surface-hover: #222d42;
  --border-color: rgba(255, 255, 255, 0.09);
  --border-color-focus: #f59e0b;

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --hw-red: #ef4444;
  --hw-orange: #f97316;
  --hw-gold: #f59e0b;
  --hw-blue: #2563eb;
  --emerald: #10b981;
  --rose: #e11d48;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.6);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --border-color: rgba(0, 0, 0, 0.1);
  --border-color-focus: #d97706;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.12);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: clip;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  margin-top: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.main-wrapper.tool-layout {
  width: 100%;
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  max-width: 100%;
}

/* Navegación por pestañas */
.hw-nav-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.75rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.hw-nav-tabs::-webkit-scrollbar {
  display: none;
}

.hw-nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  transition: all var(--transition-fast);
}

.hw-nav-tab:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.hw-nav-tab.is-active {
  color: var(--hw-orange);
  border-bottom-color: var(--hw-orange);
}

.hw-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 700;
}

.hw-tab-pane {
  display: none;
  animation: fadeIn 0.2s ease;
}

.hw-tab-pane.is-active {
  display: block;
}

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

/* Formularios y controles */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  min-height: 42px;
  padding: 0 0.85rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

select.form-control {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}

.form-control:focus {
  border-color: var(--border-color-focus);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

/* Tarjeta del decodificador */
.decoder-card-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
}

.decoder-input-row {
  display: flex;
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}

.code-input-large {
  flex: 1 1 auto;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

.btn-primary-action {
  height: 42px;
  min-height: 42px;
  padding: 0 1.5rem;
  background: linear-gradient(135deg, var(--hw-orange), #d97706);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.btn-primary-action:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.quick-codes-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn-quick-code {
  height: 32px;
  padding: 0 0.75rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-quick-code:hover {
  border-color: var(--hw-orange);
  color: var(--hw-orange);
}

/* Resultados de decodificación */
.hw-decode-card {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  border: 1px solid rgba(245, 158, 11, 0.3);
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.06);
}

.decode-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.decode-badge-code {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--hw-orange);
  background: rgba(249, 115, 22, 0.12);
  padding: 0.25rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.decode-badge-year {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.decode-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.metric-cell {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.metric-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.metric-val {
  display: block;
  font-size: 1.25rem;
  font-family: var(--font-heading);
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.decode-explanation-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: var(--radius-sm);
  color: #93c5fd;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.decode-explanation-box p {
  margin: 0;
}

.decode-factory-info h4 {
  font-size: 0.9rem;
  margin: 0 0 0.5rem;
  color: var(--text-secondary);
}

.factory-list {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.factory-list li {
  margin-bottom: 0.25rem;
}

.hw-alert-error {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  color: #fca5a5;
  font-size: 0.9rem;
}

.hw-alert-error p {
  margin: 0.25rem 0 0;
}

/* Módulo 2: Test guiado en tienda */
.store-test-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
}

.store-steps-flow {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.store-step-block {
  padding: 1.25rem;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.store-step-title {
  font-size: 1rem;
  margin: 0 0 0.25rem;
}

.store-step-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.store-choices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.store-choice-btn {
  min-height: 48px;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  transition: all var(--transition-fast);
}

.store-choice-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.store-choice-btn.is-selected {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.2), rgba(245, 158, 11, 0.2));
  border-color: var(--hw-orange);
  color: #ffffff;
  box-shadow: 0 0 0 1px var(--hw-orange);
}

.verdict-banner {
  display: flex;
  gap: 1.25rem;
  padding: 1.5rem;
  border-radius: var(--radius-md);
  animation: fadeIn 0.25s ease;
}

.verdict-sth {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(239, 68, 68, 0.15));
  border: 2px solid var(--hw-gold);
}

.verdict-th {
  background: rgba(37, 99, 235, 0.15);
  border: 2px solid var(--hw-blue);
}

.verdict-mainline {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
}

.verdict-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.verdict-badge {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.25rem;
}

.verdict-sth .verdict-badge { color: var(--hw-gold); }
.verdict-th .verdict-badge { color: #60a5fa; }
.verdict-mainline .verdict-badge { color: var(--text-muted); }

.verdict-title {
  font-size: 1.25rem;
  margin: 0 0 0.5rem;
}

.verdict-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0 0 1rem;
}

.verdict-checklist-summary {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.verdict-sth .verdict-checklist-summary { color: #fde68a; }
.verdict-th .verdict-checklist-summary { color: #bfdbfe; }

.store-pending-hint {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
}

/* Catálogo TH / Super TH */
.catalog-filter-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.catalog-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.th-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.th-car-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.th-car-card:hover {
  transform: translateY(-2px);
}

.th-car-card.is-super-card {
  border-color: rgba(245, 158, 11, 0.4);
}

.th-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.th-badge-mix {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.th-badge-type {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}

.badge-sth {
  background: rgba(245, 158, 11, 0.2);
  color: var(--hw-gold);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-th {
  background: rgba(37, 99, 235, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(37, 99, 235, 0.4);
}

.th-car-name {
  font-size: 1.15rem;
  margin: 0 0 0.2rem;
}

.th-car-series {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  display: block;
  margin-bottom: 0.75rem;
}

.th-specs-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

.th-spec-row {
  display: flex;
  gap: 0.4rem;
}

.spec-label {
  color: var(--text-muted);
  min-width: 120px;
}

.spec-val {
  color: var(--text-primary);
}

.highlight-distintivo {
  color: #fde68a;
  font-weight: 600;
}

.th-tips-box {
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.btn-toggle-garage {
  width: 100%;
  height: 40px;
  min-height: 40px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-toggle-garage:hover {
  background: var(--bg-surface-hover);
  border-color: var(--hw-orange);
}

.btn-toggle-garage.is-in-garage {
  background: var(--emerald);
  color: #ffffff;
  border-color: var(--emerald);
}

/* Guía de blíster */
.blister-guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.blister-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.blister-title {
  font-size: 1.15rem;
  margin: 0 0 0.5rem;
}

.blister-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--hw-orange);
  background: rgba(249, 115, 22, 0.15);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.75rem;
}

.blister-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Garaje */
.garage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
}

.garage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.garage-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.garage-item-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.garage-item-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.garage-item-name {
  font-size: 0.9rem;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.garage-item-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-remove-garage {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.btn-remove-garage:hover {
  color: var(--rose);
}

.empty-garage-box {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-surface);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
}

.empty-garage-box svg {
  margin-bottom: 0.75rem;
  opacity: 0.6;
}

.empty-garage-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--text-primary);
  margin: 0 0 0.5rem;
}

.empty-garage-desc {
  font-size: 0.9rem;
  max-width: 480px;
  margin: 0 auto;
}

/* Modales */
.hw-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.hw-modal.is-active {
  opacity: 1;
  pointer-events: auto;
}

.hw-modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.btn-modal {
  height: 42px;
  min-height: 42px;
  padding: 0 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-modal-cancel {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-modal-ok {
  background: var(--rose);
  border: none;
  color: #ffffff;
}

.modal-textarea {
  width: 100%;
  height: 180px;
  padding: 0.75rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  resize: vertical;
  margin-bottom: 1.25rem;
}

/* Toast */
.hw-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(10px);
  transition: all var(--transition-fast);
}

.hw-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.hw-toast.toast-success .toast-icon { color: var(--emerald); }
.hw-toast.toast-info .toast-icon { color: var(--hw-orange); }

@media (max-width: 768px) {
  .decoder-input-row {
    flex-direction: column;
  }

  .btn-primary-action {
    width: 100%;
  }

  .catalog-filter-bar {
    flex-direction: column;
  }

  .hw-toast {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }
}
