/* ==========================================================================
   Fijate Tools - Auditor y explicador interactivo de nóminas
   Cumplimiento estricto Lección 344 (sin reseteo universal destructivo) y Regla 10
   ========================================================================== */

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

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;

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

  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --success-text: #065f46;

  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;

  --amber: #f59e0b;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;
  --amber-text: #92400e;

  --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.04);
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="dark"] {
  --bg-page: #0b0f17;
  --bg-card: #131b2a;
  --bg-card-subtle: #1c2638;
  --bg-input: #1a2334;
  --border-color: #27354a;
  --border-focus: #60a5fa;
  --text-main: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-subtle: #94a3b8;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e293b;
  --primary-border: #2563eb;

  --success: #34d399;
  --success-bg: #064e3b;
  --success-border: #047857;
  --success-text: #a7f3d0;

  --danger: #f87171;
  --danger-bg: #450a0a;
  --danger-border: #7f1d1d;
  --danger-text: #fecaca;

  --amber: #fbbf24;
  --amber-bg: #291e0a;
  --amber-border: #78350f;
  --amber-text: #fde68a;
}

/* Lección 344: solo box-sizing en selector universal para no alterar header ni footer */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  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;
}

.tool-layout h1,
.tool-layout h2,
.tool-layout h3,
.tool-layout h4,
.tool-layout h5,
.tool-layout h6,
.fijate-modal-card h3,
.fijate-modal-card h4,
.section-legend,
.xray-net-val,
.faq-section-title {
  font-family: var(--font-heading);
  margin: 0;
}

.tool-layout p {
  margin: 0;
}

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

.text-danger {
  color: var(--danger) !important;
}

.text-primary {
  color: var(--primary) !important;
}

.text-success {
  color: var(--success) !important;
}

.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1;
}

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

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

.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
}

/* Barra rápida */
.tool-quick-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.quick-bar-text {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.7rem;
  border-radius: 9999px;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.quick-bar-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.quick-bar-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-subtle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 40px;
}

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

/* Secciones de formulario */
.form-section {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.35rem 1.5rem 1.5rem;
  margin: 0 0 1.5rem 0;
  background: var(--bg-card);
}

.section-legend {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-main);
  padding: 0 0.5rem;
}

.legend-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.form-grid {
  display: grid;
  gap: 1.1rem;
  margin-top: 1rem;
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

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

.req {
  color: #ef4444;
}

.field-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.tool-layout input[type="number"] {
  width: 100%;
  height: 42px;
  padding: 0 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tool-layout input:focus,
.tool-layout select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Regla 10: Desplegables responsivos sin desbordamiento de viewport */
.custom-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 38px 0 0.75rem;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  appearance: none;
  -webkit-appearance: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  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 12px center;
  background-size: 16px;
  cursor: pointer;
  outline: none;
}

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

/* Regla 10: Inputs dentro de wrappers flexbox con unidades/sufijos */
.input-suffix-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  height: 42px;
}

.input-suffix-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.input-suffix-wrapper input[type="number"] {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  height: 100%;
  border: none;
  padding: 0 0.75rem;
  background: transparent;
  outline: none;
  box-shadow: none;
}

.input-suffix {
  padding: 0 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-card-subtle);
  border-left: 1px solid var(--border-color);
  height: 100%;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Botonera principal */
.form-actions-bar {
  display: flex;
  margin-top: 0.5rem;
}

.btn-primary-action {
  width: 100%;
  min-height: 48px;
  padding: 0.65rem 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.96rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  transition: all 0.2s ease;
}

.btn-primary-action:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* Panel de Radiografía */
.payroll-xray-card {
  margin-top: 2.25rem;
  background: var(--bg-card);
  border: 2px solid var(--primary-border);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
}

@keyframes pulseHighlight {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45); }
  70% { box-shadow: 0 0 0 12px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.payroll-xray-card.highlight-pulse {
  animation: pulseHighlight 1s ease-out;
}

/* Resumen superior */
.xray-summary-header {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.xray-net-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 240px;
}

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

.xray-net-val {
  font-size: 2.35rem;
  font-weight: 800;
  color: var(--success);
  line-height: 1.1;
  margin-top: 0.25rem;
}

.xray-net-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.xray-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 0.85rem;
  flex: 1 1 520px;
}

.xray-stat-item {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
}

