/* ==========================================================================
   Fijate Tools - Calculadora de moldes de repostería
   Estilos corporativos canónicos, visualizador geométrico SVG y escalado reactivo
   ========================================================================== */

:root {
  --bg-page: #0b0f17;
  --bg-card: #131b26;
  --bg-card-hover: #182230;
  --bg-input: #1a2434;
  --bg-pill: #1f2a3a;
  --bg-pill-active: #2563eb;
  --border-color: #233044;
  --border-focus: #3b82f6;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #f59e0b;
  --accent-light: rgba(245, 158, 11, 0.12);
  --accent-border: rgba(245, 158, 11, 0.3);
  --mold-origin: #06b6d4;
  --mold-dest: #f59e0b;
  --mold-emerald: #10b981;
  --mold-purple: #8b5cf6;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"],
body.light-theme {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f1f5f9;
  --bg-pill: #e2e8f0;
  --bg-pill-active: #2563eb;
  --border-color: #cbd5e1;
  --border-focus: #2563eb;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #d97706;
  --accent-light: rgba(217, 119, 6, 0.1);
  --accent-border: rgba(217, 119, 6, 0.25);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
}

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

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

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

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

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

.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.5rem;
}

/* ==========================================================================
   WORKSPACE EN 2 COLUMNAS (CONFIGURACIÓN MOLDES + VISOR)
   ========================================================================== */

.molds-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.molds-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
}

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

.molds-card-title {
  font-size: 1.2rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Cajas de molde individual (Origen vs Destino) */
.molds-boxes-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.mold-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.mold-box.box-origin {
  border-left: 4px solid var(--mold-origin);
}

.mold-box.box-dest {
  border-left: 4px solid var(--mold-dest);
}

.mold-box-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mold-pill-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-origin {
  background: rgba(6, 182, 212, 0.15);
  color: var(--mold-origin);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.badge-dest {
  background: rgba(245, 158, 11, 0.15);
  color: var(--mold-dest);
  border: 1px solid var(--accent-border);
}

/* Selectores de forma */
.form-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

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

.mold-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.5rem 2.2rem 0.5rem 0.85rem;
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: var(--font-sans);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' 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;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}

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

/* Campos numéricos de dimensiones */
.mold-inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
}

.input-with-suffix {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-height: 42px;
}

.input-with-suffix:focus-within {
  border-color: var(--border-focus);
}

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

.input-suffix-badge {
  padding: 0 0.65rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  user-select: none;
  border-left: 1px solid var(--border-color);
}

.mold-specs-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border-color);
}

.mold-specs-line strong {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* ==========================================================================
   PANEL DERECHO: FACTOR DE ESCALA + VISUALIZADOR SVG
   ========================================================================== */

.factor-banner-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.factor-val-box {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.factor-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

.factor-number {
  font-family: var(--font-mono);
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.factor-badge {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  color: var(--accent);
}

/* Visualizador SVG comparativo */
.svg-stage-container {
  width: 100%;
  height: 240px;
  background: #06090e;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

[data-theme="light"] .svg-stage-container,
body.light-theme .svg-stage-container {
  background: #f1f5f9;
}

.svg-stage {
  width: 100%;
  height: 100%;
}

.svg-legend {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-dot.dot-origin {
  background: var(--mold-origin);
  border: 1px dashed rgba(255, 255, 255, 0.5);
}

.legend-dot.dot-dest {
  background: var(--mold-dest);
}

/* Tarjeta de ajuste de tiempo y grosor */
.baking-adjustment-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.88rem;
}

.baking-adj-title {
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.baking-adj-desc {
  color: var(--text-secondary);
  line-height: 1.45;
}

/* ==========================================================================
   TABLA DINÁMICA DE INGREDIENTES DE LA RECETA
   ========================================================================== */

.ingredients-section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.recipe-presets-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recipe-presets-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.recipe-pills-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

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

.recipe-pill-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.recipe-pill-btn.active {
  background: var(--bg-pill-active);
  color: #ffffff;
  border-color: var(--border-focus);
}

.ingredients-table-wrap {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

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

.ingredients-table th {
  background: var(--bg-input);
  padding: 0.85rem 1rem;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

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

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

.ingredient-input-name {
  width: 100%;
  min-height: 38px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-sans);
}

.ingredient-input-name:focus {
  background: var(--bg-input);
  border-color: var(--border-focus);
  outline: none;
}

.ingredient-input-amount {
  width: 80px;
  min-height: 38px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-primary);
  text-align: right;
}

.ingredient-input-amount:focus {
  background: var(--bg-input);
  border-color: var(--border-focus);
  outline: none;
}

.scaled-result-cell {
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--accent);
  font-size: 1rem;
  white-space: nowrap;
}

.egg-hint-badge {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--mold-emerald);
  margin-top: 0.2rem;
}

.btn-remove-row {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 4px;
}

.btn-remove-row:hover {
  color: #ef4444;
}

.table-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

.btn-add-ingredient {
  min-height: 40px;
  padding: 0.45rem 1rem;
  background: var(--bg-input);
  border: 1px dashed var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-add-ingredient:hover {
  border-color: var(--border-focus);
  background: var(--bg-card-hover);
}

.secondary-actions-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-sec-action {
  min-height: 40px;
  padding: 0.45rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-sec-action:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

/* ==========================================================================
   GUÍA DIDÁCTICA Y SEO (2 COLUMNAS CANÓNICAS)
   ========================================================================== */

.molds-seo-guide {
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
}

.seo-guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.seo-guide-card h2,
.seo-guide-card h3 {
  font-size: 1.25rem;
  color: var(--text-primary);
}

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

.seo-guide-card ul {
  padding-left: 1.2rem;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ==========================================================================
   RESPONSIVIDAD MÓVIL
   ========================================================================== */

@media (max-width: 900px) {
  .molds-workspace {
    grid-template-columns: 1fr;
  }
}

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

  .molds-card {
    padding: 1rem;
  }

  .mold-inputs-grid {
    grid-template-columns: 1fr 1fr;
  }

  .table-actions-row {
    flex-direction: column;
    align-items: stretch;
  }

  .secondary-actions-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .btn-sec-action,
  .btn-add-ingredient {
    width: 100%;
    justify-content: center;
  }

  .molds-seo-guide {
    grid-template-columns: 1fr;
  }
}
