/**
 * Estilos para Semáforo Nutricional Renal (fijate.com)
 * Medidores de electrolitos, buscador tricolor y técnicas de lixiviación
 */

:root {
  --bg-primary: #0f172a;
  --bg-card: #1e293b;
  --bg-card-subtle: #182234;
  --bg-input: #0b1120;
  --border-color: #334155;
  --border-color-hover: #475569;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #059669;
  --accent-hover: #047857;
  --accent-glow: rgba(5, 150, 105, 0.2);
  --color-green: #10b981;
  --color-yellow: #f59e0b;
  --color-red: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

[data-theme="light"], body.light-theme {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-color-hover: #94a3b8;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-primary: #059669;
  --accent-hover: #047857;
  --accent-glow: rgba(5, 150, 105, 0.15);
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
}

.mono-num {
  font-family: 'JetBrains Mono', monospace;
}

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

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

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

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

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.card-title {
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}

.card-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.stage-selector-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
}

.stage-label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Medidores de Electrolitos (Barras de balance diario) */
.minerals-gauge-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.gauge-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.gauge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.gauge-name {
  font-weight: 700;
  color: var(--text-secondary);
}

.gauge-vals {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.gauge-vals strong {
  color: var(--text-primary);
  font-size: 1rem;
}

.gauge-bar-track {
  width: 100%;
  height: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.gauge-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.bar-safe { background: var(--color-green); }
.bar-warning { background: var(--color-yellow); }
.bar-danger { background: var(--color-red); }

.gauge-status {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Tabs */
.card-tabs-section {
  padding: 0;
  overflow: hidden;
}

.tabs-nav-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  padding: 0 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tabs-nav {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  white-space: nowrap;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.9rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.tabs-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.btn-action-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action-sm:hover { background: var(--border-color); }
.btn-danger-soft { color: #ef4444; }
.btn-danger-soft:hover { background: rgba(239, 68, 68, 0.15); border-color: #ef4444; }

.tab-pane {
  display: none;
  padding: 1.5rem;
}

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

/* Buscador y filtros de alimentos */
.food-search-bar-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-input-wrap {
  flex: 1 1 240px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrap svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 44px;
  padding: 0 1rem 0 2.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.92rem;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.category-filter-wrap, .traffic-filter-wrap {
  flex: 0 1 220px;
}

.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 40px 0 0.85rem;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  outline: none;
  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='%2394a3b8' 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;
  background-size: 16px;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

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

/* Tablas */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

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

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

.clinical-table td {
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

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

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem 1rem;
}

.total-row th {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
  font-weight: 800;
  border-top: 2px solid var(--border-color);
  padding: 0.85rem 0.9rem;
}

/* Píldoras de Semáforo */
.traffic-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill-green {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.pill-yellow {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.pill-red {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-add-food {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--accent-primary);
  color: #fff;
  border: none;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-add-food:hover {
  background: var(--accent-hover);
}

.btn-table-del {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 4px;
}

.btn-table-del:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

/* Guía de lixiviación */
.leaching-guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.leaching-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.leaching-badge {
  background: var(--accent-primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  align-self: flex-start;
}

.leaching-card h4 {
  font-size: 1.05rem;
}

.leaching-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.phosphorus-alert-box {
  background: rgba(245, 158, 11, 0.1);
  border: 1.5px solid #f59e0b;
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.phosphorus-alert-box h3 {
  font-size: 1.1rem;
  color: #f59e0b;
  margin-bottom: 0.5rem;
}

.phosphorus-alert-box p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Formulario genérico y modales */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  height: 44px;
  padding: 0 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.92rem;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
}

.btn-primary { background: var(--accent-primary); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-card-subtle); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--border-color); }

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

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

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  max-width: 480px;
  width: 100%;
  overflow: hidden;
}

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

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.25rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-card-subtle);
  border-top: 1px solid var(--border-color);
}

.faq-section { margin-top: 1rem; }
.faq-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.faq-item { border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--bg-card-subtle); padding: 0.85rem 1.15rem; }
.faq-question { font-weight: 600; font-size: 0.95rem; color: var(--text-primary); cursor: pointer; }
.faq-answer { margin-top: 0.6rem; font-size: 0.88rem; color: var(--text-secondary); line-height: 1.5; }

.report-clinical-header { display: none; }

/* Responsive Móvil */
@media (max-width: 900px) {
  .minerals-gauge-grid { grid-template-columns: 1fr 1fr; }
  .leaching-guide-grid { grid-template-columns: 1fr; }
  .stage-selector-wrap { width: 100%; }
}

@media (max-width: 600px) {
  .minerals-gauge-grid { grid-template-columns: 1fr; }
  .category-filter-wrap, .traffic-filter-wrap { flex: 1 1 100%; }
}

/* @media print para Menú Renal y balance */
@media print {
  body { background: #ffffff !important; color: #000000 !important; }
  .app-header, .fijate-footer, .tool-ad-sidebar, .tools-ad-banner-section, .food-search-bar-row, .tabs-nav-wrapper, .btn-action-sm, .btn-table-del, .faq-section, #tab-buscador, #tab-lixiviacion {
    display: none !important;
  }
  .tool-layout, .card-main { margin: 0 !important; padding: 0 !important; border: none !important; box-shadow: none !important; }
  .tab-pane { display: block !important; padding: 0 !important; }
  .report-clinical-header { display: flex !important; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 15px; }
  .clinical-table { border: 1px solid #333 !important; font-size: 9pt !important; }
  .clinical-table th { background: #eaeaea !important; color: #000 !important; border: 1px solid #ccc !important; }
  .clinical-table td { border: 1px solid #ddd !important; color: #000 !important; }
}
