/* ==========================================================================
   Fijate Tools - Guía y calculadora de conservación de alimentos y vida útil
   Estilos canónicos responsivos para tema claro y tema oscuro
   ========================================================================== */

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

  /* Paleta tema claro */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-focus: #10b981;

  /* Identidad: Verde esmeralda y acentos de inocuidad alimentaria */
  --primary-color: #059669;
  --primary-hover: #047857;
  --primary-light: #ecfdf5;

  --accent-teal: #0d9488;
  --accent-blue: #2563eb;

  /* Semáforos de inocuidad alimentaria */
  --safe-green: #10b981;
  --safe-green-bg: #ecfdf5;
  --safe-green-border: #a7f3d0;
  --safe-green-text: #065f46;

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

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

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

[data-theme="dark"] {
  --bg-page: #0b0f17;
  --bg-card: #151d2c;
  --bg-card-subtle: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-focus: #34d399;

  --primary-color: #10b981;
  --primary-hover: #34d399;
  --primary-light: #064e3b33;

  --safe-green: #34d399;
  --safe-green-bg: rgba(6, 78, 59, 0.35);
  --safe-green-border: #065f46;
  --safe-green-text: #a7f3d0;

  --warning-amber: #fbbf24;
  --warning-amber-bg: rgba(120, 53, 15, 0.35);
  --warning-amber-border: #92400e;
  --warning-amber-text: #fde68a;

  --danger-red: #f87171;
  --danger-red-bg: rgba(127, 29, 29, 0.35);
  --danger-red-border: #991b1b;
  --danger-red-text: #fecaca;

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

/* Reset y estructura básica */
*, *::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-page);
  color: var(--text-main);
  font-family: var(--font-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Contenedor canónico de la herramienta */
.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 y encabezados */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

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

/* Introducción y pestañas de modo */
.tool-header-block {
  margin-bottom: 1.75rem;
}

.tool-intro-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.tool-intro-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.tool-intro-card p:last-child {
  margin-bottom: 0;
}

.nav-tabs-container {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-tab-btn:hover {
  color: var(--primary-color);
  background: var(--bg-card-subtle);
}

.nav-tab-btn.active {
  color: var(--primary-color);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-bottom: 2px solid var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Tarjeta principal interactiva */
.app-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

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

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

/* Filtros rápidos y buscador */
.search-filter-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.search-input-group {
  position: relative;
  width: 100%;
}

.search-input-group svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.input-search-text {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.6rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card-subtle);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.95rem;
  min-height: 44px;
  transition: border-color 0.2s, background-color 0.2s;
}

.input-search-text:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-card);
}

.category-chips-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  scrollbar-width: thin;
}

.category-chip {
  padding: 0.45rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.category-chip:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.category-chip.active {
  background: var(--primary-light);
  color: var(--primary-color);
  border-color: var(--primary-color);
  font-weight: 600;
}

/* Form controls estilizados */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

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

.form-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.form-select, .form-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.65rem 2.5rem 0.65rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-card-subtle);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.95rem;
  box-sizing: border-box;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  transition: border-color 0.2s, background-color 0.2s;
  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 0.75rem center;
  background-size: 16px 16px;
}

.form-input {
  padding-right: 0.85rem;
  background-image: none;
}

.form-select:focus, .form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  background-color: var(--bg-card);
}

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

/* Resultados y tarjeta KPI */
.result-display-panel {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1.25rem;
}

.kpi-shelf-life-box {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.kpi-shelf-life-val {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--primary-color);
  line-height: 1;
}

.kpi-shelf-life-unit {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
}

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

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

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

/* Grid de detalles de conservación */
.details-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.detail-item-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.detail-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.detail-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.detail-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  line-height: 1.4;
}

/* Avisos y alertas de seguridad */
.alert-box {
  display: flex;
  gap: 0.85rem;
  padding: 1rem 1.2rem;
  border-radius: var(--radius-md);
  margin-top: 1rem;
  font-size: 0.92rem;
  line-height: 1.45;
}

.alert-box svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-box.safe {
  background: var(--safe-green-bg);
  border: 1px solid var(--safe-green-border);
  color: var(--safe-green-text);
}

.alert-box.warning {
  background: var(--warning-amber-bg);
  border: 1px solid var(--warning-amber-border);
  color: var(--warning-amber-text);
}

.alert-box.danger {
  background: var(--danger-red-bg);
  border: 1px solid var(--danger-red-border);
  color: var(--danger-red-text);
}

/* Comparativa de métodos (tabla visual) */
.methods-table-wrapper {
  overflow-x: auto;
  margin-top: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.methods-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--bg-card);
  text-align: left;
}

.methods-table th {
  background: var(--bg-card-subtle);
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

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

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

.methods-table tr:hover td {
  background: var(--bg-card-subtle);
}

/* Asistente de conservas y semáforo de botulismo */
.botulism-status-card {
  padding: 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.botulism-status-card.acid {
  background: var(--safe-green-bg);
  border-color: var(--safe-green);
  color: var(--safe-green-text);
}

.botulism-status-card.low-acid {
  background: var(--danger-red-bg);
  border-color: var(--danger-red);
  color: var(--danger-red-text);
}

.status-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.status-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.status-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
}

/* Checklist de seguridad para conservas */
.checklist-container {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.2s;
  user-select: none;
}

.check-item:hover {
  background: var(--bg-card-subtle);
}

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

.check-item-text {
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.4;
}

/* Calculadora de descongelación */
.defrost-calculator-box {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.defrost-methods-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.defrost-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

.defrost-card.recommended {
  border-color: var(--safe-green);
  box-shadow: 0 0 0 1px var(--safe-green);
}

.defrost-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 4px;
}

.defrost-card.recommended .defrost-card-badge {
  background: var(--safe-green-bg);
  color: var(--safe-green-text);
  border: 1px solid var(--safe-green-border);
}

.defrost-card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.defrost-time-val {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 0.5rem 0;
}

.defrost-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: auto;
}

/* Guía educativa y acordeones SEO */
.seo-guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin: 2rem 0;
}

.seo-guide-header {
  margin-bottom: 1.25rem;
}

.seo-guide-title {
  font-size: 1.35rem;
  margin-bottom: 0.4rem;
}

.seo-guide-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card-subtle);
  overflow: hidden;
  transition: border-color 0.2s;
}

.faq-item summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
  user-select: none;
}

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

.faq-item summary::after {
  content: "+";
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.faq-item[open] summary::after {
  content: "−";
  transform: rotate(180deg);
  color: var(--primary-color);
}

.faq-item[open] summary {
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}

.faq-content {
  padding: 1.25rem;
  background: var(--bg-card);
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-main);
}

.faq-content p {
  margin-bottom: 0.75rem;
}

.faq-content p:last-child {
  margin-bottom: 0;
}

.faq-content ul, .faq-content ol {
  padding-left: 1.4rem;
  margin-bottom: 0.75rem;
}

.faq-content li {
  margin-bottom: 0.35rem;
}

/* Modal accesible para avisos o detalles */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 23, 0.75);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

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

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

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

/* Responsive adjustments */
@media (max-width: 768px) {
  .tool-layout {
    margin: 1rem auto 2rem;
    padding: 0 0.75rem;
  }

  .nav-tab-btn {
    padding: 0.65rem 0.85rem;
    font-size: 0.88rem;
  }

  .app-card {
    padding: 1.15rem;
  }

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

  .kpi-shelf-life-val {
    font-size: 1.8rem;
  }

  .methods-table th, .methods-table td {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
  }
}
