/**
 * Estilos canónicos para: Última matrícula DGT y buscador de fechas
 * fijate.com/tools/ultima-matricula-dgt/
 */

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

  /* Paleta oscura Midnight Slate (Predeterminada) */
  --bg-app: #0b0f17;
  --bg-card: #131b26;
  --bg-card-sub: #182232;
  --bg-hover: #1e2b3e;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #0077ff;
  
  --text-main: #f1f5f9;
  --text-sub: #94a3b8;
  --text-muted: #cbd5e1;

  /* Acentos temáticos */
  --dgt-blue: #0066cc;
  --dgt-blue-hover: #0052a3;
  --dgt-blue-light: rgba(0, 102, 204, 0.15);
  --dgt-accent: #00d2ff;
  --dgt-gold: #ffb703;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;

  /* Placa de matrícula */
  --plate-bg: #f8fafc;
  --plate-text: #0f172a;
  --plate-border: #94a3b8;
  --plate-blue: #003399;
}

[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-sub: #f1f5f9;
  --bg-hover: #e2e8f0;
  --border-color: #e2e8f0;
  --border-focus: #0066cc;

  --text-main: #0f172a;
  --text-sub: #475569;
  --text-muted: #64748b;

  --dgt-blue: #0066cc;
  --dgt-blue-hover: #0052a3;
  --dgt-blue-light: rgba(0, 102, 204, 0.1);
  --dgt-accent: #0284c7;

  --plate-bg: #ffffff;
  --plate-text: #020617;
  --plate-border: #64748b;
}

/* Reset y base */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-main);
  margin-top: 0;
  line-height: 1.25;
}

/* Layout y contención canónica */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
}

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

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

.tool-ad-sidebar {
  display: none;
}

@media (min-width: 1536px) {
  .tool-with-sidebar {
    max-width: 1480px;
  }
  .tool-ad-sidebar {
    display: block;
    width: 300px;
    flex-shrink: 0;
  }
}

/* Tarjeta principal */
.card-main {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
}

@media (min-width: 768px) {
  .card-main {
    padding: 2rem;
  }
}

/* Barra de navegación por pestañas */
.tool-nav-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.nav-tab-btn {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.15rem;
  border-radius: 0.65rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-sub);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  transition: all 0.2s ease;
  min-height: 42px;
}

.nav-tab-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.nav-tab-btn.active {
  background-color: var(--dgt-blue-light);
  color: var(--dgt-accent);
  border-color: rgba(0, 102, 204, 0.35);
}

[data-theme="light"] .nav-tab-btn.active {
  color: var(--dgt-blue);
  border-color: var(--dgt-blue);
  background-color: #e0f2fe;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

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

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

/* ----------------------------------------------------
   COMPONENTE: Placa de Matrícula Española Hiperrealista
   ---------------------------------------------------- */
.spanish-license-plate {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border: 2.5px solid #1e293b;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
  user-select: all;
  margin: 0.5rem 0;
}

/* Placa grande hero */
.spanish-license-plate.plate-hero {
  padding: 0;
  height: 72px;
  min-width: 290px;
}

@media (min-width: 640px) {
  .spanish-license-plate.plate-hero {
    height: 84px;
    min-width: 340px;
  }
}

/* Banda europea azul lateral */
.plate-eu-band {
  background-color: var(--plate-blue);
  width: 44px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
  box-shadow: inset -1px 0 2px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .plate-eu-band {
    width: 52px;
  }
}

.plate-eu-stars-svg {
  width: 22px;
  height: 22px;
  display: block;
}

.plate-country-code {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1;
  margin-top: 2px;
  letter-spacing: -0.5px;
}

/* Texto de dígitos y letras de la placa */
.plate-number-text {
  font-family: var(--font-mono);
  font-size: 2.15rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 4px;
  padding: 0 1.25rem 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8), 0 -1px 1px rgba(0, 0, 0, 0.4);
}

@media (min-width: 640px) {
  .plate-number-text {
    font-size: 2.65rem;
    letter-spacing: 6px;
    padding: 0 1.75rem 0 1.25rem;
  }
}

.plate-digits,
.plate-letters,
.spanish-license-plate .plate-letters,
.spanish-license-plate .plate-digits {
  color: #0f172a !important;
}

