/* ============================================
   BRIGHTLY - Design system & basis-styling
   Mobile-first. Geïnspireerd op Yazio.
   ============================================ */

:root {
  /* Brightly merkpalet */
  --green: #2FA45F;        /* Fris Groen — primair */
  --green-dark: #1E5C3A;   /* Diep Bos — titels */
  --green-light: #EBF6EF;  /* lichte mint — chips/hover/focus */
  --orange: #FF8A2D;       /* Zonsopgang — calorie-ring/accent */
  --carb: #FFC23D;         /* Goudgeel — koolhydraten */
  --protein: #2FA45F;      /* Fris Groen — eiwit */
  --fat: #FF8A2D;          /* Zonsopgang — vet */

  --bg: #FBFAF6;           /* zachte crème-achtergrond (mockup) */
  --surface: #ffffff;      /* witte kaarten */
  --ink: #2C2A26;          /* Inkt */
  --ink-soft: #5C594F;     /* warm grijs */
  --ink-faint: #A29D8F;    /* zacht warm grijs */
  --line: #EDE7DB;         /* warme hairline */
  --danger: #dc2626;

  /* Vorm */
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(44, 42, 38, .07), 0 1px 2px rgba(44, 42, 38, .04);
  --shadow-lg: 0 10px 30px rgba(44, 42, 38, .12);

  /* Maat */
  --maxw: 540px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--green); text-decoration: none; }

/* ---------- App shell ---------- */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100%;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.appbar h1 { font-size: 1.15rem; font-weight: 700; }
.appbar .sub { font-size: .8rem; color: var(--ink-faint); }

