/* =============================================
   calculadora.css — Bretica Calculadora
   Sistema de diseño coherente con marketing-bretica.css
   ============================================= */



/* ── Tokens propios de la calculadora ─────────── */
:root {
  --chart-1: #2563eb;
  --chart-2: #16a34a;
  --chart-3: #f97316;
  --chart-4: #9333ea;
  --chart-5: #0ea5e9;
  --chart-6: #e11d48;

  --color-principal: #2e4a62;
  --shadow-sm: 0 1px 4px rgba(15,23,42,0.06);
  --shadow-md: 0 4px 16px rgba(15,23,42,0.08);
  --shadow-lg: 0 8px 30px rgba(15,23,42,0.12);
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --t-fast: 0.12s ease;
  --t-normal: 0.22s ease;
}

/* ── Reset y base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; background: #f5f7fa; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  line-height: 1.5;
  padding-bottom: 2rem;
}

/* ── Contenedor ────────────────────────────────── */
.calc-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ── Cards ─────────────────────────────────────── */
.card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid #e5e7eb;
  box-shadow: var(--shadow-md);
  padding: 1.3rem 1.4rem;
  margin-bottom: 1.2rem;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ── Inputs ─────────────────────────────────────── */
.input {
  width: 100%;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #111827;
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color var(--t-fast), outline var(--t-fast);
}

.input:focus {
  outline: 2px solid rgba(255,142,122,0.4);
  border-color: #ff8e7a;
}

.input-right { text-align: right; }

/* ── Botones ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--t-fast), transform 0.08s ease, box-shadow var(--t-fast);
}

.btn-primary {
  background: linear-gradient(90deg, #ff8e7a, #ff6c58);
  color: #111827;
  box-shadow: 0 6px 18px rgba(255,142,122,0.3);
}
.btn-primary:hover {
  background: linear-gradient(90deg, #ff765f, #ff5a45);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(255,142,122,0.4);
}

.btn-outline {
  background: #fff;
  color: #2e4a62;
  border-color: #cbd5e1;
}
.btn-outline:hover {
  background: #eef3f7;
  border-color: #2e4a62;
}

.btn-ghost {
  background: transparent;
  color: #6b7280;
  border-color: transparent;
}
.btn-ghost:hover {
  background: rgba(167,235,208,0.25);
  color: #2e4a62;
}

.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8rem; }
.btn:active { transform: translateY(0); box-shadow: none; }

/* ── Toolbar de la calculadora ─────────────────── */
.calc-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* ── Tablas ──────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
}

.table thead { background: #f8fafc; }

.table th {
  text-align: left;
  color: #6b7280;
  font-weight: 500;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.8rem;
}

.table td {
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
}

.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: none; }

/* ── Texto auxiliar ──────────────────────────────── */
.muted { color: #6b7280; font-size: 0.875rem; }
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #2e4a62;
  margin-bottom: 0.35rem;
}
.section-help {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 0.75rem;
}

