/* ============================================================
   Calculadora de Presupuestos — Hoja de estilos específica
   Depende de css/styles.css (variables CSS globales)
   ============================================================ */

/* ── Hero de la calculadora ──────────────────────────────── */
.calc-hero {
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 60%, #1a3a6b 100%);
  color: var(--white);
  padding: 3.5rem 0 3rem;
}

.calc-hero .breadcrumb {
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
}

.calc-hero .breadcrumb a {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
}
.calc-hero .breadcrumb a:hover { color: var(--white); }
.calc-hero .breadcrumb span   { color: rgba(255,255,255,0.45); margin: 0 0.4rem; }

.calc-hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.9);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.3rem 0.85rem;
  border-radius: 99px;
  margin-bottom: 1rem;
}

.calc-hero h1 {
  color: var(--white);
  margin-bottom: 0.75rem;
  max-width: 680px;
}

.calc-hero-desc {
  color: rgba(255,255,255,0.75);
  font-size: 1.05rem;
  max-width: 580px;
  margin-bottom: 1.5rem;
}

.calc-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.calc-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.85);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
}

/* ── Layout principal ─────────────────────────────────────── */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
  padding: 2.5rem 0 3rem;
}

/* ── Tarjeta genérica ────────────────────────────────────── */
.calc-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.calc-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
}

.calc-card-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.calc-card-icon.icon-blue  { background: #dbeafe; color: var(--blue); }
.calc-card-icon.icon-green { background: #dcfce7; color: var(--green); }

.calc-card-header h2 {
  font-size: 1.05rem;
  margin: 0;
  color: var(--gray-900);
}

.calc-card-header p {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin: 0;
}

.calc-card-body {
  padding: 1.5rem;
}

/* ── Formulario ───────────────────────────────────────────── */
.calc-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.5rem;
}

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

.calc-form-group.full-width {
  grid-column: 1 / -1;
}

.calc-form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-700);
  letter-spacing: 0.01em;
}

.calc-form-group .label-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--gray-400);
  margin-left: 0.25rem;
}

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

.input-wrap .input-prefix {
  position: absolute;
  left: 0.75rem;
  color: var(--gray-400);
  font-weight: 600;
  font-size: 0.95rem;
  pointer-events: none;
  user-select: none;
}

.input-wrap input[type="number"],
.input-wrap input[type="email"] {
  width: 100%;
  padding: 0.6rem 0.85rem 0.6rem 1.8rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
}

.input-wrap input[type="number"]::-webkit-inner-spin-button,
.input-wrap input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-wrap input[type="email"] {
  padding-left: 0.85rem;
}

.input-wrap input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.1);
}

.input-wrap input.input-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}

.input-wrap input.input-ok {
  border-color: var(--green);
}

.field-error {
  font-size: 0.75rem;
  color: #dc2626;
  font-weight: 500;
  display: none;
}

.field-error.visible { display: block; }

/* ── GDPR row ─────────────────────────────────────────────── */
.gdpr-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

.gdpr-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 3px;
  accent-color: var(--green);
  cursor: pointer;
}

.gdpr-row label {
  font-size: 0.77rem;
  color: var(--gray-500);
  line-height: 1.5;
  cursor: pointer;
  font-weight: 400;
}

.gdpr-row label a {
  color: var(--blue);
}

/* ── Botón calcular ───────────────────────────────────────── */
.calc-submit-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--gray-100);
  margin-top: 0.5rem;
}

.btn-calcular {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--green);
  color: var(--white);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.7rem 1.75rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-calcular:hover { background: var(--green-hover); }
.btn-calcular:active { transform: scale(0.98); }

.btn-reset {
  background: none;
  border: 1.5px solid var(--gray-300);
  color: var(--gray-600);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-reset:hover {
  border-color: var(--gray-500);
  color: var(--gray-800);
}

/* ── Sección de resultados ────────────────────────────────── */
#resultado-container {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
}

#resultado-container.visible { display: flex; }

/* ── Alertas 50/30/20 ────────────────────────────────────── */
.alert-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.alert-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
}

.alert-pill svg {
  flex-shrink: 0;
}

.alert-pill.ok {
  background: var(--green-light);
  color: #14532d;
  border: 1px solid #86efac;
}

.alert-pill.warn {
  background: var(--amber-light);
  color: #78350f;
  border: 1px solid #fcd34d;
}

.alert-pill.bad {
  background: #fef2f2;
  color: #7f1d1d;
  border: 1px solid #fca5a5;
}

/* ── Tabla de distribución ───────────────────────────────── */
.dist-table-wrap {
  overflow-x: auto;
}

.dist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.dist-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gray-500);
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--gray-200);
}

.dist-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}

.dist-table tr:last-child td { border-bottom: none; }

.dist-table td:nth-child(2),
.dist-table td:nth-child(3),
.dist-table td:nth-child(4) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dist-table .row-total td {
  font-weight: 700;
  color: var(--gray-900);
  border-top: 2px solid var(--gray-200);
  border-bottom: none;
  background: var(--gray-50);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.4rem;
  flex-shrink: 0;
}

