/* ==========================================================================
   NutriEquivalentes — Modern Responsive Stylesheet
   ========================================================================== */

:root {
  /* Color Palette - Light Theme (Organic Botanical & Warm Linen) */
  --bg-primary: #f6f4ee;
  --bg-surface: #fdfcf9;
  --bg-surface-elevated: #ffffff;
  --bg-muted: #ede8df;
  --bg-hover: #e3ddd1;
  
  --text-main: #242c23;
  --text-muted: #5e695e;
  --text-light: #8c968c;
  --border-color: #ded8ce;
  --border-focus: #386641;

  /* Accent Colors (Herbal Matcha / Forest Pine) */
  --primary: #2d6a4f;
  --primary-hover: #1b4332;
  --primary-light: #e7f3ec;
  --primary-text: #1b4332;

  /* Category Specific Accents (Organic Earth & Harvest Tones) */
  --cat-frutas-bg: #fdf2e9;
  --cat-frutas-border: #f8c49d;
  --cat-frutas-text: #bc4726;

  --cat-verduras-bg: #edf7ed;
  --cat-verduras-border: #a3d9a5;
  --cat-verduras-text: #2d6a4f;

  --cat-leguminosas-bg: #f8ede4;
  --cat-leguminosas-border: #ddb892;
  --cat-leguminosas-text: #7f4f24;

  --cat-proteinas-bg: #fdf0ed;
  --cat-proteinas-border: #f3b2a2;
  --cat-proteinas-text: #a43625;

  --cat-grasas-bg: #f7f7e8;
  --cat-grasas-border: #d8d689;
  --cat-grasas-text: #706b1e;

  --cat-cereales-bg: #faf0e6;
  --cat-cereales-border: #e6ccb2;
  --cat-cereales-text: #9c6644;

  --cat-azucares-bg: #fbf2eb;
  --cat-azucares-border: #e8c2a8;
  --cat-azucares-text: #8d4925;

  --shadow-sm: 0 1px 3px 0 rgb(36 44 35 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(36 44 35 / 0.08), 0 2px 4px -2px rgb(36 44 35 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(36 44 35 / 0.09), 0 4px 6px -4px rgb(36 44 35 / 0.06);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  /* Color Palette - Dark Theme (Organic Peat, Moss & Forest Canopy) */
  --bg-primary: #121714;
  --bg-surface: #18201b;
  --bg-surface-elevated: #1e2822;
  --bg-muted: #243029;
  --bg-hover: #2e3d34;

  --text-main: #edeae2;
  --text-muted: #9cb0a1;
  --text-light: #697c6e;
  --border-color: #27372d;
  --border-focus: #52b788;

  --primary: #52b788;
  --primary-hover: #74c69d;
  --primary-light: #183827;
  --primary-text: #b7e4c7;

  --cat-frutas-bg: #2e1c14;
  --cat-frutas-border: #7a3922;
  --cat-frutas-text: #f4a261;

  --cat-verduras-bg: #14281b;
  --cat-verduras-border: #225838;
  --cat-verduras-text: #74c69d;

  --cat-leguminosas-bg: #291e17;
  --cat-leguminosas-border: #68452e;
  --cat-leguminosas-text: #d4a373;

  --cat-proteinas-bg: #2b1716;
  --cat-proteinas-border: #6e2824;
  --cat-proteinas-text: #f28482;

  --cat-grasas-bg: #242516;
  --cat-grasas-border: #575a28;
  --cat-grasas-text: #d4d775;

  --cat-cereales-bg: #281e16;
  --cat-cereales-border: #6d4a2a;
  --cat-cereales-text: #dda15e;

  --cat-azucares-bg: #2a1914;
  --cat-azucares-border: #6a3825;
  --cat-azucares-text: #e09f67;

  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.5);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.6);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.7);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

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

/* App Header */
.app-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  font-size: 2rem;
  background: var(--bg-muted);
  border-radius: var(--radius-md);
  padding: 0.25rem 0.5rem;
  box-shadow: var(--shadow-sm);
}

