/* ====== SISTEMA DE DISEÑO MODERNO - BONFANTE APP ====== */
/* Design System generado con UI/UX Pro Max Skill */

/* ====== VARIABLES CSS ====== */
:root {
  /* Colores principales — paleta Bonfante */
  --primary-color: #42302E;
  --primary-dark: #231F20;
  --primary-light: #EEE9E5;
  --primary-lighter: #FFFAF4;
  
  /* Colores secundarios */
  --secondary-color: #B7CACF;
  --secondary-light: #D3E3E7;
  
  /* Acento azul (CTA) */
  --accent-color: #2B66B1;
  --accent-light: #E8F1FA;
  
  /* Colores de estado */
  --success-color: #27AE60;
  --success-light: #E8F8F0;
  --warning-color: #F39C12;
  --warning-light: #FFF8E1;
  --danger-color: #E74C3C;
  --danger-light: #FDEDEC;
  --info-color: #2980B9;
  --info-light: #EBF5FB;
  
  /* Colores neutros — contraste mejorado WCAG AA+ */
  --background: #FFFAF4;
  --surface: #ffffff;
  --surface-variant: #F1F3F5;
  --text-primary: #231F20;
  --text-secondary: #495057;
  --text-disabled: #ADB5BD;
  --border-color: #DEE2E6;
  --border-light: #F1F3F5;
  
  /* Sombras — Soft UI Evolution: más suaves y con profundidad */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 2px 4px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 8px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 16px rgba(0,0,0,0.06), 0 16px 32px rgba(0,0,0,0.1);
  --shadow-hover: 0 4px 8px rgba(0,0,0,0.06), 0 12px 24px rgba(0,0,0,0.1);
  
  /* Bordes redondeados — modernos, 10-12px base */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Espaciado */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  
  /* Tipografía de marca */
  --font-family: "Cavren Sans", system-ui, sans-serif;
  --font-heading: "Cavren Sans", system-ui, sans-serif;
  --font-brand: "Sofian Monika", Georgia, serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-4xl: 2.5rem;
  
  /* Transiciones — estandarizadas a 200-250ms per UX guidelines */
  --transition-fast: 0.15s ease-out;
  --transition: 0.25s ease-out;
  --transition-slow: 0.4s ease-out;
  
  /* Z-index — escala clara */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal: 1040;
  --z-popover: 1050;
  --z-tooltip: 1060;
}

/* ====== TEMA OSCURO ====== */
html[data-theme="dark"] {
  --background: #0F1117;
  --surface: #1A1D27;
  --surface-variant: #252836;
  --text-primary: #E8ECF1;
  --text-secondary: #9CA3AF;
  --text-disabled: #6B7280;
  --border-color: #374151;
  --border-light: #2D3340;
  --primary-color: #42302E;
  --primary-dark: #231F20;
  --primary-light: #EEE9E5;
  --primary-lighter: #FFFAF4;
  --secondary-color: #B7CACF;
  --secondary-light: #D3E3E7;
  --accent-color: #2B66B1;
  --accent-light: #E8F1FA;
  --success-color: #34D399;
  --success-light: rgba(52, 211, 153, 0.15);
  --warning-color: #FBBF24;
  --warning-light: rgba(251, 191, 36, 0.15);
  --danger-color: #F87171;
  --danger-light: rgba(248, 113, 113, 0.15);
  --info-color: #60A5FA;
  --info-light: rgba(96, 165, 250, 0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow: 0 2px 8px rgba(0,0,0,0.45);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.45);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.5);
}

html[data-theme="dark"] body { background: var(--background); color: var(--text-primary); }

/* data-force-light: admin abre siempre en claro (JS lo aplica en initTheme),
   pero el usuario puede togglear libremente durante la sesión. Sin override CSS. */

/* Botón toggle tema */
.theme-toggle {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--primary-color);
  background: transparent;
  color: var(--primary-color);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--font-size-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-sizing: border-box;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.theme-toggle:hover { background: var(--primary-light); }