.xray-stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.xray-stat-num {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.25rem;
}

.xray-stat-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Veredicto y Checklist de Auditoría */
.audit-verdict-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1.15rem 1.25rem;
  border-radius: 10px;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
}

.audit-verdict-card.verdict-warn {
  background: var(--amber-bg);
  border-color: var(--amber-border);
}

.audit-verdict-card.verdict-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.verdict-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--success);
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.audit-verdict-card.verdict-warn .verdict-icon {
  background: var(--amber);
}

.audit-verdict-card.verdict-danger .verdict-icon {
  background: var(--danger);
}

.verdict-info {
  flex: 1;
  min-width: 0;
}

.verdict-info h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--success-text);
}

.audit-verdict-card.verdict-warn .verdict-info h4 {
  color: var(--amber-text);
}

.audit-verdict-card.verdict-danger .verdict-info h4 {
  color: var(--danger-text);
}

.verdict-checks-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.84rem;
  color: var(--success-text);
}

.audit-verdict-card.verdict-warn .verdict-checks-list {
  color: var(--amber-text);
}

.audit-verdict-card.verdict-danger .verdict-checks-list {
  color: var(--danger-text);
}

/* Recibo de salarios interactivo */
.payslip-table-wrapper {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

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

.payslip-header h4 {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-main);
}

.payslip-hint {
  font-size: 0.78rem;
  color: var(--primary);
  font-weight: 600;
}

.payslip-interactive-table {
  display: flex;
  flex-direction: column;
}

.payslip-section-title {
  padding: 0.6rem 1.25rem;
  background: var(--bg-card-subtle);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.payslip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.15s ease;
}

.payslip-row:last-child {
  border-bottom: none;
}

.interactive-row {
  cursor: pointer;
}

.interactive-row:hover,
.interactive-row:focus-visible {
  background: rgba(37, 99, 235, 0.07);
  outline: none;
}

.col-concept {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  font-size: 0.88rem;
  color: var(--text-main);
  min-width: 0;
}

.concept-sub-detail {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 400;
}

.concept-help-tag {
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--bg-card-subtle);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.col-amount {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}

.subtotal-row {
  background: var(--bg-card-subtle);
  font-weight: 700;
}

.total-net-row {
  background: var(--success-bg);
  border-top: 2px solid var(--success-border);
  border-bottom: 2px solid var(--success-border);
}

.total-net-row .col-concept strong,
.total-net-row .col-amount {
  color: var(--success-text);
  font-size: 1.02rem;
  font-weight: 800;
}

.highlight-base {
  background: rgba(59, 130, 246, 0.05);
}

.highlight-mei {
  background: rgba(245, 158, 11, 0.06);
}

/* FAQs */
.tool-faq-section {
  margin-top: 2.75rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.faq-section-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text-main);
}

.faq-accordion-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.faq-accordion-item[open] {
  border-color: var(--primary-border);
}

.faq-question {
  padding: 1rem 1.25rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  user-select: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: "+";
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--text-muted);
  flex-shrink: 0;
}

.faq-accordion-item[open] .faq-question::after {
  content: "−";
  color: var(--primary);
}

.faq-answer {
  padding: 0 1.25rem 1.1rem;
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Modales */
.fijate-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 99999;
}

.fijate-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 580px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

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

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

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.btn-close-modal:hover {
  background: var(--bg-card-subtle);
  color: var(--text-main);
}

.fijate-modal-body {
  padding: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  max-height: 72vh;
  overflow-y: auto;
}

.fijate-modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  min-height: 40px;
  padding: 0 1.35rem;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

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

/* Responsividad móvil (Regla 10) */
@media (max-width: 900px) {
  .tool-with-sidebar {
    flex-direction: column;
  }

  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .xray-summary-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .xray-stats-grid {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex: 1 1 auto;
  }

  .card-main {
    padding: 1.15rem;
  }

  .form-section {
    padding: 1rem;
  }

  .payroll-xray-card {
    padding: 1.1rem;
  }

  .payslip-row {
    padding: 0.75rem 0.9rem;
    flex-wrap: wrap;
  }

  .col-amount {
    margin-left: auto;
  }
}

@media (max-width: 520px) {
  .xray-stats-grid {
    grid-template-columns: 1fr;
  }

  .quick-bar-btns {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .btn-subtle {
    width: 100%;
  }
}
