/* ==========================================================================
   BeCareFood · Liquid Glass (iOS 27 style)
   Drop-in theme layer. Load AFTER the current app stylesheet.
   All classes are prefixed `lg-` so nothing existing breaks until it is
   migrated screen by screen.
   Brand (Miro "Marca"): green #2E9E5B, coral #FF7A45, water blue #2D9CDB,
   yellow #F2C94C, cream #FAF7F0, charcoal #1F2A2E. Poppins titles, Inter text.
   ========================================================================== */

:root {
  /* Brand */
  --lg-green: #2E9E5B;
  --lg-green-text: #1F7A45;      /* green for text on light surfaces (AA) */
  --lg-coral: #FF7A45;
  --lg-coral-text: #B5432A;      /* coral for text on light surfaces (AA) */
  --lg-blue: #2D9CDB;
  --lg-blue-text: #1B6F9E;
  --lg-yellow: #F2C94C;
  --lg-cream: #FAF7F0;
  --lg-ink: #1F2A2E;
  --lg-muted: #4A5550;
  --lg-leaf: #CFE6D3;

  /* Macro colors (brand rule: protein blue, carbs green, fat yellow, sugar coral) */
  --lg-protein: var(--lg-blue);
  --lg-carbs: var(--lg-green);
  --lg-fat: var(--lg-yellow);
  --lg-sugar: var(--lg-coral);

  /* Surfaces */
  --lg-bg: var(--lg-cream);
  --lg-glass-tint: rgba(255, 255, 255, .56);
  --lg-glass-tint-strong: rgba(255, 255, 255, .80);
  --lg-glass-border: rgba(255, 255, 255, .78);
  --lg-glass-hl-top: rgba(255, 255, 255, .95);
  --lg-glass-hl-bottom: rgba(255, 255, 255, .45);
  --lg-glass-shadow: 0 10px 30px rgba(31, 42, 46, .08);
  --lg-fill-soft: rgba(31, 42, 46, .05);
  --lg-fill-track: rgba(31, 42, 46, .08);
  --lg-divider: rgba(31, 42, 46, .07);
  --lg-blur: 24px;
  --lg-saturate: 180%;

  /* Ambient color behind the glass */
  --lg-amb-1: rgba(46, 158, 91, .30);
  --lg-amb-2: rgba(255, 122, 69, .22);
  --lg-amb-3: rgba(45, 156, 219, .20);

  /* Shape */
  --lg-r-card: 26px;
  --lg-r-tile: 20px;
  --lg-r-sheet: 34px;
  --lg-r-pill: 999px;

  /* Type */
  --lg-font-title: 'Poppins', system-ui, -apple-system, sans-serif;
  --lg-font-body: 'Inter', system-ui, -apple-system, sans-serif;

  /* Layout */
  --lg-gap: 12px;
  --lg-pad: 16px;
  --lg-tabbar-h: 64px;
  --lg-safe-bottom: env(safe-area-inset-bottom, 0px);
  --lg-safe-top: env(safe-area-inset-top, 0px);
}