/* Header nav: área principal + acciones a la derecha */
.header-nav-area {
  flex: 1 1 480px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-xs) var(--space-sm);
  min-width: 0;
  overflow: visible;
}

/* Nav actions: grupo 2×2 (fila superior: Admin/usuario/tema — fila inferior: botones sesión) */
.nav-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}
.nav-actions-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.nav-actions .nav-link { font-size: var(--font-size-sm); white-space: nowrap; }
.nav-actions .nav-link.nav-logout { color: var(--danger-color); }

/* Display del usuario actual */
.nav-user-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  white-space: nowrap;
  cursor: default;
}

/* Botones de acción en nav (Cambiar usuario / Cerrar sesión) */
.nav-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
}
.nav-action-btn.nav-switch-user {
  color: var(--primary-color);
  border-color: var(--primary-color);
  background: transparent;
}
.nav-action-btn.nav-switch-user:hover {
  background: var(--primary-color);
  color: #fff;
}
.nav-action-btn.nav-logout-btn {
  color: var(--danger-color);
  border-color: var(--danger-color);
  background: transparent;
}
.nav-action-btn.nav-logout-btn:hover {
  background: var(--danger-color);
  color: #fff;
}

@media (max-width: 900px) {
  .header-nav-area { flex-direction: column; align-items: stretch; }
  .nav-actions { margin-left: 0; align-items: flex-start; }
  .nav-actions-row { flex-wrap: wrap; }
  .nav-action-btn { font-size: 0.75rem; padding: 5px 8px; }
  .nav-user-display { font-size: 0.75rem; }
  .main-header .header-content {
    max-height: none !important;
    min-height: auto !important;
  }
}

/* ====== RESET Y BASE ====== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ====== TIPOGRAFÍA ====== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: var(--space-md);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--font-size-3xl); font-weight: 700; }
h2 { font-size: var(--font-size-2xl); font-weight: 600; }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

p {
  margin-bottom: var(--space-md);
  line-height: 1.65;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-dark);
}

/* ====== ACCESIBILIDAD ====== */
:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ====== LAYOUT ====== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.container-fluid {
  width: 100%;
  padding: 0 var(--space-md);
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 calc(var(--space-sm) * -1);
}

.col {
  flex: 1;
  padding: 0 var(--space-sm);
}

.col-auto {
  flex: 0 0 auto;
  padding: 0 var(--space-sm);
}

/* ====== HEADER ====== */
.main-header {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  transition: transform 0.25s ease-out;
}

html[data-theme="dark"] .main-header {
  background: rgba(26, 29, 39, 0.92);
  border-bottom-color: var(--border-color);
}

.main-header.header-scroll-hidden {
  transform: translateY(-100%);
}

/* Cada template redefine .container con su propio ancho y padding, y el header usa
   esa misma clase. Se fijan aquí ancho, centrado y padding para que el header se vea
   idéntico en todas las páginas sin importar los overrides locales. */
.main-header .container {
  max-width: 1400px !important;
  width: 100% !important;
  margin: 0 auto !important;
  padding: 0 var(--space-lg) !important;
}

/* !important garantiza que este padding aplica en todos los templates
   sin importar overrides locales, asegurando altura uniforme del header */
.main-header .header-content {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: var(--space-sm) var(--space-md) !important;
  padding: var(--space-md) 0 !important;
  min-height: 120px !important;
  max-height: none !important;
  overflow: visible !important;
}

/* Compatibilidad: selector sin prefijo por si algún template lo usa fuera del header */
.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
  min-height: 70px;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.logo {
  height: 64px;
  width: auto;
  border-radius: var(--radius);
}

.main-header .logo {
  height: 64px;
}

.main-header .logo-header-alt {
  height: 88px;
  width: auto;
  max-width: min(320px, 42vw);
  border-radius: 0;
  object-fit: contain;
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 0;
  line-height: 1.2;
}