/* Datumnavigatie (dashboard) */
.appbar-date { justify-content: space-between; }
.nav-day {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 50%;
  font-size: 1.4rem; line-height: 1;
  color: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, opacity .15s;
}
.nav-day:hover { background: var(--bg); }
.nav-day:active { transform: scale(.95); }
.nav-day:disabled { opacity: .35; cursor: default; }
.day-center {
  flex: 1; border: none; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.day-center .day-title { font-size: 1.1rem; font-weight: 700; color: var(--ink); }
.day-center .sub { font-size: .78rem; color: var(--ink-faint); }

.page { padding: 16px; }

/* ---------- Kaart ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); margin-bottom: 10px; }

/* ---------- Knoppen ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--green);
  color: #fff;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn:hover { background: var(--green-dark); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--green); }
.btn-ghost:hover { background: var(--green-light); }
.btn-sm { width: auto; padding: 9px 14px; font-size: .9rem; }

/* ---------- Formulieren ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%;
  padding: 13px 14px;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-light); }
.input::placeholder { color: var(--ink-faint); }

.hint { font-size: .8rem; color: var(--ink-faint); margin-top: 6px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1 1 0; min-width: 0; }

/* Datum/tijd-velden: passend binnen de rand houden */
.input[type="date"], .input[type="time"] {
  min-width: 0;
  padding-left: 11px;
  padding-right: 8px;
}
.input[type="date"]::-webkit-date-and-time-value { text-align: left; }

/* ---------- Meldingen ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: .9rem; margin-bottom: 14px; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-ok { background: var(--green-light); color: var(--green-dark); border: 1px solid #bbf7d0; }
.alert.hidden { display: none; }

/* ---------- Login ---------- */
.auth-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 420px;
  margin: 0 auto;
  padding: 24px;
}
.brand { text-align: center; margin-bottom: 28px; }
.brand .logo { display: flex; align-items: center; justify-content: center; gap: 12px; }
.brand .logo-mark { width: 52px; height: 52px; }
.brand .logo-text { font-family: 'Quicksand', sans-serif; font-size: 2.4rem; font-weight: 700; color: #1E5C3A; letter-spacing: -1px; line-height: 1; }
.brand .tagline { color: var(--ink-soft); margin-top: 10px; }

.tabs { display: flex; background: var(--bg); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 18px; }
.tabs button { flex: 1; padding: 10px; border: none; background: transparent; font-weight: 600; color: var(--ink-soft); border-radius: 8px; cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Calorie-kaart (dashboard) ---------- */
.kcal-card { padding: 20px; }
.kcal-top { display: flex; align-items: center; gap: 22px; }
.ring { position: relative; width: 120px; height: 120px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-bg { stroke: var(--line); }
.ring .ring-fg { stroke: var(--orange); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-center .big { font-size: 1.6rem; font-weight: 800; color: var(--ink); }
.ring-center .small { font-size: .72rem; color: var(--ink-faint); }

.macros { display: flex; flex-direction: column; gap: 16px; flex: 1; min-width: 0; }
.macro .macro-row { display: flex; justify-content: space-between; align-items: baseline; }
.macro .lbl { font-size: .9rem; color: var(--ink-soft); font-weight: 600; }
.macro .val { font-size: .85rem; color: var(--ink-faint); }
.macro .bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 8px; }
.macro .bar i { display: block; height: 100%; border-radius: 3px; transition: width .5s ease; }
.macro .bar i.carb { background: var(--carb); }
.macro .bar i.protein { background: var(--protein); }
.macro .bar i.fat { background: var(--fat); }

.kcal-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .9rem; color: var(--ink-soft); }
.kcal-foot b { color: var(--ink); font-weight: 700; }

/* ---------- Maaltijd-kaarten ---------- */
.meal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
.meal-head { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.meal-icon { width: 44px; height: 44px; border-radius: 50%; background: #F3EFE6; color: #7A756B; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.meal-icon svg { width: 22px; height: 22px; }
.meal-info { flex: 1; min-width: 0; }
.meal-info .name { font-weight: 700; }
.meal-info .sub { font-size: .82rem; color: var(--ink-faint); margin-top: 1px; }
.meal-kcal { color: var(--ink-faint); font-size: .9rem; white-space: nowrap; }
.meal-add { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--green-light); color: var(--green-dark); font-size: 1.5rem; line-height: 1; font-weight: 600; cursor: pointer; text-decoration: none; flex-shrink: 0; }
.meal-add:active { transform: scale(.94); }
.meal-item { display: flex; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--line); font-size: .92rem; }
.meal-item .meta { color: var(--ink-faint); font-size: .8rem; }

/* ---------- Gewicht-hero ---------- */
.weight-hero { display: flex; align-items: center; gap: 16px; }
.wh-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--green-light); color: var(--green-dark); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.wh-icon svg { width: 26px; height: 26px; }
.wh-info { flex: 1; min-width: 0; }
.wh-label { font-size: .82rem; color: var(--ink-faint); }
.wh-value { font-size: 1.9rem; font-weight: 800; color: var(--ink); line-height: 1.1; }
.wh-unit { font-size: 1rem; font-weight: 600; color: var(--ink-faint); }
.wh-delta { font-size: .85rem; font-weight: 700; padding: 5px 11px; border-radius: 999px; white-space: nowrap; }
.wh-delta.down { color: var(--green-dark); background: var(--green-light); }
.wh-delta.up   { color: #B5611A; background: #FFF1DF; }
.wh-delta.flat { color: var(--ink-faint); background: var(--bg); }

/* ---------- Kaart-titel met icoon ---------- */
.card-title.with-icon { display: flex; align-items: center; gap: 8px; }
.card-title.with-icon svg { width: 16px; height: 16px; stroke: var(--green); }

/* ---------- Lijst (zoekresultaten) ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 8px; cursor: pointer; }
.list-item:active { background: var(--bg); }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .ttl { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .meta { font-size: .8rem; color: var(--ink-faint); }
.list-item .meal-icon { width: 40px; height: 40px; }
.list-item .meal-icon svg { width: 20px; height: 20px; }

/* ---------- Bottom navigatie ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  max-width: var(--maxw);
  margin: 0 auto;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: .68rem;
  color: var(--ink-faint);
  font-weight: 600;
}
.bottom-nav a .ico { font-size: 1.3rem; line-height: 1; display: flex; }
.bottom-nav a .ico svg { width: 24px; height: 24px; }
.bottom-nav a.active { color: var(--green-dark); }
.bottom-nav a.fab {
  flex: 0 0 auto;
  width: 56px; height: 56px;
  margin: -18px 8px 0;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;            /* + altijd wit, ook bij .active */
  box-shadow: 0 8px 20px rgba(255, 138, 45, .4);
  font-size: 1.8rem;
}

/* ---------- Helpers ---------- */
.center { text-align: center; }
.muted { color: var(--ink-faint); }
.spacer { height: 12px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hidden { display: none !important; }
.loader { text-align: center; padding: 30px; color: var(--ink-faint); }
.divider { display:flex; align-items:center; gap:12px; color:var(--ink-faint); font-size:.85rem; margin:16px 0; }
.divider::before, .divider::after { content:""; flex:1; height:1px; background:var(--line); }

/* ---------- Zoekbalk ---------- */
.search-bar { display:flex; gap:10px; position:sticky; top:0; z-index:10; background:var(--bg); padding:12px 0; }
.search-bar .input { flex:1; }
.scan-btn { flex:0 0 auto; width:50px; border:1px solid var(--line); background:var(--surface); border-radius:var(--radius-sm); font-size:1.4rem; cursor:pointer; }
.scan-btn:active { background:var(--bg); }

/* ---------- Scanner-overlay ---------- */
#scanOverlay { position:fixed; inset:0; z-index:100; background:#000; display:none; flex-direction:column; }
#scanOverlay.open { display:flex; }
#scanOverlay .scan-head { display:flex; align-items:center; justify-content:space-between; color:#fff; padding:16px; font-weight:600; }
#scanOverlay video { flex:1; width:100%; object-fit:cover; }
.scan-close { background:rgba(255,255,255,.15); color:#fff; border:none; width:36px; height:36px; border-radius:50%; font-size:1.1rem; cursor:pointer; }
.scan-frame { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); width:75%; max-width:320px; height:170px; border:3px solid rgba(255,255,255,.9); border-radius:14px; box-shadow:0 0 0 9999px rgba(0,0,0,.45); }
.scan-msg { position:absolute; bottom:48px; left:0; right:0; text-align:center; color:#fff; font-size:.9rem; padding:0 24px; }

/* ---------- Bottom sheet (hoeveelheid) ---------- */
.sheet-backdrop { position:fixed; inset:0; z-index:90; background:rgba(15,23,42,.45); display:none; }
.sheet-backdrop.open { display:block; }
.sheet {
  position:fixed; left:0; right:0; bottom:0; z-index:91;
  max-width:var(--maxw); margin:0 auto;
  background:var(--surface); border-radius:20px 20px 0 0;
  padding:18px 18px calc(18px + var(--safe-b));
  box-shadow:var(--shadow-lg);
  transform:translateY(100%); transition:transform .25s ease;
}
.sheet.open { transform:translateY(0); }
.sheet .grip { width:40px; height:4px; border-radius:2px; background:var(--line); margin:0 auto 14px; }
.sheet h3 { font-size:1.1rem; margin-bottom:2px; }
.sheet .sub { color:var(--ink-faint); font-size:.85rem; margin-bottom:16px; }
.sheet .kcal-preview { text-align:center; margin:6px 0 16px; }
.sheet .kcal-preview .n { font-size:2rem; font-weight:800; color:var(--green); }
.sheet .kcal-preview .u { color:var(--ink-faint); font-size:.85rem; }
.chips { display:flex; gap:8px; flex-wrap:wrap; margin-top:8px; }
.chip { padding:7px 12px; border:1px solid var(--line); border-radius:999px; background:var(--surface); font-size:.85rem; cursor:pointer; }
.chip.active { background:var(--green-light); border-color:var(--green); color:var(--green-dark); font-weight:600; }

/* ============================================
   DESKTOP-weergave (≥ 860px): zijbalk i.p.v. onderbalk
   ============================================ */
@media (min-width: 860px) {
  body { background: var(--bg); }

  .app {
    max-width: none;
    margin: 0;
    padding-left: 230px;     /* ruimte voor de vaste zijbalk */
    padding-bottom: 40px;
  }

  .appbar { padding-left: 32px; padding-right: 32px; }
  .page { max-width: 820px; margin: 0 auto; padding: 24px 32px; }

  /* De onderbalk wordt een zijbalk links */
  .bottom-nav {
    inset: 0 auto 0 0;        /* vast aan de linkerkant, volledige hoogte */
    width: 230px;
    height: 100vh;
    max-width: none;
    margin: 0;
    padding: 0 0 var(--safe-b);
    flex-direction: column;
    justify-content: flex-start;
    border-top: none;
    border-right: 1px solid var(--line);
  }
  .bottom-nav::before {
    content: "Brightly";
    display: block;
    font-family: 'Quicksand', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1E5C3A;
    letter-spacing: -.5px;
    padding: 24px 24px 18px 58px;
    background: url("../assets/brightly-icon.svg") no-repeat 22px center;
    background-size: 28px 28px;
  }
  .bottom-nav a {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 13px 24px;
    font-size: .98rem;
  }
  .bottom-nav a .ico { font-size: 1.3rem; }
  .bottom-nav a.active {
    color: var(--green-dark);
    background: var(--green-light);
    box-shadow: inset 3px 0 0 var(--green);
  }
  .bottom-nav a:not(.fab):hover { background: var(--bg); }
  .bottom-nav .fab { display: none; }   /* zwevende + niet nodig op desktop */

  /* Sheet & login netjes gecentreerd op breed scherm */
  .sheet { max-width: 460px; left: 50%; right: auto; width: 100%; transform: translate(-50%, 100%); border-radius: 20px; }
  .sheet.open { transform: translate(-50%, 0); bottom: 24px; }
  .auth-wrap { max-width: 440px; }
}
