/**
 * Calculadora de Prestación por Nacimiento y Cuidado del Menor + Permiso Parental
 * Hoja de estilos corporativa oficial - Fijate Tools
 */

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

  /* Colores Corporativos Tema Claro */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-header: #f1f5f9;
  --bg-card-elevated: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

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

  --primary-color: #2563eb;
  --primary-light: #eff6ff;
  --primary-hover: #1d4ed8;

  --accent-color: #0d9488;
  --accent-light: #f0fdfa;

  --p1-color: #2563eb;
  --p1-light: #dbeafe;
  --p2-color: #7c3aed;
  --p2-light: #ede9fe;

  --lact-color: #d97706;
  --lact-light: #fef3c7;
  --vac-color: #ea580c;
  --vac-light: #ffedd5;
  --parental-color: #0284c7;
  --parental-light: #e0f2fe;

  --positive-color: #16a34a;
  --positive-light: #dcfce7;
  --danger-color: #dc2626;
  --danger-light: #fee2e2;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --container-max: 1440px;
}

[data-theme="dark"] {
  --bg-page: #0b0f17;
  --bg-card: #151d2a;
  --bg-card-header: #1c2638;
  --bg-card-elevated: #1a2333;
  --bg-input: #0f172a;
  --border-color: #263449;
  --border-focus: #60a5fa;

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

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

  --accent-color: #14b8a6;
  --accent-light: rgba(20, 184, 166, 0.15);

  --p1-color: #60a5fa;
  --p1-light: rgba(96, 165, 250, 0.18);
  --p2-color: #a78bfa;
  --p2-light: rgba(167, 139, 250, 0.18);

  --lact-color: #fbbf24;
  --lact-light: rgba(251, 191, 36, 0.18);
  --vac-color: #fb923c;
  --vac-light: rgba(251, 146, 60, 0.18);
  --parental-color: #38bdf8;
  --parental-light: rgba(56, 189, 248, 0.18);

  --positive-color: #22c55e;
  --positive-light: rgba(34, 197, 94, 0.15);
  --danger-color: #f87171;
  --danger-light: rgba(248, 113, 113, 0.15);

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

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

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

h1, h2, h3, h4, h5, h6,
.section-title,
.hero-title,
.card-header-title {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mono,
.kpi-value,
.cal-day-number,
.gantt-kpi-value {
  font-family: var(--font-mono);
}

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

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

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  max-width: 100%;
}

/* --- Hero Banner Editorial --- */
.hero-intro-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.hero-intro-banner::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--primary-color), var(--accent-color));
}

.hero-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  background: var(--primary-light);
  color: var(--primary-color);
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero-headline {
  font-size: 1.45rem;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.hero-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 900px;
}