.brand-info h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-main);
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Main Container */
.main-container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
  flex: 1;
}


/* Controls & Filters Section */
.controls-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.search-box-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 1rem;
  font-size: 1.1rem;
  pointer-events: none;
  opacity: 0.6;
}

.search-box-wrapper input {
  width: 100%;
  padding: 0.85rem 2.75rem 0.85rem 2.85rem;
  font-size: 1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-color);
  background: var(--bg-muted);
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

.search-box-wrapper input:focus {
  border-color: var(--primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(45, 80, 52, 0.15);
}

.search-clear {
  position: absolute;
  right: 0.85rem;
  background: none;
  border: none;
  font-size: 1.35rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
}

/* Category Filter Pills */
.category-filters {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  scrollbar-width: thin;
}

.category-filters::-webkit-scrollbar {
  height: 4px;
}
.category-filters::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.filter-pill:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.filter-pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(45, 106, 79, 0.3);
}

.filter-pill.active .pill-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.pill-count {
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  background: var(--bg-muted);
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

/* Toolbar Options */
.toolbar-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.sort-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.form-select {
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

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

.view-switch {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.btn-icon {
  background: var(--bg-surface);
  border: none;
  padding: 0.45rem 0.65rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.btn-icon.active {
  background: var(--primary-light);
  color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

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

.btn-outline {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: var(--bg-hover);
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

/* Results Header */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.active-tags {
  display: flex;
  gap: 0.4rem;
}

/* Table View & Food Table Layout */
.table-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  margin-top: 0.5rem;
}

.food-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  font-size: 0.925rem;
}

.food-table thead th {
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1rem 1.15rem;
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

/* Group Header Rows in Table */
.table-group-header td {
  background: var(--bg-muted);
  padding: 0.85rem 1.15rem !important;
  border-top: 2px solid var(--border-color);
  border-bottom: 2px solid var(--border-color);
  cursor: pointer !important;
  user-select: none;
}

.table-group-header:hover td {
  background: var(--bg-hover) !important;
}

.group-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.group-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.group-chevron {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-block;
}

.table-group-header.collapsed .group-chevron {
  transform: rotate(-90deg);
}

.group-header-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.group-header-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.group-header-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.group-header-desc {
  font-size: 0.825rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Category Specific Accent Left Borders */
.group-frutas td {
  border-left: 5px solid var(--cat-frutas-text);
  background: var(--cat-frutas-bg);
}
.group-verduras td {
  border-left: 5px solid var(--cat-verduras-text);
  background: var(--cat-verduras-bg);
}
.group-leguminosas td {
  border-left: 5px solid var(--cat-leguminosas-text);
  background: var(--cat-leguminosas-bg);
}
.group-proteinas td {
  border-left: 5px solid var(--cat-proteinas-text);
  background: var(--cat-proteinas-bg);
}
.group-grasas_con_proteina td {
  border-left: 5px solid var(--cat-leguminosas-text);
  background: var(--cat-leguminosas-bg);
}
.group-grasas_sin_proteina td {
  border-left: 5px solid var(--cat-grasas-text);
  background: var(--cat-grasas-bg);
}
.group-cereales td {
  border-left: 5px solid var(--cat-cereales-text);
  background: var(--cat-cereales-bg);
}
.group-azucares td {
  border-left: 5px solid var(--cat-azucares-text);
  background: var(--cat-azucares-bg);
}

.food-table tbody tr {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.food-table tbody tr:nth-child(even) {
  background-color: var(--bg-muted);
}

.food-table tbody tr:hover {
  background-color: var(--bg-hover) !important;
}

.food-table tbody tr:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: -2px;
}

.food-table td {
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

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

/* Table Specific Columns */
.td-name {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 190px;
}

.table-food-icon {
  font-size: 1.4rem;
  line-height: 1;
}

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

.cat-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.text-subcat {
  font-size: 0.825rem;
  color: var(--text-muted);
}

.text-portion-highlight {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}

.text-weight {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* Category Colors */
.cat-frutas {
  background-color: var(--cat-frutas-bg);
  border: 1px solid var(--cat-frutas-border);
  color: var(--cat-frutas-text);
}

.cat-verduras {
  background-color: var(--cat-verduras-bg);
  border: 1px solid var(--cat-verduras-border);
  color: var(--cat-verduras-text);
}

.cat-leguminosas {
  background-color: var(--cat-leguminosas-bg);
  border: 1px solid var(--cat-leguminosas-border);
  color: var(--cat-leguminosas-text);
}

.cat-proteinas {
  background-color: var(--cat-proteinas-bg);
  border: 1px solid var(--cat-proteinas-border);
  color: var(--cat-proteinas-text);
}

.cat-grasas_con_proteina {
  background-color: var(--cat-leguminosas-bg);
  border: 1px solid var(--cat-leguminosas-border);
  color: var(--cat-leguminosas-text);
}

.cat-grasas_sin_proteina {
  background-color: var(--cat-grasas-bg);
  border: 1px solid var(--cat-grasas-border);
  color: var(--cat-grasas-text);
}

.cat-cereales {
  background-color: var(--cat-cereales-bg);
  border: 1px solid var(--cat-cereales-border);
  color: var(--cat-cereales-text);
}

.cat-azucares {
  background-color: var(--cat-azucares-bg);
  border: 1px solid var(--cat-azucares-border);
  color: var(--cat-azucares-text);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  background: var(--bg-surface);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  margin-top: 1.5rem;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.25rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Native Dialog & Modal System */
.native-dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 90vw;
  width: 620px;
  margin: auto;
  outline: none;
}

.native-dialog::backdrop {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
}

.dialog-content {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

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

.dialog-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.dialog-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-icon {
  font-size: 2.75rem;
  line-height: 1;
}

.modal-title-wrap h2 {
  font-size: 1.4rem;
  font-weight: 800;
}

.modal-portion-highlight {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.2rem;
}

/* Calculator Boxes */
.calc-box-inline {
  background: var(--bg-muted);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

.calc-box-inline h4 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.calc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.number-stepper {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.number-stepper button {
  background: var(--bg-muted);
  border: none;
  font-size: 1.1rem;
  font-weight: bold;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  color: var(--text-main);
  transition: background var(--transition);
}

.number-stepper button:hover {
  background: var(--bg-hover);
}

.number-stepper button:active {
  background: var(--border-color);
}

.number-stepper button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.number-stepper input {
  width: 60px;
  text-align: center;
  border: none;
  outline: none;
  font-weight: bold;
  font-size: 1rem;
  background: var(--bg-surface);
  color: var(--text-main);
}

.calc-result {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border-color);
  font-size: 0.95rem;
}

.substitutes-section h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.substitutes-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.substitutes-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

.substitute-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  cursor: pointer;
}

.substitute-item:last-child {
  border-bottom: none;
}

.substitute-item:hover {
  background: var(--bg-hover);
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

/* Modal Calculator Detailed */
.modal-calculator {
  width: 760px;
}

.calc-explainer {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.calc-converter-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1.25rem;
  background: var(--bg-muted);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.calc-column {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

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

.full-width {
  width: 100%;
}

.form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  outline: none;
}

.calc-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.calc-arrows {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--primary);
}

.calc-substitute-highlight {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--bg-surface);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--primary);
  min-height: 42px;
  display: flex;
  align-items: center;
}

.calc-food-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.calc-summary-banner {
  background: var(--primary-light);
  color: var(--primary-text);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* App Footer */
.app-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 1.75rem 1rem;
  margin-top: auto;
  text-align: center;
}

.footer-container {
  max-width: 1280px;
  margin: 0 auto;
}

.app-footer p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.footer-link {
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-decoration: none;
  transition: var(--transition);
  border-bottom: 1.5px solid transparent;
}

.footer-link:hover {
  color: var(--primary-hover);
  border-bottom-color: var(--primary-hover);
}

/* Media Queries & Responsive (Mobile Optimized) */
@media (max-width: 768px) {
  .main-container {
    padding: 1rem 0.85rem 3rem;
  }

  .header-container {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
  }

  .brand-info h1 {
    font-size: 1.15rem;
  }

  .header-actions {
    width: auto;
  }

  .controls-section {
    padding: 0.85rem;
    gap: 0.85rem;
    border-radius: var(--radius-md);
  }

  .search-box-wrapper input {
    padding: 0.75rem 2.25rem 0.75rem 2.5rem;
    font-size: 0.925rem;
  }


  .results-header {
    font-size: 0.825rem;
    margin-bottom: 0.75rem;
  }

  /* --- Mobile Table Adaptation (Clean List-Row Layout) --- */
  .table-wrapper {
    overflow-x: hidden;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
  }

  .food-table {
    display: block;
    width: 100%;
    border-collapse: collapse;
  }

  /* Ocultar encabezados de columna rígidos en móvil */
  .food-table thead {
    display: none;
  }

  .food-table tbody {
    display: block;
    width: 100%;
  }

  /* Encabezados de grupo nutricional en móvil */
  .food-table tbody tr.table-group-header {
    display: block;
    width: 100%;
  }

  .food-table tbody tr.table-group-header td {
    display: block;
    width: 100%;
    padding: 0.75rem 0.85rem !important;
    box-sizing: border-box;
  }

  .group-header-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .group-header-title {
    font-size: 0.95rem;
  }

  .group-header-desc {
    display: none; /* Se oculta la descripción larga en pantallas pequeñas */
  }

  /* Filas de alimentos en móvil (diseño de lista fluida y accesible) */
  .food-table tbody tr:not(.table-group-header) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--border-color);
    box-sizing: border-box;
    width: 100%;
  }

  .food-table tbody tr:not(.table-group-header) td {
    padding: 0;
    border: none;
  }

  /* Alimento (Icono + Nombre) */
  .td-name {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex: 1;
    min-width: 0;
    margin-right: 0.25rem;
  }

  .table-food-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
  }

  .food-title-cell {
    font-size: 0.9rem;
    font-weight: 700;
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
  }

  /* 2. Porción Equivalente */
  .food-table tbody tr:not(.table-group-header) td:nth-child(2) {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    text-align: right;
    flex-shrink: 0;
    max-width: 48%;
  }

  .text-portion-highlight {
    font-size: 0.875rem;
    line-height: 1.3;
    text-align: right;
  }

  /* 3. Peso/Gramos: se oculta en móvil para mantener la fila limpia y compacta */
  .food-table tbody tr:not(.table-group-header) td:nth-child(3) {
    display: none;
  }

  /* Dialogs / Modales en móvil */
  .native-dialog {
    max-width: 95vw;
    width: 100%;
  }

  .dialog-content {
    padding: 1.15rem;
    gap: 1rem;
  }

  .modal-hero {
    gap: 0.75rem;
  }

  .modal-icon {
    font-size: 2.25rem;
  }

  .modal-title-wrap h2 {
    font-size: 1.2rem;
  }

  .calc-converter-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    padding: 0.9rem;
  }

  .calc-divider {
    margin: 0.35rem 0;
  }
}

/* Print Styles */
@media print {
  .app-header, .controls-section, .dialog-footer, .header-actions, .btn-quick-calc {
    display: none !important;
  }
  
  body {
    background: #ffffff;
    color: #000000;
  }

  .cards-grid {
    display: none !important;
  }

  .table-wrapper {
    display: block !important;
    border: none;
    box-shadow: none;
  }

  .food-table th, .food-table td {
    border: 1px solid #ddd;
    color: #000;
  }
}