.brand-text span {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.main-nav {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  row-gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  border: 1px solid transparent;
  box-sizing: border-box;
  background-color: transparent;
  transition: none;
  transform: none;
  position: relative;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-link:hover:not(.active) {
  color: var(--primary-color);
}

.nav-link.active,
.nav-link.active:hover {
  color: var(--primary-color);
  font-weight: 500;
  background-color: var(--primary-lighter);
  border-radius: var(--radius);
  transform: none;
}

.nav-link i {
  font-size: var(--font-size-sm);
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: auto;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.nav-toggle:hover,
.nav-toggle:focus-visible {
  color: var(--primary-color);
  border-color: var(--primary-color);
}

/* ====== PAGE HEADER (usado en admin y algunos templates de inventario) ====== */
.page-header {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary-color);
}

.page-header h1 {
  font-family: var(--font-brand);
  color: var(--primary-color);
  font-size: var(--font-size-3xl);
  font-weight: 400;
  margin: var(--space-xs) 0 0 0;
  line-height: 1.2;
}

.page-header .breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.page-header .breadcrumb a {
  color: var(--primary-color);
  text-decoration: none;
}

.page-header .breadcrumb a:hover {
  text-decoration: underline;
}

/* ====== BOTONES ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-color);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: #245899;
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-warning {
  background: var(--warning-color);
  color: white;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-xs);
}

.btn-lg {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-lg);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
}

/* ====== CARDS ====== */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  background: transparent;
}

.card-body {
  padding: var(--space-lg);
}

.card-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border-light);
  background: var(--surface-variant);
}

.metric-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow);
  transition: all var(--transition);
  border-left: 4px solid var(--primary-color);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
}

.metric-card:hover {
  box-shadow: var(--shadow-hover);
}

.card-icon {
  width: 48px;
  height: 48px;
  background: var(--primary-light);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--primary-color);
  margin-bottom: var(--space-md);
}

.metric-value {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: var(--space-sm);
  line-height: 1;
}

.metric-change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.metric-change.positive {
  background: var(--success-light);
  color: var(--success-color);
}

.metric-change.negative {
  background: var(--danger-light);
  color: var(--danger-color);
}

.metric-change.neutral {
  background: var(--surface-variant);
  color: var(--text-secondary);
}

/* ====== GRID SYSTEM ====== */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.grid-auto-fit {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-auto-fill {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ====== TABLAS ====== */
.table-container {
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: var(--surface);
}

.table-wrapper {
  overflow-x: auto;
}

.modern-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.modern-table th {
  background: var(--surface-variant);
  padding: var(--space-md);
  text-align: left;
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Ordenación global de tablas */
th.th-sortable,
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.th-sortable:hover,
th.sortable:hover {
  color: var(--primary-color);
}

th.th-sortable .sort-icon,
th.sortable .sort-icon {
  margin-left: 6px;
  opacity: 0.4;
  font-size: 0.85em;
}

th.th-sortable.sort-asc .sort-icon,
th.th-sortable.sort-desc .sort-icon,
th.sortable.asc .sort-icon,
th.sortable.desc .sort-icon,
th.sortable.sort-asc .sort-icon,
th.sortable.sort-desc .sort-icon {
  opacity: 1;
  color: var(--primary-color);
}

.modern-table td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  transition: background-color var(--transition-fast);
}

.modern-table tbody tr:hover {
  background: var(--background);
}

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

/* ====== FORMULARIOS ====== */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 500;
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: var(--font-size-base);
  transition: all var(--transition-fast);
  background: var(--surface);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}

.form-control:invalid {
  border-color: var(--danger-color);
}

.form-control:disabled {
  background: var(--surface-variant);
  color: var(--text-disabled);
  cursor: not-allowed;
}

.form-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right var(--space-sm) center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: var(--space-2xl);
}