/* Dark mode (the app already supports light/dark) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --lg-bg: #121816;
    --lg-ink: #EEF3EF;
    --lg-muted: #A9B5AF;
    --lg-green-text: #5FD08D;
    --lg-coral-text: #FF9C73;
    --lg-blue-text: #6CC0EE;
    --lg-glass-tint: rgba(30, 38, 35, .55);
    --lg-glass-tint-strong: rgba(30, 38, 35, .82);
    --lg-glass-border: rgba(255, 255, 255, .14);
    --lg-glass-hl-top: rgba(255, 255, 255, .22);
    --lg-glass-hl-bottom: rgba(255, 255, 255, .06);
    --lg-glass-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    --lg-fill-soft: rgba(255, 255, 255, .06);
    --lg-fill-track: rgba(255, 255, 255, .10);
    --lg-divider: rgba(255, 255, 255, .08);
    --lg-amb-1: rgba(46, 158, 91, .28);
    --lg-amb-2: rgba(255, 122, 69, .16);
    --lg-amb-3: rgba(45, 156, 219, .16);
  }
}
:root[data-theme="dark"] {
  --lg-bg: #121816;
  --lg-ink: #EEF3EF;
  --lg-muted: #A9B5AF;
  --lg-green-text: #5FD08D;
  --lg-coral-text: #FF9C73;
  --lg-blue-text: #6CC0EE;
  --lg-glass-tint: rgba(30, 38, 35, .55);
  --lg-glass-tint-strong: rgba(30, 38, 35, .82);
  --lg-glass-border: rgba(255, 255, 255, .14);
  --lg-glass-hl-top: rgba(255, 255, 255, .22);
  --lg-glass-hl-bottom: rgba(255, 255, 255, .06);
  --lg-glass-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --lg-fill-soft: rgba(255, 255, 255, .06);
  --lg-fill-track: rgba(255, 255, 255, .10);
  --lg-divider: rgba(255, 255, 255, .08);
  --lg-amb-1: rgba(46, 158, 91, .28);
  --lg-amb-2: rgba(255, 122, 69, .16);
  --lg-amb-3: rgba(45, 156, 219, .16);
}

/* ---------- App shell ---------- */
.lg-app, .lg-app *, .lg-app *::before, .lg-app *::after { box-sizing: border-box; }
.lg-app {
  position: relative;
  min-height: 100dvh;
  background: var(--lg-bg);
  color: var(--lg-ink);
  font-family: var(--lg-font-body);
  -webkit-font-smoothing: antialiased;
  isolation: isolate;
  overflow-x: hidden;
}
/* Soft color behind the glass. One fixed layer, cheap to render. */
.lg-app::before {
  content: "";
  position: fixed;
  inset: -10vh -10vw;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40vmax 40vmax at 5% 5%, var(--lg-amb-1), transparent 70%),
    radial-gradient(34vmax 34vmax at 95% 35%, var(--lg-amb-2), transparent 70%),
    radial-gradient(38vmax 38vmax at 10% 85%, var(--lg-amb-3), transparent 70%);
}
.lg-screen {
  display: flex;
  flex-direction: column;
  gap: var(--lg-gap);
  padding: calc(var(--lg-safe-top) + 12px) var(--lg-pad)
           calc(var(--lg-tabbar-h) + var(--lg-safe-bottom) + 40px);
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- Glass material ---------- */
.lg-glass {
  background: var(--lg-glass-tint);
  -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-saturate));
  backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-saturate));
  border: 1px solid var(--lg-glass-border);
  /* iOS 27: subtle static highlights on top and bottom edges only */
  box-shadow:
    inset 0 1px 0 var(--lg-glass-hl-top),
    inset 0 -1px 0 var(--lg-glass-hl-bottom),
    var(--lg-glass-shadow);
}
.lg-glass--strong { background: var(--lg-glass-tint-strong); }
.lg-glass--dark {
  background: rgba(24, 30, 28, .40);
  border-color: rgba(255, 255, 255, .22);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 10px 30px rgba(0, 0, 0, .25);
}
.lg-glass--green {
  background: rgba(46, 158, 91, .92);
  border: 1px solid rgba(255, 255, 255, .45);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .5),
    inset 0 -1px 0 rgba(255, 255, 255, .2),
    0 10px 24px rgba(46, 158, 91, .32);
}

/* No backdrop-filter support, or user asked for less transparency:
   fall back to solid surfaces (also covers iOS "Reduce Transparency"). */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .lg-glass { background: var(--lg-glass-tint-strong); }
}
@media (prefers-reduced-transparency: reduce) {
  .lg-glass, .lg-glass--strong {
    background: var(--lg-bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .lg-app::before { display: none; }
}

/* ---------- Typography ---------- */
.lg-title { font-family: var(--lg-font-title); font-weight: 700; font-size: 26px; letter-spacing: -.4px; line-height: 1.15; margin: 0; }
.lg-h2    { font-family: var(--lg-font-title); font-weight: 600; font-size: 17px; margin: 0; }
.lg-num   { font-family: var(--lg-font-title); font-weight: 700; font-variant-numeric: tabular-nums; }
.lg-muted { color: var(--lg-muted); font-size: 13px; font-weight: 500; }
.lg-label { color: var(--lg-muted); font-size: 12px; font-weight: 600; }
.lg-eyebrow { color: var(--lg-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }

/* ---------- Layout helpers ---------- */
.lg-row { display: flex; align-items: center; gap: 10px; }
.lg-row--between { justify-content: space-between; }
.lg-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.lg-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }

/* ---------- Card ---------- */
.lg-card { border-radius: var(--lg-r-card); padding: 14px 16px; }
.lg-list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--lg-divider);
}
.lg-list-row:last-child { border-bottom: 0; }