/* Remaches decorativos */
.plate-bolt {
  position: absolute;
  width: 6px;
  height: 6px;
  background: radial-gradient(circle at 35% 35%, #e2e8f0, #475569);
  border-radius: 50%;
  border: 1px solid #1e293b;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.8), 0 1px 2px rgba(0,0,0,0.4);
}
.plate-bolt-tl { top: 6px; left: 52px; }
.plate-bolt-tr { top: 6px; right: 8px; }
.plate-bolt-bl { bottom: 6px; left: 52px; }
.plate-bolt-br { bottom: 6px; right: 8px; }

/* Tarjetas de estadísticas y KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}

@media (min-width: 640px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.kpi-card {
  background-color: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

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

.kpi-label {
  font-size: 0.85rem;
  color: var(--text-sub);
  font-weight: 500;
}

.kpi-icon {
  font-size: 1.25rem;
  color: var(--dgt-accent);
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.kpi-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Formularios canónicos y controles táctiles */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.45rem;
  color: var(--text-main);
}

.input-plate-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-plate-control {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  width: 100%;
  height: 52px;
  padding: 0.5rem 1rem;
  background-color: var(--bg-card-sub);
  border: 1.5px solid var(--border-color);
  border-radius: 0.65rem;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.input-plate-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.2);
}

.input-plate-control::placeholder {
  color: var(--text-sub);
  opacity: 0.6;
}

.form-select-canonical {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 44px;
  padding: 0.5rem 2.5rem 0.5rem 1rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  background-color: var(--bg-card-sub);
  color: var(--text-main);
  border: 1.5px solid var(--border-color);
  border-radius: 0.65rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 16px;
  cursor: pointer;
}

.form-select-canonical:focus {
  outline: none;
  border-color: var(--border-focus);
}

.form-select-canonical option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

/* Botón principal */
.btn-dgt-primary {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, var(--dgt-blue) 0%, var(--dgt-blue-hover) 100%);
  color: #ffffff;
  border: none;
  border-radius: 0.65rem;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

.btn-dgt-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-dgt-primary:active {
  transform: translateY(0);
}

/* Tarjeta de resultados */
.result-card {
  background-color: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: 0.85rem;
  padding: 1.5rem;
  margin-top: 1.5rem;
}

/* Distintivo ambiental DGT */
.badge-dgt-container {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.95rem;
}

.badge-dgt-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.25rem;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.badge-dgt-cero { background: radial-gradient(circle at 35% 35%, #0099ff, #0052a3); }
.badge-dgt-eco { background: radial-gradient(circle at 35% 35%, #10b981, #009944); }
.badge-dgt-c { background: radial-gradient(circle at 35% 35%, #22c55e, #15803d); }
.badge-dgt-b { background: radial-gradient(circle at 35% 35%, #fbbf24, #d97706); color: #020617; }
.badge-dgt-sin { background: radial-gradient(circle at 35% 35%, #94a3b8, #475569); }

/* Calendario del mes interactivo */
.history-calendar-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.875rem;
}

.history-calendar-table th {
  padding: 0.65rem 0.5rem;
  text-align: left;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-sub);
  font-weight: 600;
}

.history-calendar-table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.history-calendar-table tr:hover td {
  background-color: var(--bg-hover);
}

/* Modales canónicos accesibles */
.modal-backdrop-custom {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
}

.modal-backdrop-custom.active {
  display: flex;
}

.modal-content-custom {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.modal-header-custom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.btn-close-modal:hover {
  color: var(--text-main);
}

/* Barra de progreso global del sistema de matrículas */
.progress-bar-container {
  background-color: var(--bg-card-sub);
  border-radius: 9999px;
  height: 14px;
  overflow: hidden;
  margin: 0.75rem 0;
  position: relative;
  border: 1px solid var(--border-color);
}

.progress-bar-fill {
  background: linear-gradient(90deg, #0066cc 0%, #00d2ff 100%);
  height: 100%;
  border-radius: 9999px;
  transition: width 0.6s ease;
}

/* FAQ y sección informativa */
.faq-accordion {
  margin-top: 1.5rem;
}

.faq-item {
  background-color: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: 0.65rem;
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.faq-question {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  user-select: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-answer {
  padding: 0 1.25rem 1rem;
  color: var(--text-muted);
  font-size: 0.925rem;
  line-height: 1.6;
}

/* Utilidades */
.text-accent { color: var(--dgt-accent); }
.text-gold { color: var(--dgt-gold); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.font-mono { font-family: var(--font-mono); }
