/* ==========================================================================
   Calculadora de Panadería Artesanal y Temperatura DDT - Fijate Tools
   Estilos Canónicos y Sistema Visual Obrador Profesional
   ========================================================================== */

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

  /* Paleta base Midnight Slate con acentos dorados panaderos */
  --bg-primary: #0b0f17;
  --bg-card: #131b26;
  --bg-card-hover: #1a2534;
  --bg-input: #1a2433;
  --bg-subtle: rgba(255, 255, 255, 0.04);
  --border-color: #243247;
  --border-focus: #f59e0b;

  --text-main: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  /* Acentos de panadería: Ámbar, Trigo, Miga y Calor */
  --amber-primary: #f59e0b;
  --amber-hover: #d97706;
  --amber-glow: rgba(245, 158, 11, 0.15);
  --wheat-gold: #fbbf24;
  --crust-dark: #b45309;

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info-cyan: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --bg-subtle: rgba(0, 0, 0, 0.03);
  --border-color: #e2e8f0;
  --border-focus: #d97706;

  --text-main: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --amber-primary: #d97706;
  --amber-hover: #b45309;
  --amber-glow: rgba(217, 119, 6, 0.12);

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

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

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

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.card-header-title {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

.mono, code, .metric-value, .percent-val, .badge-calc {
  font-family: var(--font-mono);
}

/* Layout Canónico */
.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: 1.75rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

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

/* Barra superior de pestañas de la herramienta */
.tool-nav-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  background: var(--bg-subtle);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 1.75rem;
}

.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  white-space: nowrap;
}

.nav-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab-btn.is-active {
  background: var(--amber-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

/* Paneles de Pestañas */
.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Presets Carousel / Grid de panes */
.presets-container {
  margin-bottom: 1.75rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

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

.presets-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.presets-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 38px;
}

.preset-chip-btn:hover {
  border-color: var(--amber-primary);
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.preset-chip-btn.is-selected {
  border-color: var(--amber-primary);
  background: var(--amber-glow);
  color: var(--amber-primary);
  font-weight: 700;
}

/* Modos de cálculo (Harina, Masa total, Piezas) */
.calc-modes-selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.mode-radio-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 0.5rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  min-height: 64px;
}

.mode-radio-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-radio-card:hover {
  border-color: var(--amber-primary);
}

.mode-radio-card.is-active {
  border-color: var(--amber-primary);
  background: var(--amber-glow);
}

.mode-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.mode-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Formularios y cuadrícula de inputs */
.form-grid-dual {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

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

.input-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
}

.input-label-badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--amber-primary);
  font-weight: 700;
}

.input-flex-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 44px;
  transition: border-color 0.2s ease;
}

.input-flex-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--amber-glow);
}

.input-flex-wrapper input[type="number"],
.input-flex-wrapper input[type="text"] {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-main);
  padding: 0 0.85rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
}

.input-flex-wrapper input:focus {
  outline: none;
}

.input-suffix {
  padding: 0 0.85rem;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
  background: var(--bg-subtle);
  height: 100%;
  display: flex;
  align-items: center;
  border-left: 1px solid var(--border-color);
  user-select: none;
}

/* Desplegables select canónicos */
.select-wrapper {
  position: relative;
  width: 100%;
}

.select-wrapper select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 40px 0 0.85rem;
  font-size: 0.9rem;
  font-family: var(--font-main);
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}

.select-wrapper select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.select-arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
}

/* Sliders de porcentaje panadero */
.ingredients-slider-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.slider-row {
  display: grid;
  grid-template-columns: 180px 1fr 100px;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-color);
}

.slider-row:last-child {
  border-bottom: none;
}

.slider-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
}

.slider-subinfo {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 450;
}

.slider-control input[type="range"] {
  width: 100%;
  accent-color: var(--amber-primary);
  cursor: pointer;
  height: 6px;
  background: var(--bg-input);
  border-radius: 4px;
}

.slider-val-box {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--amber-primary);
}

/* Resultados y Ficha Técnica de Ingredientes */
.results-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1.5rem;
}

.results-header-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.summary-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  text-align: center;
}

.summary-pill-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.summary-pill-val {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
}

.summary-pill.highlight-amber .summary-pill-val {
  color: var(--amber-primary);
}

/* Tabla canónica de fórmula panadera */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  margin-bottom: 1.25rem;
}

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

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

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

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

