/**
 * Estilos específicos: Buscador de frecuencias de nombres y apellidos en España (INE)
 * Fijate Tools
 */

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

  /* Paleta cromática tema claro */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-subtle: #cbd5e1;

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

  --accent-brand: #2563eb;
  --accent-brand-hover: #1d4ed8;
  --accent-brand-light: #eff6ff;
  --accent-brand-text: #1e40af;

  --color-gold: #d97706;
  --color-green: #16a34a;
  --color-purple: #7c3aed;

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

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

/* Tema oscuro unificado con [data-theme="dark"] */
[data-theme="dark"] {
  --bg-page: #0b0f17;
  --bg-card: #151d2c;
  --bg-card-hover: #1e293b;
  --bg-input: #1a2336;
  --border-color: #27354f;
  --border-subtle: #334466;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --accent-brand: #3b82f6;
  --accent-brand-hover: #60a5fa;
  --accent-brand-light: rgba(59, 130, 246, 0.15);
  --accent-brand-text: #93c5fd;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

/* Reseteo y contención global */
*, *::before, *::after {
  box-sizing: border-box;
}

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

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

.text-mono {
  font-family: var(--font-mono);
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

/* Layout */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
  width: 100%;
}

@media (min-width: 1536px) {
  .tool-with-sidebar {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    width: 100%;
  }
}

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

/* 1. Tarjeta principal del buscador hero */
.ine-search-hero-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.hero-badge-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background-color: var(--accent-brand-light);
  color: var(--accent-brand-text);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-brand);
}

.hero-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.hero-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* Caja de búsqueda */
.search-box-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.search-input-group {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

@media (max-width: 640px) {
  .search-input-group {
    flex-direction: column;
  }
}

.search-input-wrap {
  position: relative;
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 48px;
  height: 48px;
  padding: 0.5rem 2.5rem 0.5rem 2.85rem;
  font-family: var(--font-main);
  font-size: 1rem;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  border-color: var(--accent-brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-btn {
  min-height: 48px;
  height: 48px;
  font-size: 0.95rem;
  padding: 0 1.25rem;
  white-space: nowrap;
}

/* Filtro tipo pill */
.search-controls-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-type-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.filter-type-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 0.25rem;
}

.btn-type-pill {
  background-color: var(--bg-page);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-type-pill:hover {
  border-color: var(--border-subtle);
}

.btn-type-pill.active {
  background-color: var(--accent-brand);
  color: #ffffff;
  border-color: var(--accent-brand);
}

/* Chips rápidos */
.quick-chips-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  overflow: hidden;
}

.chips-label {
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 600;
}

.chips-scroll {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.chips-scroll::-webkit-scrollbar {
  display: none;
}

.chip-example {
  background-color: var(--bg-page);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.chip-example:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

/* 2. Tarjeta resumen del nombre y termómetro */
.name-summary-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.name-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.name-type-badges {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.badge-tipo {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  background-color: var(--accent-brand-light);
  color: var(--accent-brand-text);
}

.badge-generacion {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  background-color: var(--border-color);
  color: var(--text-secondary);
}

.display-name {
  font-size: 2.1rem;
  margin-bottom: 0.2rem;
  color: var(--text-primary);
}

.display-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Termómetro demográfico */
.thermometer-box {
  background-color: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  min-width: 240px;
  display: flex;
  flex-direction: column;
}

@media (max-width: 640px) {
  .thermometer-box {
    width: 100%;
  }
}

.thermometer-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.thermometer-metric {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.thermometer-bar-wrap {
  width: 100%;
  height: 8px;
  background-color: var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.thermometer-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #38bdf8 0%, #22c55e 35%, #eab308 65%, #ef4444 100%);
  transition: width 0.4s ease;
}

.thermometer-caption {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Cuadrícula de KPIs */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 900px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 500px) {
  .metrics-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.metric-card {
  background-color: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

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

.metric-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

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

/* 3. Distribución geográfica y décadas */
.geo-distribution-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .geo-distribution-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.provincial-map-card, .decades-chart-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.card-header-clean {
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.15rem;
  margin-bottom: 0.2rem;
}

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

/* Lista coroplética provincial */
.provinces-heat-container {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 440px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.35rem;
}

.province-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 75px;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.84rem;
}

@media (max-width: 480px) {
  .province-row {
    grid-template-columns: 110px minmax(0, 1fr) 65px;
  }
}

.province-name {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.province-bar-track {
  width: 100%;
  height: 10px;
  background-color: var(--bg-page);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.province-bar-fill {
  height: 100%;
  background-color: var(--accent-brand);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.province-rate {
  text-align: right;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Gráfico de barras por décadas */
.decades-bars-container {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.decade-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 55px;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.84rem;
}

.decade-label {
  font-weight: 600;
  color: var(--text-secondary);
}

.decade-bar-track {
  width: 100%;
  height: 12px;
  background-color: var(--bg-page);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.decade-bar-fill {
  height: 100%;
  background-color: var(--accent-brand);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.decade-percent {
  text-align: right;
  font-weight: 700;
  color: var(--text-primary);
}

/* 4. Comparador dual */
.compare-module-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.compare-header {
  margin-bottom: 1rem;
}

.compare-title {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}

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

.compare-inputs-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.compare-inputs-row .form-input {
  flex: 1 1 200px;
}

.compare-vs {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--accent-brand);
}

.compare-results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

@media (max-width: 640px) {
  .compare-results-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.compare-col {
  background-color: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.compare-col-name {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.compare-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.86rem;
}

.compare-stat-row:last-child {
  border-bottom: none;
}

/* 5. Guía SEO y acordeón */
.ine-guide-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.guide-title {
  font-size: 1.35rem;
  margin-bottom: 1.25rem;
}

.guide-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.guide-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: var(--bg-page);
}

.guide-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.guide-summary::-webkit-details-marker {
  display: none;
}

.guide-arrow {
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.guide-item[open] .guide-arrow {
  transform: rotate(180deg);
}

.guide-content {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.guide-content p {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.guide-content ul, .guide-content ol {
  margin: 0;
  padding-left: 1.25rem;
}

.guide-content li {
  margin-bottom: 0.5rem;
}

/* Inputs y botones genéricos */
.form-input {
  min-height: 42px;
  height: 42px;
  padding: 0.5rem 0.85rem;
  font-family: var(--font-main);
  font-size: 0.92rem;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
  border-color: var(--accent-brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-primary, .btn-secondary {
  min-height: 42px;
  height: 42px;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0 1.15rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.btn-primary {
  background-color: var(--accent-brand);
  color: #ffffff;
  border: 1px solid var(--accent-brand);
}

.btn-primary:hover {
  background-color: var(--accent-brand-hover);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-clear {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
