/* ==========================================================================
   Calculadora de raciones de carbohidratos - fijate.com
   Estilos canónicos con soporte Dark/Light Mode y diseño táctil optimizado
   ========================================================================== */

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

  /* Tema claro */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #16a34a;

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

  --primary: #16a34a;
  --primary-hover: #15803d;
  --primary-light: #dcfce7;

  --teal: #0d9488;
  --teal-light: #ccfbf1;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;

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

[data-theme="dark"] {
  --bg-app: #0b0f17;
  --bg-card: #131b29;
  --bg-card-subtle: #1c2638;
  --border-color: #26334a;
  --border-focus: #4ade80;

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

  --primary: #4ade80;
  --primary-hover: #86efac;
  --primary-light: rgba(74, 222, 128, 0.15);

  --teal: #2dd4bf;
  --teal-light: rgba(45, 212, 191, 0.15);
  --warning: #fbbf24;
  --warning-light: rgba(251, 191, 36, 0.15);
  --danger: #f87171;
  --danger-light: rgba(248, 113, 113, 0.15);

  --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);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  overflow-x: clip;
}

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

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

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

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

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

/* Pestañas de modo */
.tabs-nav {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.35rem;
  gap: 0.35rem;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  min-height: 40px;
}

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

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .tab-btn.active {
  color: #0b0f17;
}

/* Paneles de modo */
.mode-panel {
  display: none;
}

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

/* Rejilla de 2 columnas */
.calc-grid-wrapper {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.5rem;
  align-items: stretch;
}

@media (max-width: 960px) {
  .calc-grid-wrapper {
    grid-template-columns: 1fr;
  }
}

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

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

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

/* Buscador con dropdown */
.search-input-wrap {
  position: relative;
}

.suggestions-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  margin-top: 4px;
}

.suggestion-item {
  padding: 0.65rem 0.85rem;
  font-size: 0.88rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background: var(--bg-card-subtle);
  color: var(--primary);
}

/* Tarjeta del alimento seleccionado */
.selected-food-card {
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
}

.food-info-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.food-name {
  font-size: 1.05rem;
  color: var(--text-main);
}

.badge-gi {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
}

.gi-low {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.gi-medium {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.gi-high {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.food-info-props {
  display: flex;
  gap: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.food-tip-text {
  font-size: 0.82rem;
  color: var(--text-subtle);
  font-style: italic;
}

/* Form inputs */
.form-group {
  margin-bottom: 1.15rem;
}

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

.form-input {
  width: 100%;
  height: 44px;
  padding: 0 0.85rem;
  font-size: 1rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus {
  border-color: var(--border-focus);
}

.form-input.text-large {
  font-size: 1.25rem;
  font-weight: 700;
  height: 48px;
}

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

.input-unit-wrapper .form-input {
  padding-right: 75px;
}

.input-suffix {
  position: absolute;
  right: 12px;
  font-size: 0.85rem;
  color: var(--text-subtle);
  font-weight: 600;
  pointer-events: none;
}

.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 40px 0 0.85rem;
  font-size: 0.92rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  color: var(--text-main);
  outline: none;
  appearance: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  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 12px center;
  cursor: pointer;
}

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

.section-divider-top {
  border-top: 1px dashed var(--border-color);
  padding-top: 1rem;
}

.helper-text {
  display: block;
  font-size: 0.8rem;
  color: var(--text-subtle);
  margin-top: 0.35rem;
}

/* Caja de resultados del alimento */
.result-badge-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-around;
  margin: 1.25rem 0;
}

.result-badge-col {
  text-align: center;
}

.badge-sub {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.badge-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.badge-unit-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--text-subtle);
  margin-top: 0.25rem;
}

/* Modo Pauta Highlight */
.result-pauta-highlight {
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: linear-gradient(135deg, var(--primary-light), var(--bg-card-subtle));
  border-color: var(--primary);
}

.pauta-hero-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  margin: 0.4rem 0;
}

.pauta-hero-num {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.pauta-hero-unit {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 0 1.25rem;
  height: 44px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  width: 100%;
  min-height: 40px;
}

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

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

[data-theme="dark"] .btn-primary {
  color: #0b0f17;
}

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

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

.btn-text-danger {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

/* Tarjeta Mi Plato */
.plate-hero-card {
  background: linear-gradient(135deg, var(--primary-light), var(--bg-card-subtle));
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.plate-hero-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.plate-number-wrap {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.25rem 0;
}

.plate-hero-num {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.plate-hero-unit {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-muted);
}

.plate-grams-badge {
  font-size: 0.82rem;
  color: var(--text-subtle);
}

.plate-items-container {
  margin-bottom: 1.25rem;
}

.plate-items-title {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
  font-weight: 600;
}

.plate-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 240px;
  overflow-y: auto;
}

.plate-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
}

.plate-item-info {
  display: flex;
  flex-direction: column;
}

.plate-item-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.plate-item-grams {
  font-size: 0.78rem;
  color: var(--text-subtle);
}

.plate-item-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.plate-item-rations {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}

.btn-remove-item {
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0 0.35rem;
  border-radius: 4px;
}

.btn-remove-item:hover {
  color: var(--danger);
  background: var(--danger-light);
}

.empty-plate-hint {
  font-size: 0.85rem;
  color: var(--text-subtle);
  text-align: center;
  padding: 1.5rem 1rem;
  font-style: italic;
}

/* Puente a la calculadora de bolo */
.insulin-bridge-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 1rem;
}

.bridge-text strong {
  font-size: 0.92rem;
  color: var(--text-main);
}

.bridge-text p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0.75rem;
}

.btn-bridge {
  text-decoration: none;
  color: var(--text-main);
  text-align: center;
}

/* Catálogo de alimentos */
.catalog-filters-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

@media (max-width: 640px) {
  .catalog-filters-row {
    grid-template-columns: 1fr;
  }
}

.table-scroll-wrap {
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

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

.catalog-table th {
  background: var(--bg-card-subtle);
  padding: 0.75rem 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  border-bottom: 1.5px solid var(--border-color);
}

.catalog-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

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

/* FAQ */
.faq-section {
  margin-top: 1.5rem;
}

.faq-item {
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
}

.faq-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-question {
  font-size: 1.05rem;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.faq-answer {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Modales */
.fijate-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 15, 23, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.fijate-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.fijate-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

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

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

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

.fijate-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-section-h4 {
  font-size: 0.98rem;
  color: var(--text-main);
  margin: 1rem 0 0.4rem;
}

.modal-section-h4:first-child {
  margin-top: 0;
}

.formula-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--primary);
  margin-bottom: 0.45rem;
}

.modal-ul {
  padding-left: 1.25rem;
  margin-top: 0.4rem;
}

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