.bread-table td.col-num {
  font-family: var(--font-mono);
  font-weight: 600;
  text-align: right;
}

.bread-table tr.total-row {
  background: var(--bg-subtle);
  font-weight: 700;
}

.bread-table tr.total-row td {
  border-top: 2px solid var(--border-color);
  color: var(--amber-primary);
}

/* Tarjeta informativa de sal y norma RD 308/2019 */
.law-notice-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  margin-top: 1rem;
  font-size: 0.84rem;
}

.law-notice-card.compliant {
  border-left: 4px solid var(--success);
}

.law-notice-card.non-compliant {
  border-left: 4px solid var(--warning);
}

.law-notice-icon {
  flex-shrink: 0;
  margin-top: 2px;
}

/* Visualizador Termodinámico DDT (Desired Dough Temperature) */
.ddt-gauge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.75rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  text-align: center;
}

.ddt-main-display {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0.75rem 0;
}

.ddt-target-degree {
  font-family: var(--font-mono);
  font-size: 3.25rem;
  font-weight: 800;
  line-height: 1;
}

.ddt-target-degree.temp-hot { color: var(--danger); }
.ddt-target-degree.temp-optimal { color: var(--success); }
.ddt-target-degree.temp-ice { color: var(--info-cyan); }

.ddt-unit {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.ice-alert-box {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--info-bg);
  border: 1px solid var(--info-cyan);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  text-align: left;
}

.ice-quantities {
  display: flex;
  gap: 1.5rem;
}

.ice-metric {
  display: flex;
  flex-direction: column;
}

.ice-metric-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.ice-metric-val {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--info-cyan);
}

/* Ficha de Obrador Imprimible A4 */
.obrador-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2rem;
  position: relative;
}

.obrador-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}

.obrador-brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
}

.obrador-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  background: var(--bg-subtle);
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
}

.obrador-meta-item {
  display: flex;
  flex-direction: column;
}

.obrador-meta-item span {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.obrador-meta-item strong {
  font-size: 0.92rem;
  font-family: var(--font-mono);
  color: var(--text-main);
}

.action-buttons-bar {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.65rem 1.25rem;
  background: var(--amber-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--amber-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.65rem 1.25rem;
  background: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* Modales canónicos accesibles */
.can-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 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.25s ease;
}

.can-modal.is-open {
  opacity: 1;
  visibility: visible;
}

.can-modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.25s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.can-modal.is-open .can-modal-content {
  transform: scale(1);
}

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

.can-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  border-radius: var(--radius-sm);
}

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

/* Sección SEO Canónica */
.seo-guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-top: 2rem;
}

.seo-guide-section h2 {
  font-size: 1.35rem;
  margin-bottom: 1rem;
  color: var(--text-main);
}

.seo-guide-section h3 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.75rem;
  color: var(--wheat-gold);
}

.seo-guide-section p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.seo-guide-section ul {
  list-style: square;
  padding-left: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.seo-guide-section li {
  margin-bottom: 0.5rem;
}

/* Responsive móvil */
@media (max-width: 768px) {
  .tool-nav-tabs {
    grid-template-columns: 1fr;
  }

  .calc-modes-selector {
    grid-template-columns: 1fr;
  }

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

  .slider-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .slider-val-box {
    text-align: left;
  }

  .results-header-summary {
    grid-template-columns: 1fr;
  }

  .obrador-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ice-alert-box {
    flex-direction: column;
    align-items: flex-start;
  }

  .action-buttons-bar {
    flex-direction: column;
  }

  .btn-primary, .btn-secondary {
    width: 100%;
  }
}

/* Estilos de impresión A4 para la ficha técnica del obrador */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .app-header,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .fijate-footer,
  .tool-nav-tabs,
  .presets-container,
  .calc-modes-selector,
  .ingredients-slider-box,
  .action-buttons-bar,
  .seo-guide-section,
  .can-modal {
    display: none !important;
  }

  .tool-layout {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .card-main {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: transparent !important;
  }

  .tab-panel {
    display: block !important;
  }

  .obrador-sheet {
    border: 1px solid #000 !important;
    color: #000 !important;
    background: #fff !important;
  }

  .bread-table th {
    background: #f0f0f0 !important;
    color: #000 !important;
  }

  .bread-table td {
    color: #000 !important;
  }
}
