/* ==========================================================================
   Calculadora de reparto de herencia y legítima - Estilos Canónicos
   Fijate Tools
   ========================================================================== */

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

  /* Paleta cromática tema oscuro (predeterminado) */
  --bg-body: #0b0f17;
  --bg-card: #111827;
  --bg-card-sub: #162032;
  --bg-input: #1a2436;
  --border-color: #243247;
  --border-subtle: #1e293b;

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

  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: rgba(59, 130, 246, 0.15);

  --accent-gold: #f59e0b;
  --accent-gold-light: rgba(245, 158, 11, 0.15);
  --accent-green: #10b981;
  --accent-green-light: rgba(16, 185, 129, 0.15);
  --accent-purple: #8b5cf6;
  --accent-purple-light: rgba(139, 92, 246, 0.15);
  --accent-rose: #f43f5e;
  --accent-rose-light: rgba(244, 63, 94, 0.15);

  --color-estricta: #3b82f6;
  --color-mejora: #f59e0b;
  --color-libre: #10b981;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
}

[data-theme="light"],
body.light-theme {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-sub: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-subtle: #e2e8f0;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.1);

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.06);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-body);
  color: var(--text-main);
  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,
.brand-title,
.section-title,
.hero-title,
.faq-section-title {
  font-family: var(--font-heading);
}

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

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

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Tarjeta principal */
.card-main {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Grid de dos columnas para formulario y resultados */
.herencia-workspace {
  display: grid;
  grid-template-columns: 1.1fr 1.3fr;
  gap: 2rem;
  align-items: flex-start;
}

@media (max-width: 960px) {
  .herencia-workspace {
    grid-template-columns: 1fr;
  }
}

/* Estilos de formulario */
.form-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background-color: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

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

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

.form-help {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Selects canónicos con ellipsis */
select.form-control {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 40px 0 0.85rem;
  font-family: var(--font-main);
  font-size: 0.92rem;
  color: var(--text-main);
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  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' 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 12px center;
  cursor: pointer;
  transition: border-color 0.2s;
}

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

/* Inputs de texto y números */
input[type="number"].form-control,
input[type="text"].form-control {
  width: 100%;
  height: 42px;
  padding: 0 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

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

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

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

/* Grupos de botones / Radio tabs */
.radio-tab-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  width: 100%;
}

.radio-tab-label {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 0.75rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.radio-tab-input {
  display: none;
}

.radio-tab-input:checked + .radio-tab-label {
  background-color: var(--primary-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Checkbox estilizado */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  min-height: 40px;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-color);
  cursor: pointer;
}

/* Badges informativos */
.badge-info-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  background-color: var(--accent-gold-light);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 999px;
  width: fit-content;
  margin-top: 0.25rem;
}

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

/* Tarjetas de métricas */
.metrics-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .metrics-summary-grid {
    grid-template-columns: 1fr;
  }
}

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

.metric-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
}

.metric-card.highlight {
  border-color: var(--primary-color);
  background-color: var(--primary-light);
}

.metric-card.highlight .metric-val {
  color: var(--primary-color);
}

/* Barra visual de los tercios */
.tercios-visual-container {
  background-color: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.tercios-visual-bar {
  display: flex;
  height: 38px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
}

.tercio-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: var(--font-mono);
  transition: width 0.3s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
}

.segment-estricta { background-color: var(--color-estricta); }
.segment-mejora { background-color: var(--color-mejora); }
.segment-libre { background-color: var(--color-libre); }

.tercios-visual-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.color-estricta { background-color: var(--color-estricta); }
.color-mejora { background-color: var(--color-mejora); }
.color-libre { background-color: var(--color-libre); }

/* Tabla de herederos */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-card-sub);
}

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

.table-herederos th {
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table-herederos td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}

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

.heredero-cell {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.heredero-name {
  font-weight: 600;
  color: var(--text-main);
}

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  width: fit-content;
}

.badge-conyuge {
  background-color: var(--accent-gold-light);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-descendiente {
  background-color: var(--primary-light);
  color: var(--primary-color);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-general {
  background-color: var(--accent-green-light);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.text-right { text-align: right; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-highlight { color: var(--accent-green); }

/* Bloque de usufructo y conmutación */
.usufructo-summary-box {
  background-color: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.usufructo-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 42px;
  padding: 0 1.25rem;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background-color: var(--primary-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 44px;
  padding: 0 1.5rem;
  font-family: var(--font-main);
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
  background-color: var(--primary-color);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.2s;
  width: 100%;
}

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

/* Alerta de advertencias */
.alert-card {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.5;
}

.alert-warning {
  background-color: var(--accent-rose-light);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fca5a5;
}

.alert-warning ul {
  padding-left: 1.25rem;
  margin-top: 0.35rem;
}

.alert-info-banner {
  background-color: var(--accent-green-light);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #86efac;
}

/* Notas legales */
.legal-notes-card {
  background-color: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.legal-notes-card h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.legal-notes-card ul {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Modales canónicos */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.is-active {
  display: flex;
}

.modal-dialog {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.05);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* Sección de guía y preguntas frecuentes (FAQ) */
.seo-guide-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.seo-guide-section h2 {
  font-size: 1.4rem;
  color: var(--text-main);
}

.faq-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.faq-item {
  background-color: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.faq-item h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.faq-item p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ==========================================================================
   Vista de Impresión Oficial A4 (.print-sheet)
   ========================================================================== */
.print-sheet {
  display: none;
}

@media print {
  /* Ocultar interfaz web y anuncios */
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt !important;
  }

  .app-header,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .fijate-footer,
  .card-main,
  .seo-guide-section,
  .modal-overlay,
  .btn-print-action {
    display: none !important;
  }

  .tool-layout {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .print-sheet {
    display: block !important;
    width: 100% !important;
    max-width: 210mm !important;
    margin: 0 auto !important;
    padding: 15mm 20mm !important;
    background: #ffffff !important;
    color: #111827 !important;
    font-family: Arial, sans-serif !important;
  }

  .print-header {
    border-bottom: 2px solid #111827;
    padding-bottom: 12px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
  }

  .print-title {
    font-size: 18pt;
    font-weight: bold;
    color: #111827;
  }

  .print-subtitle {
    font-size: 10pt;
    color: #4b5563;
  }

  .print-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
    font-size: 10pt;
    border: 1px solid #e5e7eb;
    padding: 12px;
    border-radius: 6px;
  }

  .print-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
    font-size: 9.5pt;
  }

  .print-table th {
    background-color: #f3f4f6 !important;
    border: 1px solid #d1d5db;
    padding: 8px 10px;
    text-align: left;
    font-weight: bold;
  }

  .print-table td {
    border: 1px solid #e5e7eb;
    padding: 8px 10px;
  }

  .print-signatures {
    margin-top: 40px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 40px;
  }

  .signature-box {
    border-top: 1px solid #111827;
    padding-top: 8px;
    text-align: center;
    font-size: 9.5pt;
  }
}