/* ── Flex helpers ────────────────────────────────── */
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.summary {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.875rem;
}
.summary strong { font-size: 1rem; color: #2e4a62; }

/* ── Select ──────────────────────────────────────── */
.select {
  width: 100%;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #111827;
  font-size: 0.875rem;
  font-family: inherit;
}
.select:focus {
  outline: 2px solid rgba(255,142,122,0.4);
  border-color: #ff8e7a;
}

/* ── KPIs (resultado) ────────────────────────────── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.resultado {
  border: 2px solid rgba(37,99,235,0.2);
  animation: fadeSlideIn 0.3s ease;
}

.resultado-header {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  padding: 0.9rem 1.1rem;
  border-radius: calc(var(--radius-lg) - 2px) calc(var(--radius-lg) - 2px) 0 0;
  margin: -1.3rem -1.4rem 1rem;
}

.resultado-header h2 {
  font-size: 1rem;
  color: #1e40af;
  margin: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kpi-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  animation: fadeSlideIn 0.3s ease both;
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.kpi-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.kpi-card.kpi-principal {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #2e4a62, #1e3347);
  color: #fff;
  border: none;
}

.kpi-label {
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 0.2rem;
}
.kpi-principal .kpi-label { color: rgba(255,255,255,0.7); }

.kpi-valor {
  font-size: 1.25rem;
  font-weight: 700;
  color: #2e4a62;
  font-variant-numeric: tabular-nums;
}
.kpi-principal .kpi-valor { color: #fff; font-size: 1.6rem; }

.kpi-nota {
  font-size: 0.72rem;
  color: #9ca3af;
  margin-top: 0.15rem;
}
.kpi-principal .kpi-nota { color: rgba(255,255,255,0.6); }

/* ── Barra desglose apilado ───────────────────────── */
.desglose-section { margin-bottom: 1rem; }
.desglose-section h3 { font-size: 0.9rem; color: #2e4a62; margin-bottom: 0.6rem; }

.desglose-stacked {
  display: flex;
  height: 28px;
  border-radius: 999px;
  overflow: hidden;
  gap: 2px;
  margin-bottom: 0.6rem;
}

.desglose-segment {
  height: 100%;
  cursor: default;
  transition: filter var(--t-fast);
}
.desglose-segment:hover { filter: brightness(1.1); }

.desglose-leyenda {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}
.leyenda-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: #6b7280;
}
.leyenda-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Acordeón de tabla detalle ─────────────────── */
.detalle-acordeon {
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.detalle-acordeon summary {
  padding: 0.65rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #2e4a62;
  background: #f8fafc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  list-style: none;
}
.detalle-acordeon summary::-webkit-details-marker { display: none; }
.detalle-acordeon summary::after {
  content: '▸';
  font-size: 0.8rem;
  color: #9ca3af;
  transition: transform var(--t-fast);
}
.detalle-acordeon[open] summary::after { transform: rotate(90deg); }

.detalle-acordeon .table { margin-bottom: 0; }

/* ── Avisos / advertencias ───────────────────────── */
.avisos-box {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.9rem;
  font-size: 0.85rem;
  color: #92400e;
  margin-bottom: 0.75rem;
  display: flex;
  gap: 0.5rem;
}
.avisos-box ul { margin: 0.3rem 0 0 1rem; }

/* ── Tipo de cálculo chips ────────────────────────── */
.tipo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.tipo-btn {
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  background: #fff;
  padding: 0.85rem 1rem;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.tipo-btn:hover {
  border-color: rgba(255,142,122,0.5);
  background: #fff7f5;
}
.tipo-btn.activo {
  border-color: #ff8e7a;
  background: rgba(255,142,122,0.05);
  box-shadow: 0 0 0 3px rgba(255,142,122,0.15);
}
.tipo-btn .tipo-icon { font-size: 1.3rem; margin-bottom: 0.3rem; }
.tipo-btn .tipo-nombre { font-size: 0.9rem; font-weight: 600; color: #2e4a62; margin-bottom: 0.1rem; }
.tipo-btn .tipo-desc { font-size: 0.78rem; color: #6b7280; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 640px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .tipo-grid {
    grid-template-columns: 1fr;
  }
  .table th, .table td {
    font-size: 0.8rem;
    padding: 0.35rem 0.5rem;
  }
  .card { padding: 1rem; }
}

/* ── Print ───────────────────────────────────────── */
@media print {
  body { background: #fff; }
  .card { box-shadow: none; border-radius: 0; }
  .btn, .calc-toolbar { display: none !important; }
}

/* ── Popover / modal ─────────────────────────────── */
.popover {
  position: absolute;
  z-index: 100;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 1rem 1.1rem;
  max-width: 340px;
  font-size: 0.85rem;
  color: #374151;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.25);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  max-width: 480px;
  width: 90%;
}

/* ── Ingreso base helpers ────────────────────────── */
.label {
  display: block;
  font-size: 0.82rem;
  color: #6b7280;
  margin-bottom: 0.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

/* ── Cancelar hover-zoom de animations.css ────── */
.card,
.card:hover {
  transform: none !important;
  box-shadow: var(--shadow-md) !important;
}