/**
 * Fijate Tools - Máquina del Tiempo de la Peseta y la Inflación
 * Hoja de estilos corporativa con soporte completo de tema claro y oscuro.
 */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Tema Claro canónico */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-header: #f1f5f9;
  --bg-card-subtle: #f8fafc;
  --bg-input: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;

  /* Identidad Numismática & Peseta */
  --gold-primary: #b48a1c;
  --gold-hover: #967012;
  --gold-light: #fef9c3;
  --gold-glow: rgba(180, 138, 28, 0.25);
  --green-peseta: #166534;
  --green-peseta-light: #dcfce7;
  --primary-color: #0284c7;
  --primary-light: #e0f2fe;

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

[data-theme="dark"] {
  --bg-page: #0b1120;
  --bg-card: #151e2e;
  --bg-card-header: #1e293b;
  --bg-card-subtle: #192436;
  --bg-input: #0f172a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-hover: #475569;

  --gold-primary: #d4af37;
  --gold-hover: #e6c555;
  --gold-light: rgba(212, 175, 55, 0.15);
  --gold-glow: rgba(212, 175, 55, 0.3);
  --green-peseta: #22c55e;
  --green-peseta-light: rgba(34, 197, 94, 0.15);
  --primary-color: #38bdf8;
  --primary-light: rgba(56, 189, 248, 0.15);

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

/* Reset y Contención */
*, *::before, *::after {
  box-sizing: border-box;
}

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

h1, h2, h3, h4, h5, h6,
.section-title,
.hero-title,
.card-title {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 0.5rem;
}

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

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

.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

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

/* Hero Introductorio */
.tool-hero-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.tool-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.825rem;
  font-weight: 600;
  background: var(--gold-light);
  color: var(--gold-primary);
  border: 1px solid rgba(212, 175, 55, 0.3);
  margin-bottom: 0.75rem;
}

.tool-main-title {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
  .tool-main-title {
    font-size: 2.35rem;
  }
}

.tool-main-desc {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 780px;
  margin: 0 auto;
}

/* Presets Rápidos Virales */
.presets-section {
  margin-bottom: 2rem;
}

.section-eyebrow {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold-primary);
  font-weight: 700;
  margin-bottom: 0.25rem;
  display: block;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 0.85rem;
}

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

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

.preset-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
  width: 100%;
}

.preset-card:hover, .preset-card:focus-visible {
  border-color: var(--gold-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--gold-glow);
}

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

.preset-year-tag {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--gold-light);
  color: var(--gold-primary);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.preset-amount-tag {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.preset-card-title {
  font-size: 0.95rem;
  margin: 0 0 0.25rem;
  color: var(--text-main);
}

.preset-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.35;
}

/* Formulario Principal de la Máquina del Tiempo */
.calculator-box {
  background: var(--bg-card-subtle);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

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

/* Conmutador de Divisa */
.currency-selector-row {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.currency-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 4px;
  width: 100%;
  max-width: 380px;
}

.currency-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 40px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.currency-tab-btn.active {
  background: var(--gold-primary);
  color: #ffffff;
  box-shadow: 0 2px 6px var(--gold-glow);
}

/* Cuadrícula de Controles */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .form-grid {
    grid-template-columns: 1.2fr 1fr 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

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

.input-with-suffix {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 44px;
  transition: border-color 0.2s ease;
}

.input-with-suffix:focus-within {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.input-with-suffix input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 0 0.85rem;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  height: 100%;
}

.input-with-suffix input:focus {
  outline: none;
}

.input-suffix {
  padding: 0 0.85rem;
  background: var(--bg-card-header);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  height: 100%;
  display: flex;
  align-items: center;
  border-left: 1px solid var(--border-color);
}

.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 44px;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 2.5rem 0 0.85rem;
  font-size: 1rem;
  font-family: var(--font-main);
  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.5' 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 0.85rem center;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.form-select:focus {
  outline: none;
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

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

/* Botón Principal */
.btn-calculate {
  width: 100%;
  min-height: 48px;
  background: linear-gradient(135deg, var(--gold-primary) 0%, #967012 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--font-heading);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  cursor: pointer;
  box-shadow: 0 4px 10px var(--gold-glow);
  transition: all 0.2s ease;
}

.btn-calculate:hover {
  background: linear-gradient(135deg, var(--gold-hover) 0%, #7d5c0b 100%);
  transform: translateY(-1px);
}

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

/* ========================================================
   SECCIÓN DE RESULTADOS
   ======================================================== */
.results-section {
  animation: fadeIn 0.3s ease;
}

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

/* Hero Card de Impacto */
.hero-result-card {
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-card-subtle) 100%);
  border: 2px solid var(--gold-primary);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.25rem;
  text-align: center;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 24px var(--gold-glow);
}

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

.hero-result-badge {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold-primary);
  background: var(--gold-light);
  padding: 0.25rem 0.85rem;
  border-radius: 9999px;
  margin-bottom: 0.75rem;
}

.hero-original-amount {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.hero-arrow-down {
  color: var(--gold-primary);
  margin: 0.35rem 0;
}

.hero-updated-eur {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
  margin-bottom: 0.35rem;
}

@media (min-width: 768px) {
  .hero-updated-eur {
    font-size: 3.5rem;
  }
}

.hero-updated-pts {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold-primary);
  margin-bottom: 1.5rem;
}

/* KPIs en Rejilla */
.kpis-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 0.85rem;
  max-width: 800px;
  margin: 0 auto 1.5rem;
}