/* ====== BADGES Y ETIQUETAS ====== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary-color);
}

.badge-success {
  background: var(--success-light);
  color: var(--success-color);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning-color);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger-color);
}

.badge-secondary {
  background: var(--surface-variant);
  color: var(--text-secondary);
}

/* ====== INDICADORES ====== */
.profit-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: var(--font-size-sm);
}

.profit-indicator.high {
  background: var(--success-light);
  color: var(--success-color);
}

.profit-indicator.medium {
  background: var(--warning-light);
  color: var(--warning-color);
}

.profit-indicator.low {
  background: var(--danger-light);
  color: var(--danger-color);
}

/* ====== SECCIONES ====== */
.section {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-light);
}

.section-title {
  font-family: var(--font-heading);
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0;
}

/* ====== LISTAS ====== */
.recipes-list {
  display: grid;
  gap: var(--space-sm);
}

.recipe-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--background);
  border-radius: var(--radius);
  transition: all var(--transition);
  border: 1px solid transparent;
}

.recipe-item:hover {
  background: var(--surface);
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
  transform: translateX(4px);
}

.recipe-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.recipe-name {
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
}

.recipe-actions {
  display: flex;
  gap: var(--space-sm);
}

.action-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius);
  background: var(--background);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn:hover {
  background: var(--primary-color);
  color: white;
  box-shadow: var(--shadow-sm);
}

/* ====== ESTADOS VACÍOS ====== */
.empty-state {
  text-align: center;
  padding: var(--space-3xl);
  color: var(--text-secondary);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  color: var(--text-disabled);
}