/* ---------- Header (logo + name + ES/EN) ---------- */
.lg-header {
  position: sticky;
  top: calc(var(--lg-safe-top) + 8px);
  z-index: 20;
  height: 54px;
  border-radius: var(--lg-r-pill);
  padding: 0 7px 0 9px;
  display: flex; align-items: center; justify-content: space-between;
}
.lg-brand { display: flex; align-items: center; gap: 8px; }
.lg-brand__logo { width: 34px; height: 34px; flex-shrink: 0; }
.lg-wordmark { font-family: var(--lg-font-title); font-weight: 700; font-size: 19px; letter-spacing: -.4px; }
.lg-wordmark .care { color: var(--lg-green); }
.lg-wordmark .food { color: var(--lg-coral); }

/* ---------- Segmented control (ES/EN, Día/Semana/Mes, Poco/Normal/Mucho) ---------- */
.lg-segmented {
  display: flex; gap: 2px; padding: 4px;
  border-radius: var(--lg-r-pill);
}
.lg-segmented--inset { background: var(--lg-fill-soft); padding: 3px; }
.lg-segmented > button {
  flex: 1; min-height: 36px; border: 0; background: transparent;
  border-radius: var(--lg-r-pill); padding: 0 12px;
  font: 600 13px/1 var(--lg-font-body); color: var(--lg-ink); cursor: pointer;
}
.lg-segmented > button[aria-pressed="true"],
.lg-segmented > button.is-active {
  background: #fff; color: #1F2A2E;
  box-shadow: 0 2px 8px rgba(31, 42, 46, .12);
}