@media (min-width: 640px) {
  .kpis-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
}

.kpi-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.kpi-val {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
}

.kpi-val.positive {
  color: #10b981;
}

/* Botones de Acción Social / Viral */
.hero-social-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.btn-viral {
  min-height: 42px;
  padding: 0 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.btn-viral-card {
  background: var(--gold-primary);
  color: #ffffff;
}

.btn-viral-card:hover {
  background: var(--gold-hover);
}

.btn-viral-whatsapp {
  background: #25d366;
  color: #ffffff;
}

.btn-viral-whatsapp:hover {
  background: #20bd5a;
}

.btn-viral-copy {
  background: var(--bg-card-subtle);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-viral-copy:hover {
  border-color: var(--border-hover);
}

/* ========================================================
   CESTA DE LA COMPRA HISTÓRICA
   ======================================================== */
.basket-section {
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
}

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

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

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

.basket-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.2s ease;
}

.basket-card:hover {
  border-color: var(--gold-primary);
}

.basket-card-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.basket-card-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--gold-light);
  color: var(--gold-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.basket-card-title {
  font-size: 0.95rem;
  margin: 0;
  line-height: 1.25;
}

.basket-quantities-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.5rem;
}

.basket-qty-box {
  display: flex;
  flex-direction: column;
  flex: 1;
  text-align: center;
}

.basket-qty-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.basket-qty-val {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.basket-qty-unit {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.basket-unit-price {
  font-size: 0.7rem;
  color: var(--gold-primary);
  font-weight: 600;
}

.basket-arrow-col {
  color: var(--text-muted);
  padding: 0 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========================================================
   GRÁFICO CANVAS EVOLUTIVO
   ======================================================== */
.chart-section {
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.chart-canvas-container {
  width: 100%;
  height: 320px;
  position: relative;
}

#timeline-chart-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ========================================================
   GALERÍA DE BILLETES Y MONEDAS DE COLECCIÓN
   ======================================================== */
.currency-gallery-section {
  margin-top: 3rem;
  margin-bottom: 2rem;
}

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

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

@media (min-width: 1024px) {
  .currency-gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.currency-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.currency-item-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.currency-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.currency-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.currency-badge.billete {
  background: var(--green-peseta-light);
  color: var(--green-peseta);
}

.currency-badge.moneda {
  background: var(--gold-light);
  color: var(--gold-primary);
}

.currency-intro-year {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.currency-preview-box {
  background: var(--bg-card-subtle);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.25rem 0.5rem;
  text-align: center;
  margin-bottom: 0.85rem;
}

.currency-value-stamp {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
}

.currency-name {
  font-size: 1.05rem;
  margin: 0 0 0.35rem;
}

.currency-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  line-height: 1.4;
}

.currency-curiosity-box {
  background: var(--bg-card-subtle);
  border-left: 3px solid var(--gold-primary);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-radius: 0 4px 4px 0;
  margin-bottom: 1rem;
}

.btn-calculate-piece {
  width: 100%;
  min-height: 40px;
  background: var(--bg-card-header);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-calculate-piece:hover {
  background: var(--gold-primary);
  color: #ffffff;
  border-color: var(--gold-primary);
}

/* ========================================================
   MODALES ACCESIBLES (SIN ALERT)
   ======================================================== */
.custom-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.custom-modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

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

.custom-modal-title {
  margin: 0;
  font-size: 1.15rem;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

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

.custom-modal-body {
  padding: 1.5rem;
  text-align: center;
}

.card-preview-img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.custom-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toast de notificación rápida */
.toast-notice {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-main);
  color: var(--bg-card);
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  z-index: 100000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.toast-notice.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
