/* ==========================================================================
   Fijate Tools - Auditor regulatorio de factura eléctrica 2.0TD
   Estilos corporativos y responsive con soporte de modo claro / oscuro
   ========================================================================== */

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

  /* Colores tema claro */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-card: #e2e8f0;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-heading: #0f172a;

  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --color-info: #0284c7;

  /* Segmentos barra */
  --bar-power: #3b82f6;
  --bar-energy: #10b981;
  --bar-services: #ef4444;
  --bar-taxes: #8b5cf6;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

[data-theme="dark"] {
  --bg-page: #0b0f17;
  --bg-card: #131b2b;
  --bg-card-subtle: #1a2438;
  --bg-input: #172238;
  --border-card: #22304d;
  --border-focus: #3b82f6;

  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --text-heading: #f8fafc;

  --color-primary: #3b82f6;
  --color-primary-hover: #60a5fa;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout canónico */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  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;
  width: 100%;
}

/* Tipografía */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-heading);
  margin-top: 0;
  letter-spacing: -0.015em;
}

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

/* Tarjeta de presets rápidos */
.presets-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.presets-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.btn-preset {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  min-height: 44px;
}

.btn-preset:hover {
  background: var(--bg-card);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

.btn-preset.active {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

/* Tarjetas de formulario y resultados */
.calculator-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  border-bottom: 1px solid var(--border-card);
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Modos de tarifa (radio buttons estilo pill) */
.tariff-toggle {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.tariff-label-radio {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  min-height: 40px;
  box-sizing: border-box;
}

.tariff-label-radio input {
  cursor: pointer;
  accent-color: var(--color-primary);
}

/* Formularios en rejilla */
.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

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

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

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

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

.input-with-unit input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 3.5rem 0.65rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-main);
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  min-height: 40px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-with-unit input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-with-unit .unit {
  position: absolute;
  right: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* KPIs principales */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

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

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.02em;
}

.kpi-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  margin-top: 0.5rem;
  width: fit-content;
}

.badge-success {
  background: rgba(22, 163, 74, 0.15);
  color: #16a34a;
}

.badge-info {
  background: rgba(2, 132, 199, 0.15);
  color: #0284c7;
}

.badge-warning {
  background: rgba(217, 119, 6, 0.15);
  color: #d97706;
}

.badge-danger {
  background: rgba(220, 38, 38, 0.15);
  color: #dc2626;
}

.badge-neutral {
  background: var(--bg-card-subtle);
  color: var(--text-muted);
}

/* Barra horizontal de distribución porcentual */
.distribution-box {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.dist-bar-container {
  display: flex;
  height: 20px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-card-subtle);
  margin: 0.75rem 0 1rem;
}

.dist-bar-seg {
  height: 100%;
  transition: width 0.3s ease;
}

.dist-seg-power { background-color: var(--bar-power); }
.dist-seg-energy { background-color: var(--bar-energy); }
.dist-seg-services { background-color: var(--bar-services); }
.dist-seg-taxes { background-color: var(--bar-taxes); }

.dist-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.82rem;
}

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

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Tabla de desglose numérico */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.audit-table th, .audit-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-card);
  text-align: left;
}

.audit-table th {
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
}

.audit-table td.text-right, .audit-table th.text-right {
  text-align: right;
}

.audit-table tr.total-row td {
  font-weight: 700;
  border-top: 2px solid var(--border-card);
  border-bottom: none;
  font-size: 1.05rem;
  color: var(--color-primary);
}

/* Tarjetas de alertas de auditoría */
.alerts-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.audit-card {
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  border-left: 4px solid;
  background: var(--bg-card);
  border-top: 1px solid var(--border-card);
  border-right: 1px solid var(--border-card);
  border-bottom: 1px solid var(--border-card);
}

.audit-card-danger {
  border-left-color: var(--color-danger);
  background: rgba(220, 38, 38, 0.03);
}

.audit-card-warning {
  border-left-color: var(--color-warning);
  background: rgba(217, 119, 6, 0.03);
}

.audit-card-info {
  border-left-color: var(--color-info);
  background: rgba(2, 132, 199, 0.03);
}

.audit-card-success {
  border-left-color: var(--color-success);
  background: rgba(22, 163, 74, 0.03);
}

.audit-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.audit-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.audit-dot-danger { background: var(--color-danger); }
.audit-dot-warning { background: var(--color-warning); }
.audit-dot-info { background: var(--color-info); }
.audit-dot-success { background: var(--color-success); }

.audit-card-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.audit-card-desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Borrador de carta de reclamación */
.claim-draft-area {
  width: 100%;
  min-height: 180px;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 1rem;
  box-sizing: border-box;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-main);
  line-height: 1.5;
  resize: vertical;
}

/* Botones de acción */
.actions-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
  border: 1px solid transparent;
}

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

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

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

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

/* Guía y preguntas frecuentes SEO */
.seo-guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin-top: 2rem;
  box-shadow: var(--shadow-sm);
}

.seo-guide-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.faq-accordion details {
  border-bottom: 1px solid var(--border-card);
  padding: 0.85rem 0;
}

.faq-accordion summary {
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--text-heading);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.faq-accordion summary::after {
  content: "+";
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--text-muted);
}

.faq-accordion details[open] summary::after {
  content: "−";
}

.faq-content {
  margin-top: 0.65rem;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 900px) {
  .tool-with-sidebar {
    display: block;
  }

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

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

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

/* Estilos de impresión */
@media print {
  .app-header, .fijate-footer, .tool-ad-sidebar, .tools-ad-banner-section,
  .presets-card, .actions-row, .btn-action, .seo-guide-section {
    display: none !important;
  }

  body, .tool-layout, .tool-main-content {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  .calculator-card, .kpi-card, .distribution-box {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }
}