/* ---------- Buttons ---------- */
.lg-btn {
  min-height: 52px; border-radius: var(--lg-r-pill); padding: 0 20px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 16px/1 var(--lg-font-body); cursor: pointer; text-decoration: none;
  border: 0; color: var(--lg-ink);
  transition: transform .12s ease, filter .12s ease;
}
.lg-btn:active { transform: scale(.97); }
.lg-btn--block { width: 100%; }
.lg-btn.lg-glass--green, .lg-fab.lg-glass--green { color: #fff; }
.lg-btn--sm { min-height: 36px; font-size: 13px; padding: 0 12px; }
/* Use with .lg-glass--green for primary, .lg-glass for secondary */

/* ---------- Chips / tags ---------- */
.lg-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.lg-chip {
  min-height: 34px; border-radius: var(--lg-r-pill); padding: 0 12px;
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 13px/1 var(--lg-font-body); color: var(--lg-ink); cursor: pointer;
}
.lg-chip[aria-pressed="true"], .lg-chip.is-on { background: var(--lg-green); color: #fff; border-color: transparent; }
.lg-tag {
  display: inline-flex; align-items: center; border-radius: var(--lg-r-pill);
  padding: 3px 8px; font: 700 11px/1.3 var(--lg-font-body);
  color: var(--lg-green-text); background: rgba(46, 158, 91, .13);
}
.lg-tag--coral { color: var(--lg-coral-text); background: rgba(255, 122, 69, .15); }
.lg-tag--blue  { color: var(--lg-blue-text);  background: rgba(45, 156, 219, .14); }

/* ---------- Progress bars & rings ---------- */
.lg-bar { height: 8px; border-radius: 99px; background: var(--lg-fill-track); overflow: hidden; }
.lg-bar > span { display: block; height: 100%; border-radius: 99px; background: var(--lg-green); width: var(--v, 0%); transition: width .5s ease; }
.lg-bar--protein > span { background: var(--lg-protein); }
.lg-bar--carbs   > span { background: var(--lg-carbs); }
.lg-bar--fat     > span { background: var(--lg-fat); }
.lg-bar--sugar   > span { background: var(--lg-sugar); }
.lg-bar--water   > span { background: var(--lg-blue); }
.lg-ring__track { stroke: var(--lg-fill-track); }
.lg-ring__value { stroke: var(--lg-green); stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.lg-ring__value--water { stroke: var(--lg-blue); }

/* ---------- Macro tiles (Prot / Carb / Grasas / Azúcar) ---------- */
.lg-macros { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.lg-macros > div { border-radius: 14px; background: var(--lg-fill-soft); padding: 7px 4px; text-align: center; }
.lg-macros b { display: block; font: 700 15px/1.2 var(--lg-font-title); }
.lg-macros span { font-size: 10px; font-weight: 600; color: var(--lg-muted); }

/* ---------- Portion multiplier (½× 1× 1½× 2× Quitar) ---------- */
.lg-mult { display: flex; gap: 6px; margin-top: 8px; }
.lg-mult > button {
  flex: 1; min-height: 32px; border: 0; border-radius: var(--lg-r-pill);
  background: var(--lg-fill-soft); color: var(--lg-ink);
  font: 700 12px/1 var(--lg-font-body); cursor: pointer;
}
.lg-mult > button[aria-pressed="true"] { background: var(--lg-green); color: #fff; }
.lg-mult > .lg-mult__remove { color: var(--lg-coral-text); }

/* ---------- Alerts (allergy, health) ---------- */
.lg-alert {
  border-radius: var(--lg-r-card); padding: 14px 16px;
  display: flex; gap: 12px; align-items: flex-start;
  background: rgba(255, 122, 69, .16); border: 1px solid rgba(255, 122, 69, .35);
  color: #8E3420;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lg-alert { color: #FFC2A8; background: rgba(255, 122, 69, .14); } }
:root[data-theme="dark"] .lg-alert { color: #FFC2A8; background: rgba(255, 122, 69, .14); }

/* ---------- Floating tab bar + camera button ---------- */
.lg-tabbar[hidden]{display:none!important}
.lg-tabbar {
  position: fixed; z-index: 30;
  left: 14px; right: 14px;
  bottom: calc(var(--lg-safe-bottom) + 14px);
  max-width: 532px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  transition: transform .25s ease;
}
.lg-tabbar__nav {
  flex: 1; height: var(--lg-tabbar-h); border-radius: var(--lg-r-pill);
  display: flex; align-items: center; justify-content: space-around;
}
.lg-tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 56px; min-height: 48px; justify-content: center;
  padding: 6px 12px; border-radius: var(--lg-r-pill);
  font: 700 10px/1 var(--lg-font-body); color: var(--lg-muted); text-decoration: none;
  transition: background .2s ease, color .2s ease;
}
.lg-tab svg { width: 22px; height: 22px; }
.lg-tab[aria-current="page"], .lg-tab.is-active { background: rgba(46, 158, 91, .14); color: var(--lg-green-text); }
.lg-fab {
  width: var(--lg-tabbar-h); height: var(--lg-tabbar-h); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  cursor: pointer; border: 0;
}
.lg-fab svg { width: 28px; height: 28px; }
/* Compact on scroll down (iOS behaviour), set by liquid-glass.js */
.lg-tabbar.is-compact .lg-tab { font-size: 0; gap: 0; }
.lg-tabbar.is-compact .lg-tabbar__nav { height: 52px; }
.lg-tabbar.is-compact .lg-fab { width: 52px; height: 52px; }

/* ---------- Bottom sheet / modal screens ---------- */
.lg-sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(31, 42, 46, .28); }
.lg-sheet {
  position: fixed; z-index: 41; left: 10px; right: 10px;
  bottom: calc(var(--lg-safe-bottom) + 10px);
  max-width: 540px; margin: 0 auto;
  border-radius: var(--lg-r-sheet); padding: 22px 18px 18px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: 88dvh; overflow-y: auto;
}
.lg-sheet::before {
  content: ""; width: 40px; height: 5px; border-radius: 99px;
  background: rgba(31, 42, 46, .22); align-self: center; margin-top: -10px; margin-bottom: 4px;
}
.lg-sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
/* Sticky total at the bottom of result screens */
.lg-total { position: sticky; bottom: calc(var(--lg-safe-bottom) + 10px); border-radius: 30px; padding: 14px 16px; }

/* ---------- Calendar (monthly report, cycle) ---------- */
.lg-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.lg-cal__dow { text-align: center; font-size: 12px; font-weight: 600; color: var(--lg-muted); }
.lg-cal__day {
  height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font: 700 13px/1 var(--lg-font-body); background: var(--lg-fill-soft);
}
.lg-cal__day.is-ok    { background: var(--lg-green); color: #fff; }
.lg-cal__day.is-over  { background: var(--lg-coral); color: #1F2A2E; }
.lg-cal__day.is-today { outline: 2px solid var(--lg-ink); outline-offset: -2px; }

/* ---------- Focus & motion ---------- */
.lg-app :focus-visible { outline: 3px solid var(--lg-blue); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .lg-app *, .lg-app *::before { transition: none !important; animation: none !important; }
}
