/**
 * Fijate Tools - Guía antical y calculadora de dureza del agua
 * Hoja de estilos canónica, responsiva y accesible para modos claro y oscuro.
 */

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

  /* Paleta cromática corporativa (claro) */
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-accent: #eff6ff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

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

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;

  --accent-cyan: #06b6d4;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-success: #10b981;

  --shadow-sm: 0 1px 3px 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);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] {
  --bg-primary: #0b0f17;
  --bg-card: #151d2a;
  --bg-card-hover: #1e293b;
  --bg-accent: #172554;
  --border-color: #2a3749;
  --border-focus: #60a5fa;

  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --text-subtle: #94a3b8;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e3a8a;

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

/* Reset y contención canónica */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.25;
}

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

/* Layout principal de herramienta */
.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  display: flex;
  gap: 2rem;
  flex: 1 0 auto;
}

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

/* Hero / Introducción */
.tool-hero-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}

.hero-pill-category {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--bg-accent);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tool-page-title {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.tool-page-lead {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 900px;
  line-height: 1.6;
}

/* Barra de pestañas */
.tool-nav-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.tool-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  margin-bottom: -2px;
}

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

.tool-nav-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Paneles de pestañas */
.tool-tab-panel {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
}

.tool-tab-panel.active {
  display: flex;
}

/* Tarjetas y secciones */
.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-title {
  font-size: 1.25rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Formularios y controles canónicos */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.select-wrapper {
  position: relative;
  width: 100%;
}

select.form-control {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.65rem 2.5rem 0.65rem 0.85rem;
  font-size: 0.9375rem;
  font-family: var(--font-main);
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  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%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

select.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

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

.unit-field {
  display: flex;
  flex-direction: column;
}

.unit-field .form-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.input-with-suffix {
  display: flex;
  align-items: center;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  min-height: 42px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

.input-with-suffix input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  border: none;
  outline: none;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-family: var(--font-mono);
  font-weight: 600;
  background: transparent;
  color: var(--text-main);
}

.input-suffix {
  background: var(--bg-card-hover);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-left: 1px solid var(--border-color);
  white-space: nowrap;
}

/* Diagnóstico y Badge de dureza */
.diagnosis-banner {
  background: var(--bg-accent);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.25rem;
  margin-top: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.diagnosis-badge {
  font-size: 0.875rem;
  font-weight: 700;
  color: #ffffff;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  white-space: nowrap;
}

.diagnosis-text {
  flex: 1;
}

.diagnosis-desc {
  font-size: 0.9375rem;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.province-info-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* KPIs de impacto económico */
.impact-kpis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.impact-kpi-card {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
}

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

.impact-kpi-value {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.impact-kpi-hint {
  font-size: 0.75rem;
  color: var(--text-subtle);
  line-height: 1.4;
}

/* Cuadrícula de electrodomésticos */
.appliances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}

.appliance-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

.appliance-card:hover, .appliance-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.card-icon {
  font-size: 2rem;
  line-height: 1;
}

.card-title {
  font-size: 1.0625rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.card-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-accent);
  color: var(--primary);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.card-symptoms {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.45;
  flex: 1;
}

.card-action {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.5rem;
}

/* Tablas científicas */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

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

.scientific-table th,
.scientific-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.scientific-table th {
  background: var(--bg-card-hover);
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

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

.scientific-table tr.danger-row {
  background: rgba(239, 68, 68, 0.06);
}

.table-warning {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.table-warning.badge-danger {
  color: var(--accent-danger);
  font-weight: 700;
}

/* Calculadora de disolución de ácido cítrico */
.calculator-box {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.25rem;
  margin-top: 1.25rem;
}

.calculator-result-display {
  background: var(--bg-card);
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  text-align: center;
}

.calc-res-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.calc-res-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--primary);
}

.calc-res-sub {
  font-size: 0.875rem;
  color: var(--text-subtle);
  margin-top: 0.25rem;
}

/* Alertas de seguridad */
.security-alert-box {
  background: rgba(239, 68, 68, 0.08);
  border-left: 4px solid var(--accent-danger);
  padding: 1rem 1.25rem;
  border-radius: 0 8px 8px 0;
  margin-top: 1.25rem;
}

.alert-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--accent-danger);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.alert-desc {
  font-size: 0.875rem;
  color: var(--text-main);
  line-height: 1.5;
}

/* Sistemas de tratamiento de agua */
.systems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.system-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.875rem;
}

.system-title {
  font-size: 1.0625rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.system-efficiency {
  color: var(--primary);
  font-weight: 600;
}

.system-pros {
  color: var(--accent-success);
}

.system-cons {
  color: var(--accent-warning);
}

.system-rec {
  background: var(--bg-accent);
  padding: 0.6rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  color: var(--text-main);
  margin-top: auto;
}

/* Modal accesible de receta */
.appliance-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.appliance-modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-window {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  z-index: 10;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

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

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  border-radius: 6px;
  transition: color 0.15s, background-color 0.15s;
}

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

.modal-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: var(--bg-accent);
  padding: 1rem;
  border-radius: 8px;
}

.modal-meta-item .meta-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.modal-meta-item .meta-val {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-main);
}

.modal-body-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

.modal-steps-content {
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-protip-box {
  background: rgba(245, 158, 11, 0.08);
  border-left: 4px solid var(--accent-warning);
  padding: 1rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.875rem;
  color: var(--text-main);
  line-height: 1.5;
}

/* Sidebar publicitario canónico */
.tool-ad-sidebar {
  display: none;
  width: 300px;
  flex-shrink: 0;
}

@media (min-width: 1536px) {
  .tool-ad-sidebar {
    display: block;
  }
}

.sticky-ad-box {
  position: sticky;
  top: 1.5rem;
}

/* Responsividad táctil para móvil */
@media (max-width: 768px) {
  .tool-layout {
    margin: 1rem auto 2rem;
    padding: 0 0.75rem;
  }

  .tool-hero-box {
    padding: 1.25rem;
  }

  .tool-page-title {
    font-size: 1.35rem;
  }

  .tool-nav-tabs {
    gap: 0.25rem;
  }

  .tool-nav-btn {
    padding: 0.6rem 0.75rem;
    font-size: 0.875rem;
  }

  .content-card {
    padding: 1.15rem;
  }

  .input-units-grid {
    grid-template-columns: 1fr;
  }

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

  .modal-meta-grid {
    grid-template-columns: 1fr;
  }

  .modal-window {
    padding: 1.25rem;
  }
}
