/* ==========================================================================
   Fijate Tools - Conversor de medidas de cocina por ingrediente y densidad
   Estilos corporativos canónicos, temas claro/oscuro y componentes interactivos
   ========================================================================== */

: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);
  --culinary-emerald: #10b981;
  --culinary-cyan: #06b6d4;
  --culinary-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;
}

/* Pestañas de la herramienta */
.density-tabs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: var(--bg-card);
  padding: 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

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

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

.tab-btn.active {
  background: var(--bg-pill-active);
  color: #ffffff;
  border-color: var(--border-focus);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.tab-pane {
  display: none;
}

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

/* ==========================================================================
   TAB 1: CONVERSOR UNITARIO EN 2 COLUMNAS
   ========================================================================== */

.converter-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.panel-column {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.panel-column-title {
  font-size: 1.15rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.65rem;
}

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

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

.form-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-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  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;
}

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

.input-with-select {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 0.5rem;
}

.amount-input {
  width: 100%;
  min-height: 44px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  outline: none;
}

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

/* Panel de resultado digital */
.result-display-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.digital-hero-readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}

.digital-hero-readout::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
}

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

.digital-hero-number {
  font-family: var(--font-mono);
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  margin: 0.2rem 0;
}

.digital-hero-unit {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.density-badge-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.density-k {
  color: var(--text-muted);
}

.density-v {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--culinary-cyan);
}

.quick-equivalents-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.equiv-cell {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.equiv-cell-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.equiv-cell-val {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ==========================================================================
   TAB 2: CONVERSOR DE RECETAS COMPLETAS
   ========================================================================== */

.recipe-converter-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.recipe-input-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: 1rem;
}

.recipe-textarea {
  width: 100%;
  min-height: 130px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.recipe-textarea:focus {
  border-color: var(--border-focus);
}

.recipe-results-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

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

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

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

.recipe-results-table td.res-converted {
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--accent);
}

/* ==========================================================================
   TAB 3: TABLA DE DENSIDADES CULINARIAS COMPLETA
   ========================================================================== */

.density-catalog-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.catalog-search-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
}

.search-field-inner {
  position: relative;
  flex: 1 1 280px;
}

.search-icon-svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.catalog-search-input {
  width: 100%;
  min-height: 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem 0.45rem 2.4rem;
  font-size: 0.92rem;
  color: var(--text-primary);
  outline: none;
}

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

/* Pastillas de categorías - sin scroll horizontal artificial */
.catalog-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

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

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

.cat-pill-btn.active {
  background: var(--accent);
  color: #000000;
  font-weight: 700;
  border-color: var(--accent);
}

/* Tabla de densidades */
.density-full-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

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

.density-full-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;
}

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

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

.density-full-table td.density-cell-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--culinary-cyan);
}

.density-full-table td.mass-cell-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

/* Botones de acción generales */
.btn-primary-action {
  min-height: 44px;
  padding: 0.5rem 1.25rem;
  background: var(--bg-pill-active);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s ease;
}

.btn-primary-action:hover {
  filter: brightness(1.1);
}

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

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

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

.density-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) {
  .converter-workspace {
    grid-template-columns: 1fr;
  }
}

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

  .density-tabs-nav {
    flex-direction: column;
  }

  .tab-btn {
    width: 100%;
    justify-content: flex-start;
  }

  .input-with-select {
    grid-template-columns: 1fr;
  }

  .quick-equivalents-list {
    grid-template-columns: 1fr;
  }

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