/* ==========================================================================
   Generador de etiquetas nutricionales y Nutri-Score - Estilos visuales
   ========================================================================== */

:root {
  --primary-color: #10b981;
  --primary-hover: #059669;
  --primary-light: rgba(16, 185, 129, 0.15);
  --warning-color: #f59e0b;
  --danger-color: #ef4444;

  --bg-app: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-header: #19243d;
  --bg-input: #0f172a;
  --border-color: #1e293b;
  --border-color-focus: #10b981;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

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

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-header: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-color-focus: #10b981;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

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

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

.main-wrapper {
  flex: 1;
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.tool-with-sidebar {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}

.tool-main-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Hero */
.tool-hero {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.tool-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--primary-light);
  color: var(--primary-color);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 20px;
  margin-bottom: 12px;
}

.tool-hero h2 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.tool-hero p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Barra de Plantillas */
.presets-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.presets-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.presets-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.preset-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: var(--primary-light);
}

/* Área de Trabajo de 2 Columnas */
.nutrition-workspace {
  display: grid;
  grid-template-columns: 50% 50%;
  gap: 20px;
  align-items: start;
}

.form-pane, .preview-pane {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.pane-head {
  background: var(--bg-card-header);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pane-head h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.preview-actions {
  display: flex;
  gap: 8px;
}

.btn-action-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-action-sm:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: var(--primary-light);
}

/* Formulario */
.form-section {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-bottom: 1px solid var(--border-color);
}

.form-section:last-child {
  border-bottom: none;
}

.form-section h4 {
  font-size: 0.92rem;
  color: var(--primary-color);
  margin-bottom: 4px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
}

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

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

.input-with-unit .form-input {
  width: 100%;
  padding-right: 80px;
}

.unit-text {
  position: absolute;
  right: 10px;
  font-size: 0.75rem;
  color: var(--text-dim);
  pointer-events: none;
}

/* Semáforo Nutri-Score */
.nutriscore-banner {
  padding: 16px 20px;
  background: var(--bg-card-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nutriscore-badge-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

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

.nutriscore-scale {
  display: inline-flex;
  border-radius: 8px;
  overflow: hidden;
  background: #1e293b;
  padding: 3px;
  gap: 2px;
}

.ns-box {
  width: 32px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Oswald', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  opacity: 0.35;
  border-radius: 4px;
  transition: all 0.2s;
}

.ns-a { background: #038141; }
.ns-b { background: #85bb2f; }
.ns-c { background: #fecb02; color: #1e293b; }
.ns-d { background: #ee8100; }
.ns-e { background: #e63e11; }

.ns-box.active {
  opacity: 1;
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
  z-index: 2;
}

.nutriscore-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Escenario de la Etiqueta */
.label-stage-wrapper {
  padding: 24px;
  display: flex;
  justify-content: center;
  background: radial-gradient(var(--border-color) 1px, transparent 1px);
  background-size: 14px 14px;
  background-color: var(--bg-card);
}

.rendered-label-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  color: #0f172a;
  border-radius: 4px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  font-family: var(--font-main);
}

/* FORMATO UE */
.label-eu-box {
  width: 100%;
}

.label-eu-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.label-eu-header h4 {
  font-size: 1.1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #0f172a;
}

.label-sub-text {
  font-size: 0.78rem;
  color: #475569;
}

.nutrition-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  color: #0f172a;
}

.nutrition-table th, .nutrition-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #cbd5e1;
}

.nutrition-table thead th {
  border-bottom: 2px solid #0f172a;
  font-weight: 700;
  font-size: 0.8rem;
  background: #f8fafc;
}

.text-right {
  text-align: right;
}

.row-highlight td {
  background: #f1f5f9;
}

.row-sub td:first-child {
  padding-left: 16px;
  font-style: italic;
  color: #475569;
}

.label-eu-footer {
  margin-top: 10px;
  font-size: 0.7rem;
  color: #64748b;
  line-height: 1.35;
}

/* FORMATO FDA */
.label-fda-box {
  border: 2px solid #000000;
  padding: 10px;
  background: #ffffff;
  color: #000000;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.fda-header h2 {
  font-family: 'Impact', 'Arial Black', sans-serif;
  font-size: 2.2rem;
  line-height: 1;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.fda-servings-line {
  font-size: 0.85rem;
}

.fda-serving-size-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 2px 0 4px;
}

.fda-bar-thick {
  height: 10px;
  background: #000000;
  margin: 4px 0;
}

.fda-bar-medium {
  height: 5px;
  background: #000000;
  margin: 4px 0;
}

.fda-calories-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 4px 0;
}

.fda-cal-title {
  font-size: 1.5rem;
  font-weight: 900;
}

.fda-cal-number {
  font-family: 'Impact', 'Arial Black', sans-serif;
  font-size: 2.6rem;
  line-height: 0.9;
}

.fda-dv-header {
  text-align: right;
  font-size: 0.75rem;
  font-weight: 700;
  padding-bottom: 2px;
  border-bottom: 1px solid #000000;
}

.fda-nutrient-list {
  font-size: 0.82rem;
}

.fda-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid #e2e8f0;
}

.fda-row-sub {
  padding-left: 16px;
}

.fda-footer-note {
  font-size: 0.68rem;
  line-height: 1.3;
  margin-top: 6px;
  color: #333333;
}

/* FAQ & Sidebar & Modal standard */
.faq-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.faq-section h3 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  margin-bottom: 16px;
}

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card-header);
}

.faq-question {
  padding: 14px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
  user-select: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question svg {
  transition: transform 0.2s;
  color: var(--primary-color);
}

.faq-item[open] .faq-question svg {
  transform: rotate(180deg);
}

.faq-answer {
  padding: 0 16px 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.tool-sidebar {
  width: 300px;
}

.ad-sidebar-wrapper {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ad-sidebar-card {
  width: 300px;
  min-height: 600px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad-dev-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
  color: var(--text-dim);
}

.ad-size-badge {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

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

.modal-header {
  background: var(--bg-card-header);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

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

.modal-body {
  padding: 20px 18px;
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.5;
}

.modal-footer {
  padding: 12px 18px;
  background: var(--bg-card-header);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--primary-color);
  color: #ffffff;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
}

@media (max-width: 1024px) {
  .tool-with-sidebar {
    grid-template-columns: 1fr;
  }
  .tool-sidebar {
    width: 100%;
  }
  .ad-sidebar-card {
    width: 100%;
    min-height: 250px;
  }
  .nutrition-workspace {
    grid-template-columns: 1fr;
  }
}

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