/* ==========================================================================
   Estilos principales: Simulador y comparador de hipotecas (Fijate Tools)
   ========================================================================== */

:root {
  --primary: #ff8507;
  --primary-hover: #e07400;
  --primary-light: rgba(255, 133, 7, 0.12);
  --primary-glow: rgba(255, 133, 7, 0.35);

  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --info: #3b82f6;

  --bg-main: #0b0f17;
  --bg-card: #131b26;
  --bg-card-hover: #1a2434;
  --bg-input: #0e1520;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(255, 133, 7, 0.5);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(255, 133, 7, 0.6);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Cabecera estándar de la aplicación */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.btn-back-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-back-tools:hover {
  color: var(--text-main);
  border-color: var(--primary);
  transform: translateX(-2px);
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo-box {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #fbbf24);
  color: #0b0f17;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
  margin: 0;
}

.brand-subtitle {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* Contenedor principal */
.main-wrapper {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* Hero */
.tool-hero {
  text-align: center;
  margin-bottom: 2rem;
}

.tool-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(255, 133, 7, 0.25);
}

.tool-hero h1 {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
}

.tool-hero p {
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto;
  font-size: 0.98rem;
}

/* Layout de dos columnas */
.mortgage-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.5rem;
  align-items: start;
  margin-bottom: 2.5rem;
}

/* Tarjeta de parámetros */
.params-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.params-card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-group {
  margin-bottom: 1.15rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.input-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.input-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* HUD de resultados principales */
.results-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hud-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.hud-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.hud-card.highlight {
  border-color: rgba(255, 133, 7, 0.4);
  background: linear-gradient(180deg, var(--bg-card), rgba(255, 133, 7, 0.05));
}

.hud-card .val {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.15;
  margin-bottom: 0.3rem;
}

.hud-card .lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

/* Comparador de amortización anticipada */
.early-repay-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.early-repay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.early-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.compare-option-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
}

.compare-option-box.active {
  border-color: var(--success);
}

.compare-option-box h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.compare-saved-val {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--success);
  margin-bottom: 0.25rem;
}

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

/* Gráfico de evolución de capital */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.5rem;
}

.chart-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.mortgage-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Cuadro de amortización */
.schedule-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.5rem;
}

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

.view-pills {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 3px;
}

.view-btn {
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-btn.active {
  background: var(--primary);
  color: #0b0f17 !important;
  font-weight: 700;
}

.table-responsive {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: right;
}

.schedule-table th, .schedule-table td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.schedule-table th {
  background: var(--bg-input);
  font-weight: 700;
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 10;
}

.schedule-table td:first-child, .schedule-table th:first-child {
  text-align: left;
}

/* Sección informativa */
.info-section {
  margin-top: 3rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

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

.info-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Responsive */
@media (max-width: 960px) {
  .mortgage-layout {
    grid-template-columns: 1fr;
  }
  .hud-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .info-section, .early-compare-grid {
    grid-template-columns: 1fr;
  }
}

/* @media print */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .tool-nav, .view-pills, .info-section, .fijate-footer, button {
    display: none !important;
  }
  .main-wrapper {
    max-width: 100%;
    padding: 0;
  }
  .mortgage-layout {
    display: block;
  }
  .params-card, .hud-card, .chart-card, .schedule-card {
    border: 1px solid #cccccc;
    background: #ffffff;
    color: #000000;
    box-shadow: none;
    margin-bottom: 1.5rem;
  }
  .table-responsive {
    max-height: none;
  }
}