/* --- Tarjetas Principales --- */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.card-header-bar {
  background: var(--bg-card-header);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-header-title {
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

/* --- Rejillas de Formulario --- */
.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

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

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.label-help {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* --- Inputs y Selects Estilizados --- */
.input-text,
.select-custom {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  min-height: 40px;
  padding: 0 0.85rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.925rem;
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-text:focus,
.select-custom:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.select-custom {
  appearance: none;
  -webkit-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='%2364748b' 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 14px center;
  padding-right: 40px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

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

.input-prefix-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-prefix-wrapper .input-text {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  padding-right: 2.2rem;
}

.input-suffix-tag {
  position: absolute;
  right: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  pointer-events: none;
}

/* Switch / Checkbox Elegante */
.checkbox-inline-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  padding: 0.5rem 0;
}

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

/* --- Rejilla de KPIs Económicos Destacados --- */
.kpi-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.kpi-card-box {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.kpi-card-box:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.kpi-card-box.kpi-highlight-positive {
  background: var(--positive-light);
  border-color: rgba(34, 197, 94, 0.4);
}

.kpi-card-box.kpi-highlight-positive .kpi-label {
  color: var(--positive-color);
  font-weight: 700;
}

.kpi-card-box.kpi-highlight-positive .kpi-value {
  color: var(--positive-color);
}

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

.kpi-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.kpi-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-positive {
  background: rgba(34, 197, 94, 0.2);
  color: var(--positive-color);
}

.badge-neutral {
  background: var(--border-color);
  color: var(--text-muted);
}

/* Callout Sentencia Tribunal Supremo */
.ts-callout-box {
  background: var(--primary-light);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-top: 1rem;
}

.ts-callout-icon {
  flex-shrink: 0;
  color: var(--primary-color);
  margin-top: 2px;
}

.ts-callout-text {
  font-size: 0.875rem;
  color: var(--text-main);
  line-height: 1.45;
}

.ts-callout-text strong {
  color: var(--primary-color);
}

/* --- Resumen y Cronograma Gantt --- */
.gantt-summary-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.gantt-kpi-item {
  display: flex;
  flex-direction: column;
}

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

.gantt-kpi-value {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0.2rem 0;
}

.text-accent {
  color: var(--accent-color);
}

.gantt-kpi-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Timeline Gantt */
.gantt-timeline-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1rem;
  overflow-x: auto;
  min-width: 100%;
}

.gantt-header-months {
  display: flex;
  width: 100%;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.gantt-month-cell {
  flex: 1;
  text-align: center;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: capitalize;
}

.gantt-track-lane {
  margin-bottom: 1rem;
}

.gantt-lane-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.progenitor-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
}

.p1-badge {
  background: var(--p1-light);
  color: var(--p1-color);
}

.p2-badge {
  background: var(--p2-light);
  color: var(--p2-color);
}

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

.gantt-lane-bars {
  position: relative;
  height: 36px;
  background: var(--bg-card-elevated);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-color);
  width: 100%;
}

.gantt-bar {
  position: absolute;
  top: 3px;
  bottom: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.5rem;
  font-size: 0.725rem;
  font-weight: 600;
  color: #ffffff;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: filter 0.15s ease, transform 0.15s ease;
}

.gantt-bar:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.bar-type-compulsory {
  background: linear-gradient(135deg, #1e40af, #2563eb);
}

.bar-type-voluntary {
  background: linear-gradient(135deg, #0d9488, #14b8a6);
}

.p2-bar.bar-type-voluntary {
  background: linear-gradient(135deg, #6d28d9, #8b5cf6);
}

.bar-type-lactation {
  background: linear-gradient(135deg, #b45309, #d97706);
}

.bar-type-vacation {
  background: linear-gradient(135deg, #c2410c, #ea580c);
}

.gantt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.oblig-dot { background: #2563eb; }
.vol-dot { background: #0d9488; }
.lact-dot { background: #d97706; }
.vac-dot { background: #ea580c; }

/* --- Calendario Mes a Mes --- */
.calendar-widget-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

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

.cal-month-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: capitalize;
}

.btn-cal-nav {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

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

.cal-weekdays-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.cal-day-cell {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  min-height: 58px;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.cal-day-cell:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

.cal-empty-cell {
  background: transparent;
  border-color: transparent;
  cursor: default;
}

.cal-empty-cell:hover {
  background: transparent;
  border-color: transparent;
}

.cal-is-today {
  border-color: var(--primary-color);
  background: rgba(37, 99, 235, 0.08);
}

.cal-is-today .cal-day-number {
  color: var(--primary-color);
  font-weight: 800;
}

.cal-is-weekend {
  opacity: 0.85;
}

.cal-day-number {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
}

.cal-day-chips {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.cal-micro-chip {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 2px;
  text-align: center;
  color: #ffffff;
}

.chip-compulsory { background: #2563eb; }
.chip-voluntary.chip-p1 { background: #0d9488; }
.chip-voluntary.chip-p2 { background: #7c3aed; }
.chip-lactation { background: #d97706; }
.chip-vacation { background: #ea580c; }

/* --- Barra de Acciones y Botones --- */
.action-buttons-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.btn-primary,
.btn-secondary {
  height: 44px;
  min-height: 40px;
  padding: 0 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.925rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-primary {
  background: var(--primary-color);
  color: #ffffff;
  border: 1px solid var(--primary-color);
}

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-header);
  border-color: var(--text-muted);
}

/* --- Modales Corporativos --- */
.custom-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.custom-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

.custom-modal-title {
  font-size: 1.2rem;
}

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

.custom-modal-close:hover {
  color: var(--text-main);
}

.custom-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  font-size: 0.925rem;
  line-height: 1.6;
}

.letter-textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  color: var(--text-main);
  resize: vertical;
  margin-top: 0.5rem;
}

.letter-actions-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  justify-content: flex-end;
}

/* --- Responsive y Móvil --- */
@media (max-width: 992px) {
  .form-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .gantt-summary-card {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

@media (max-width: 640px) {
  .form-grid-3,
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
  .kpi-cards-grid {
    grid-template-columns: 1fr;
  }
  .action-buttons-bar {
    flex-direction: column;
  }
  .btn-primary,
  .btn-secondary {
    width: 100%;
  }
  .cal-day-cell {
    min-height: 46px;
    padding: 0.2rem;
  }
}

/* --- Impresión (@media print) --- */
@media print {
  .app-header,
  .fijate-footer,
  .tool-ad-sidebar,
  .tools-ad-banner-section,
  .action-buttons-bar,
  .btn-cal-nav {
    display: none !important;
  }
  .tool-layout {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
  .card-main {
    border: none;
    box-shadow: none;
  }
}