.empty-state h3 {
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.empty-state p {
  margin-bottom: var(--space-lg);
}

/* ====== ANIMACIONES ====== */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.animate-slide-in {
  animation: slideInUp 0.3s ease-out;
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-slide-left {
  animation: slideInLeft 0.3s ease-out;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* ====== LOADING ====== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
}

.loading-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

/* ====== UTILIDADES ====== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--primary-color); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-danger { color: var(--danger-color); }

.bg-primary { background-color: var(--primary-color); }
.bg-secondary { background-color: var(--secondary-color); }
.bg-success { background-color: var(--success-color); }
.bg-warning { background-color: var(--warning-color); }
.bg-danger { background-color: var(--danger-color); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-normal { font-weight: 400; }

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }

.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.ml-0 { margin-left: 0; }
.mr-0 { margin-right: 0; }

.p-0 { padding: 0; }
.pt-0 { padding-top: 0; }
.pb-0 { padding-bottom: 0; }
.pl-0 { padding-left: 0; }
.pr-0 { padding-right: 0; }

.hidden { display: none; }
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.grid { display: grid; }

.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }

.justify-center { justify-content: center; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }

.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

.rounded { border-radius: var(--radius); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }

.shadow { box-shadow: var(--shadow); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* ====== RESPONSIVE ====== */
@media (max-width: 1400px) {
  .container {
    max-width: 1200px;
  }
}

@media (max-width: 1200px) {
  .container {
    max-width: 960px;
  }
}

@media (max-width: 992px) {
  .container {
    max-width: 720px;
  }
  
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .container {
    max-width: 540px;
  }

  .main-header .container {
    padding: 0 var(--space-md) !important;
  }

  .header-content {
    flex-direction: column;
    gap: var(--space-md);
    text-align: center;
  }
  
  .main-nav {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .grid-cols-4,
  .grid-cols-3,
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }
  
  .modern-table {
    font-size: var(--font-size-sm);
  }
  
  .modern-table th,
  .modern-table td {
    padding: var(--space-sm);
  }
  
  .metric-value {
    font-size: var(--font-size-2xl);
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }

  .main-header .btn,
  .nav-toggle {
    width: auto;
  }
  
  .btn + .btn {
    margin-top: var(--space-sm);
  }
}

@media (max-width: 576px) {
  .container {
    padding: 0 var(--space-sm);
  }
  
  .section {
    padding: var(--space-md);
  }
  
  .card-body {
    padding: var(--space-md);
  }
  
  .metric-card {
    padding: var(--space-md);
  }
  
  .brand-text h1 {
    font-size: var(--font-size-lg);
  }
  
  .section-title {
    font-size: var(--font-size-lg);
  }
}

/* Header compacto en celular (vertical y horizontal): barra corta + menú */
@media (max-width: 960px), (max-height: 540px) {
  .nav-toggle {
    display: inline-flex;
  }

  .main-header .header-content {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    min-height: 56px !important;
    max-height: none !important;
    padding: 6px 0 !important;
    gap: 8px !important;
    align-items: center !important;
    text-align: left !important;
  }

  .main-header .logo-section {
    min-width: 0;
    flex: 1 1 auto;
  }

  .main-header .logo {
    height: 48px;
  }

  .main-header .logo-header-alt {
    height: 56px;
    max-width: min(200px, 55vw);
  }

  .main-header .brand-text h1 {
    font-size: 1.05rem;
  }

  .main-header .brand-text span {
    display: none;
  }

  .main-header .header-nav-area {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    flex-basis: 100%;
    max-height: calc(100dvh - 56px);
    overflow-y: auto;
    padding: 8px 0 12px;
    gap: 10px;
  }

  .main-header.nav-open .header-content {
    flex-wrap: wrap !important;
  }

  .main-header.nav-open .header-nav-area {
    display: flex;
  }

  .main-header .main-nav {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap !important;
    gap: 4px !important;
  }

  .main-header .main-nav .nav-link,
  .main-header .nav-actions .nav-link {
    min-height: 44px;
    justify-content: flex-start;
    white-space: normal;
  }

  .main-header .nav-actions {
    margin-left: 0;
    width: 100%;
  }

  .main-header .nav-actions-row {
    flex-wrap: wrap;
  }
}

body.header-nav-open {
  overflow: hidden;
}

/* ====== PRINT STYLES ====== */
@media print {
  .main-header,
  .btn,
  .action-btn,
  .nav-link {
    display: none !important;
  }
  
  .section {
    box-shadow: none;
    border: 1px solid var(--border-color);
    break-inside: avoid;
  }
  
  .metric-card {
    break-inside: avoid;
  }
  
  body {
    background: white;
    color: black;
  }
}

/* ====== BÚSQUEDA CON AUTOCOMPLETADO ====== */
.search-container {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto var(--space-lg);
}

.search-input {
  width: 100%;
  padding: var(--space-md);
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-size: var(--font-size-base);
  background: var(--surface);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}

.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
}

.search-suggestion {
  padding: var(--space-lg);
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
}

.search-suggestion:hover {
  background: var(--primary-lighter);
  transform: translateX(2px);
}

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

.suggestion-content {
  flex: 1;
  min-width: 0;
}

.suggestion-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--font-size-base);
  margin-bottom: var(--space-sm);
  line-height: 1.3;
}

.suggestion-stats {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-sm);
}

.stat-label {
  color: var(--text-secondary);
  font-weight: 500;
  min-width: 60px;
}

.stat-value {
  font-weight: 600;
  font-family: 'Courier New', monospace;
}

.stat-value.cost {
  color: var(--text-primary);
}

.stat-value.price {
  color: var(--info-color);
}

.suggestion-profit {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 80px;
  padding: var(--space-sm);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

.profit-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profit-value {
  font-weight: 700;
  font-size: var(--font-size-base);
  font-family: 'Courier New', monospace;
}

.profit-value.positive {
  color: var(--success-color);
}

.profit-value.negative {
  color: var(--danger-color);
}

.profit-value.neutral {
  color: var(--text-secondary);
}

.search-no-results {
  padding: var(--space-lg);
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
}

/* El tema se controla exclusivamente via data-theme="dark"|"light" (JS).
   El script anticipado en <head> lo aplica antes del render → sin flash.
   El default es siempre claro (light). */
