/* v5.1 — Optimized Modern Edition */
:root{
  --bg:#0B1020; --card:#121A3A; --ink:#EAF0FF; --muted:#A8B0D6; --line:#26325E;
  --accent: #7DD3FC; --p:#A78BFA; --c:#34D399; --f:#FB7185; --k:#60A5FA;
  --bar-bg: #1a2247;
}
html[data-theme="light"]{
  --bg:#F8FAFF; --card:#FFFFFF; --ink:#0B1020; --muted:#64748B; --line:#E5E7EB;
  --accent:#06B6D4; --p:#7C3AED; --c:#059669; --f:#DC2626; --k:#2563EB;
  --bar-bg:#EDF2F7;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--ink);font-family:Inter,system-ui,Arial}
h1,h2,h3{font-family:Poppins,Inter,system-ui,Arial;margin:0}
.topbar{display:flex;justify-content:space-between;align-items:center;padding:14px 20px;border-bottom:1px solid var(--line);position:sticky;top:0;background:var(--bg);z-index:5}
.brand h1{font-size:22px}
.brand .meta{font-size:12px;color:var(--muted);margin-top:4px}
.btn{border:none;border-radius:12px;padding:8px 12px;background:linear-gradient(135deg,#8B5CF6,#06B6D4);color:#fff;font-weight:700;cursor:pointer;margin-left:8px}
.btn.ghost{background:transparent;color:var(--ink);border:1px solid var(--line)}
.iconBtn{border:none;background:transparent;color:var(--ink);cursor:pointer;font-size:16px}
/* Daily bars row */
.dailyBars{display:grid;grid-template-columns:repeat(7,1fr);gap:10px;padding:12px 20px;break-inside:avoid;page-break-inside:avoid}
.dayBar{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:8px 10px}
.dayBar .head{display:flex;justify-content:space-between;align-items:center;font-weight:700;font-size:12px;margin-bottom:6px}
.progress{height:6px;border-radius:6px;background:var(--bar-bg);overflow:hidden}
.progress > span{display:block;height:100%;background:var(--k);width:0;transition:width .4s ease}
.metaRow{display:flex;justify-content:space-between;font-size:11px;color:var(--muted);margin-top:6px}
/* Week grid */
.weekGrid{padding:10px 20px;display:grid;grid-template-columns:repeat(4,1fr);gap:12px}
.day{background:var(--card);border:1px solid var(--line);border-radius:14px;break-inside:avoid;page-break-inside:avoid;display:flex;flex-direction:column}
.dayHeader{padding:10px 12px;border-bottom:1px solid var(--line);font-weight:800;letter-spacing:.5px}
.meal{padding:10px 12px;border-top:1px dashed var(--line)}
.meal:first-of-type{border-top:none}
.meal .row1{display:flex;justify-content:space-between;align-items:center}
.meal .mTitle{font-weight:700;font-size:8px;display:flex;gap:8px;align-items:center}
.meal .edit{opacity:.8;margin-left:8px}
.meal .dish{margin-top:2px; font-size: 12px}
.meal .mac{color:var(--muted);font-size:8px}
.dayFooter{padding:8px 12px;border-top:1px solid var(--line);font-size:12px;color:var(--muted)}
/* Popup picker */
.picker{position:fixed;inset:0;background:rgba(0,0,0,.45);display:flex;align-items:center;justify-content:center}
.picker.hidden{display:none}
.pickerCard{width:520px;max-height:70vh;background:var(--card);border:1px solid var(--line);border-radius:12px;overflow:hidden;box-shadow:0 20px 50px rgba(0,0,0,.35)}
.pickerHead{display:flex;justify-content:space-between;align-items:center;padding:10px 12px;border-bottom:1px solid var(--line)}
.pickerSearch{width:100%;padding:8px 10px;border:none;border-bottom:1px solid var(--line);background:transparent;color:var(--ink)}
.pickerList{list-style:none;margin:0;padding:0;max-height:50vh;overflow:auto}
.pickerList li{padding:10px 12px;border-bottom:1px solid var(--line);cursor:pointer}
.pickerList li:hover{background:rgba(125,211,252,.1)}
/* Ingredients page */
.ingredients{page-break-before:always;padding:16px 20px}
.ingredients h2{font-size:14px;margin-bottom:10px}
.ingBuckets{display:grid;grid-template-columns:repeat(4,1fr);gap:12px}
.bucket{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:10px 12px;break-inside:avoid; font-size: 12px;}
.bucket h3{margin:0 0 6px;font-size:12px}
.bucket ul{margin:0;padding-left:18px}
/* Top section - progress bar */
/* === Per-day macro summary section === */
.macroBarsWrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px 10px;
  font-size: 11px;           /* Adjust this for smaller/larger text */
  line-height: 1.3;
}

.macroLabel {
  font-weight: 600;
  margin-bottom: 2px;
}

.macroBar .progress {
  height: 5px;               /* Adjust bar thickness */
  border-radius: 4px;
  background: var(--bar-bg);
  overflow: hidden;
}

.macroBar .progress > span {
  display: block;
  height: 100%;
  transition: none;           /* static (no animation) */
}


/* --- Daily summary cards --- */
/* --- Make daily summary tiles appear as cards like the meal section --- */
#dailyBars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

/* Make each top summary tile look like a meal card */
.daySummaryTile {
  background: var(--card);               /* ✅ use the same background as meal cards */
  border: 1px solid var(--line);         /* match meal card border */
  border-radius: 14px;                   /* same as .day cards */
  box-shadow: 0 0px 0px rgba(0,0,0,.25); /* subtle elevation like .day */
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 150px;
  box-sizing: border-box;
}

.daySummaryTile strong {
  letter-spacing: .5px;
}

.daySummaryTile .macroBarsWrap {
  margin-top: 4px;
}

/* Ensure alignment with meals */
#dailyBars,
#week {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.daySummaryHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

/* inner layout */
.daySummaryTile .macroBarsWrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  line-height: 1.3;
}

/* card look consistency */
.daySummaryTile .progress {
  height: 6px;
  border-radius: 4px;
  background: var(--bar-bg);
  overflow: hidden;
}

.daySummaryTile .progress > span {
  display: block;
  height: 100%;
}

/* distinct macro colors */
.macroBar.calories .progress > span { background: #2196F3; }  /* blue */
.macroBar.protein  .progress > span { background: #9C27B0; }  /* violet */
.macroBar.carbs    .progress > span { background: #4CAF50; }  /* green */
.macroBar.fats     .progress > span { background: #FF9800; }  /* orange */

/* Footer */
.foot{padding:12px 20px;color:var(--muted)}
/* Print */
@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  /* Hide UI not needed for print */
  .topbar,
  .foot,
  .picker {
    display: none !important;
  }

  /* Force light mode for print */
  :root {
    --window: #ffffff;
    --card: #ffffff;
    --text: #000000;
    --line: #cccccc;
    --border: #cccccc;
    --bar-bg: #e5e7eb;
    --shadow: none;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  /* Always print backgrounds and colors */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Cards (meals + top summary) */
  .day,
  .daySummaryTile,
  .bucket {
    background: var(--card) !important;
    border: 1px solid #aaa !important;
    box-shadow: none !important;
    color: #000 !important;
  }

  /* Keep macro bar colors visible */
  .progress > span {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Shared grid layout for summary + meals */
  #dailyBars,
  #week {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px !important;
  }

  /* --- Page Breaks --- */

  /* Page 1: summary tiles only */
  #dailyBars {
    page-break-after: always;
  }

  /* Page 2: meals grid */
  #week {
    page-break-after: always;
  }

  /* Page 3: ingredients */
  .ingredients {
    page-break-before: always;
  }
}