.dot-necesidades { background: #1d4ed8; }
.dot-deseos      { background: #f59e0b; }
.dot-ahorro      { background: #15803d; }
.dot-deudas      { background: #ef4444; }

.amount-ok   { color: var(--green); font-weight: 600; }
.amount-warn { color: var(--amber); font-weight: 600; }
.amount-bad  { color: #dc2626;      font-weight: 600; }

/* Celda editable */
.editable-cell {
  position: relative;
}

.editable-input {
  width: 90px;
  padding: 0.25rem 0.5rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: var(--font);
  text-align: right;
  color: var(--gray-900);
  transition: border-color 0.15s;
}

.editable-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(29,78,216,0.1);
}

/* ── Sección de gráficos ─────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.chart-box {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.chart-box h3 {
  font-size: 0.9rem;
  color: var(--gray-700);
  margin-bottom: 1rem;
  font-weight: 600;
}

.chart-canvas-wrap {
  position: relative;
  max-width: 220px;
  margin: 0 auto;
}

/* ── Barra de progreso meta ─────────────────────────────── */
.meta-box {
  background: linear-gradient(135deg, var(--navy) 0%, #1a3a6b 100%);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

.meta-box h3 {
  color: rgba(255,255,255,0.85);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.meta-goal-amount {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--white);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.meta-subtitle {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.55);
  margin-bottom: 1.25rem;
}

.progress-bar-wrap {
  background: rgba(255,255,255,0.15);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
  margin-bottom: 0.6rem;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #34d399, #10b981);
  width: 0%;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.meta-stats {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.meta-stat {
  display: flex;
  flex-direction: column;
}

.meta-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1;
}

.meta-stat-label {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.55);
  margin-top: 0.15rem;
}

.meta-impossible {
  font-size: 0.85rem;
  color: #fca5a5;
  font-weight: 600;
  margin-top: 0.5rem;
}

/* ── Botón exportar PDF ──────────────────────────────────── */
.export-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  padding-top: 0.5rem;
}

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--navy);
  color: var(--white);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
}

.btn-export:hover {
  background: var(--navy-dark);
  text-decoration: none;
  color: var(--white);
}

.btn-export:active { transform: scale(0.98); }

.btn-export.loading {
  opacity: 0.7;
  pointer-events: none;
}

.export-note {
  font-size: 0.75rem;
  color: var(--gray-400);
}

/* ── Sidebar calculadora ─────────────────────────────────── */
.calc-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 80px;
}

.info-widget {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.info-widget h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.info-rule-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--gray-100);
}

.info-rule-item:last-child { border-bottom: none; }

.info-rule-pct {
  width: 42px;
  text-align: center;
  font-size: 1rem;
  font-weight: 800;
  color: var(--white);
  padding: 0.25rem 0;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.pct-needs  { background: #1d4ed8; }
.pct-wants  { background: #f59e0b; }
.pct-savings { background: var(--green); }

.info-rule-text strong {
  display: block;
  font-size: 0.82rem;
  color: var(--gray-900);
}

.info-rule-text span {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.info-tip {
  font-size: 0.78rem;
  color: var(--gray-500);
  line-height: 1.5;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-100);
}

/* ── Disclaimer calculadora ──────────────────────────────── */
.calc-disclaimer {
  margin-top: 1rem;
}

/* ── Estado vacío / placeholder ─────────────────────────── */
.calc-empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--gray-400);
}

.calc-empty-state svg {
  margin: 0 auto 1rem;
  opacity: 0.4;
}

.calc-empty-state p {
  font-size: 0.9rem;
  margin: 0;
}

/* ── Spinner de carga PDF ────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .calc-layout {
    grid-template-columns: 1fr;
  }

  .calc-sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  .calc-hero { padding: 2.5rem 0 2rem; }

  .calc-form {
    grid-template-columns: 1fr;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .calc-submit-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-calcular { justify-content: center; width: 100%; }

  .calc-sidebar {
    grid-template-columns: 1fr;
    order: 2; /* sidebar siempre debajo del contenido en móvil */
  }

  .export-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-export { justify-content: center; width: 100%; }
  .btn-reset  { width: 100%; }

  /* Chart canvas: min-height para que Chart.js no se aplaste */
  .chart-canvas-wrap { min-height: 200px; }

  /* Indicador visual de scroll horizontal en tabla de distribución */
  .dist-table-wrap {
    -webkit-overflow-scrolling: touch;
    box-shadow: inset -6px 0 8px -6px rgba(0,0,0,0.08);
  }
}

@media (max-width: 480px) {
  .calc-hero h1 { font-size: 1.6rem; }
  .meta-goal-amount { font-size: 1.5rem; }
  .dist-table { font-size: 0.8rem; }
  .editable-input { width: 70px; }
}
