/* ═══════════════════════════════════════════════
   MEALPLAN PWA — Organic Natural Theme
   DM Serif Display + DM Sans
   ═══════════════════════════════════════════════ */

:root {
  --green-deep:   #1a3a2a;
  --green-dark:   #1e5c3a;
  --green-med:    #2d7a50;
  --green-light:  #4caf78;
  --green-pale:   #d4edda;
  --green-xpale:  #f0faf3;
  --mint:         #b2dfdb;
  --yellow:       #fff8e1;
  --yellow-acc:   #f9a825;
  --orange-pale:  #fff3e0;
  --orange-acc:   #ef6c00;
  --blue-pale:    #e3f2fd;
  --blue-acc:     #1565c0;
  --red:          #e53935;
  --white:        #ffffff;
  --off-white:    #f8faf8;
  --gray-lt:      #f0f2f0;
  --gray:         #9e9e9e;
  --gray-dark:    #4a4a4a;
  --text:         #1a2a1e;
  --text-mid:     #3d5a44;
  --text-light:   #6e8c74;

  --radius-sm:    8px;
  --radius-md:    16px;
  --radius-lg:    24px;
  --radius-xl:    32px;
  --shadow-sm:    0 2px 8px rgba(26,58,42,.08);
  --shadow-md:    0 4px 20px rgba(26,58,42,.12);
  --shadow-lg:    0 8px 40px rgba(26,58,42,.18);

  --nav-height:   68px;
  --top-height:   56px;
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%; width: 100%; overflow: hidden;
  background: var(--green-deep);
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ── SPLASH ─────────────────────────────────────── */
#splash {
  position: fixed; inset: 0; z-index: 999;
  background: linear-gradient(160deg, var(--green-deep) 0%, var(--green-dark) 60%, #0d2118 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  transition: opacity .5s ease, transform .5s ease;
}
#splash.fade-out { opacity: 0; transform: scale(1.04); pointer-events: none; }
.splash-leaf {
  font-size: 64px;
  animation: leaf-bounce .8s ease infinite alternate;
}
@keyframes leaf-bounce {
  from { transform: translateY(0) rotate(-5deg); }
  to   { transform: translateY(-10px) rotate(5deg); }
}
.splash-title {
  font-family: 'DM Serif Display', serif;
  font-size: 42px; color: #fff; letter-spacing: -0.5px;
}
.splash-sub { color: var(--green-pale); font-size: 15px; font-weight: 300; }

/* ── APP SHELL ──────────────────────────────────── */
#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--off-white);
}
#app.hidden { display: none; }

/* ── TOP BAR ────────────────────────────────────── */
.topbar {
  height: var(--top-height);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--green-deep);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
.topbar-date { font-size: 11px; color: var(--green-pale); font-weight: 500; min-width: 70px; }
.topbar-title {
  font-family: 'DM Serif Display', serif;
  font-size: 20px; color: #fff; flex: 1; text-align: center;
}
.topbar-btn {
  background: rgba(255,255,255,.1); border: none;
  border-radius: var(--radius-sm); width: 36px; height: 36px;
  cursor: pointer; font-size: 16px; transition: background .2s;
}
.topbar-btn:active { background: rgba(255,255,255,.2); }

/* ── MAIN SCROLL ─────────────────────────────────── */
.main-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* ── TAB CONTENT ─────────────────────────────────── */
.tab-content { display: none; padding: 0 0 16px; }
.tab-content.active { display: block; }

/* ── TODAY TAB ───────────────────────────────────── */
.today-hero {
  background: linear-gradient(145deg, var(--green-dark) 0%, var(--green-deep) 100%);
  padding: 24px 20px 28px;
  color: #fff;
}
.today-day {
  font-family: 'DM Serif Display', serif;
  font-size: 32px; color: #fff; line-height: 1.1;
}
.today-greeting { font-size: 13px; color: var(--green-pale); margin-top: 4px; margin-bottom: 20px; }
.today-progress-label { font-size: 11px; color: var(--green-pale); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .8px; }
.progress-bar {
  height: 6px; background: rgba(255,255,255,.2);
  border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--green-light);
  border-radius: 99px; transition: width .6s cubic-bezier(.4,0,.2,1);
  width: 0%;
}
.progress-text { font-size: 11px; color: var(--green-pale); margin-top: 6px; }

/* Meal Cards */
.meal-cards { padding: 16px; display: flex; flex-direction: column; gap: 10px; }

.meal-card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
  border: 1.5px solid transparent;
}
.meal-card.done { border-color: var(--green-light); }
.meal-card:active { transform: scale(.98); }

.meal-card-inner { display: flex; align-items: stretch; }

.meal-card-stripe {
  width: 5px; flex-shrink: 0;
  background: var(--green-light);
}
.meal-card.breakfast .meal-card-stripe { background: #f9c74f; }
.meal-card.snack-am  .meal-card-stripe { background: #90be6d; }
.meal-card.lunch     .meal-card-stripe { background: #f3722c; }
.meal-card.snack-pm  .meal-card-stripe { background: #90be6d; }
.meal-card.dinner    .meal-card-stripe { background: #577590; }

.meal-card-body { flex: 1; padding: 12px 14px; }
.meal-card-time { font-size: 10px; color: var(--text-light); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.meal-card-name { font-family: 'DM Serif Display', serif; font-size: 16px; color: var(--text); margin: 2px 0 6px; }
.meal-card-desc { font-size: 13px; color: var(--text-mid); line-height: 1.5; }

.meal-card-check {
  width: 52px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: transparent; border: none;
  font-size: 22px; transition: transform .2s;
}
.meal-card-check:active { transform: scale(.85); }
.meal-card.done .meal-card-check::before { content: '✅'; }
.meal-card:not(.done) .meal-card-check::before { content: '⭕'; opacity: .35; }

.meal-card.done .meal-card-desc { opacity: .55; text-decoration: line-through; }

/* Reminder strip */
.reminder-strip {
  margin: 4px 16px 0;
  background: var(--green-xpale);
  border-radius: var(--radius-md);
  border: 1px solid var(--green-pale);
  overflow: hidden;
}
.reminder-item {
  padding: 10px 16px;
  font-size: 13px; color: var(--text-mid);
  border-bottom: 1px solid var(--green-pale);
}
.reminder-item:last-child { border-bottom: none; }

/* ── WEEKLY TAB ──────────────────────────────────── */
.section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 26px; color: var(--green-deep);
  padding: 20px 16px 12px;
}

.week-selector {
  display: flex; gap: 8px; padding: 0 16px 16px; overflow-x: auto;
  scrollbar-width: none;
}
.week-selector::-webkit-scrollbar { display: none; }
.week-btn {
  flex-shrink: 0; padding: 8px 20px;
  border-radius: 99px; border: 2px solid var(--green-pale);
  background: var(--white); color: var(--text-mid);
  font-size: 13px; font-weight: 600; font-family: 'DM Sans', sans-serif;
  cursor: pointer; transition: all .2s;
}
.week-btn.active {
  background: var(--green-dark); border-color: var(--green-dark);
  color: #fff; box-shadow: var(--shadow-sm);
}

.weekly-grid { padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }

.weekly-day-card {
  background: var(--white); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.weekly-day-card.today-card {
  border: 2px solid var(--green-light);
  box-shadow: 0 0 0 4px rgba(76,175,120,.12), var(--shadow-md);
}

.weekly-day-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--green-xpale);
  cursor: pointer;
}
.weekly-day-name {
  font-family: 'DM Serif Display', serif;
  font-size: 17px; color: var(--green-deep);
  display: flex; align-items: center; gap: 8px;
}
.today-badge {
  background: var(--green-med); color: #fff;
  font-size: 10px; font-family: 'DM Sans', sans-serif; font-weight: 700;
  padding: 2px 8px; border-radius: 99px; letter-spacing: .5px;
}
.weekly-day-date { font-size: 12px; color: var(--text-light); }
.weekly-day-assign-btn {
  background: var(--green-pale); border: none; border-radius: var(--radius-sm);
  padding: 4px 10px; font-size: 11px; color: var(--green-dark); font-weight: 600;
  cursor: pointer; font-family: 'DM Sans', sans-serif; transition: background .2s;
}
.weekly-day-assign-btn:active { background: var(--mint); }

.weekly-day-meals { padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.weekly-meal-row { display: flex; gap: 10px; align-items: baseline; }
.weekly-meal-time { font-size: 10px; color: var(--text-light); font-weight: 600; min-width: 54px; }
.weekly-meal-text { font-size: 13px; color: var(--text-mid); line-height: 1.4; }

/* ── SHOPPING TAB ────────────────────────────────── */
.shop-summary {
  margin: 0 16px 16px;
  background: var(--green-deep); color: #fff;
  border-radius: var(--radius-md); padding: 16px 20px;
  display: flex; gap: 16px; align-items: center;
}
.shop-stat { text-align: center; flex: 1; }
.shop-stat-num { font-family: 'DM Serif Display', serif; font-size: 28px; }
.shop-stat-label { font-size: 10px; color: var(--green-pale); text-transform: uppercase; letter-spacing: .5px; }

.shop-category { margin: 0 16px 8px; }
.shop-cat-label {
  font-size: 11px; font-weight: 700; color: var(--text-light);
  text-transform: uppercase; letter-spacing: .8px;
  padding: 8px 0 6px;
}
.shop-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--white); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 6px;
  box-shadow: var(--shadow-sm);
  cursor: pointer; transition: all .2s;
  border: 1.5px solid transparent;
  -webkit-user-select: none; user-select: none;
}
.shop-item.checked {
  background: var(--green-xpale);
  border-color: var(--green-pale);
  opacity: .75;
}
.shop-item-check { font-size: 20px; flex-shrink: 0; transition: transform .2s; }
.shop-item:active .shop-item-check { transform: scale(.8); }
.shop-item-info { flex: 1; min-width: 0; }
.shop-item-name { font-size: 14px; color: var(--text); font-weight: 500; }
.shop-item.checked .shop-item-name { text-decoration: line-through; color: var(--gray); }
.shop-item-qty { font-size: 11px; color: var(--text-light); margin-top: 2px; }

.fab-clear {
  display: block; margin: 16px auto 0;
  padding: 10px 28px; border: none;
  background: var(--gray-lt); color: var(--gray-dark);
  border-radius: 99px; font-size: 13px; font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer; transition: background .2s;
}
.fab-clear:active { background: #e0e0e0; }

/* ── MENUS TAB ───────────────────────────────────── */
#menu-list { padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }

.menu-card {
  background: var(--white); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.menu-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(90deg, var(--green-xpale), var(--white));
  cursor: pointer;
}
.menu-card-name { font-family: 'DM Serif Display', serif; font-size: 17px; color: var(--green-deep); }
.menu-card-actions { display: flex; gap: 8px; }
.menu-card-btn {
  background: transparent; border: none; font-size: 18px;
  cursor: pointer; padding: 4px; border-radius: var(--radius-sm);
  transition: background .2s;
}
.menu-card-btn:active { background: var(--gray-lt); }

.menu-card-body {
  max-height: 0; overflow: hidden;
  transition: max-height .3s ease;
}
.menu-card-body.open { max-height: 400px; }
.menu-card-slots { padding: 0 16px 14px; display: flex; flex-direction: column; gap: 6px; }
.menu-slot-row { display: flex; gap: 10px; align-items: baseline; }
.menu-slot-time { font-size: 10px; color: var(--text-light); font-weight: 600; min-width: 66px; }
.menu-slot-text { font-size: 13px; color: var(--text-mid); line-height: 1.4; }

.add-menu-btn {
  display: block; margin: 16px;
  padding: 16px; border: 2px dashed var(--green-light);
  background: var(--green-xpale); color: var(--green-dark);
  border-radius: var(--radius-md); font-size: 15px; font-weight: 600;
  font-family: 'DM Serif Display', serif;
  cursor: pointer; width: calc(100% - 32px); text-align: center;
  transition: all .2s;
}
.add-menu-btn:active { background: var(--green-pale); }

/* ── BOTTOM NAV ──────────────────────────────────── */
.bottom-nav {
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--white);
  border-top: 1px solid var(--gray-lt);
  display: flex; align-items: flex-start;
  box-shadow: 0 -4px 20px rgba(0,0,0,.06);
  flex-shrink: 0;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; padding: 10px 4px 6px;
  background: transparent; border: none;
  cursor: pointer; color: var(--gray);
  transition: color .2s, transform .1s;
  font-family: 'DM Sans', sans-serif;
}
.nav-btn.active { color: var(--green-dark); }
.nav-btn:active { transform: scale(.9); }
.nav-icon { font-size: 22px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

.nav-btn.active .nav-icon {
  filter: drop-shadow(0 2px 4px rgba(45,122,80,.3));
}

/* ── MODALS ──────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  backdrop-filter: blur(2px);
  transition: opacity .2s;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto;
  padding-bottom: calc(20px + var(--safe-bottom));
  animation: slide-up .25s ease;
}
@keyframes slide-up {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--gray-lt);
  position: sticky; top: 0; background: var(--white); z-index: 1;
}
.modal-title { font-family: 'DM Serif Display', serif; font-size: 22px; color: var(--green-deep); }
.modal-close {
  background: var(--gray-lt); border: none; border-radius: 50%;
  width: 32px; height: 32px; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-dark); transition: background .2s;
}
.modal-close:active { background: #e0e0e0; }

.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-hint { font-size: 13px; color: var(--text-light); }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 700; color: var(--text-mid); text-transform: uppercase; letter-spacing: .6px; }
.form-group input {
  padding: 12px 14px;
  border: 1.5px solid var(--gray-lt);
  border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text);
  font-family: 'DM Sans', sans-serif;
  background: var(--off-white);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus {
  border-color: var(--green-med);
  box-shadow: 0 0 0 3px rgba(45,122,80,.12);
  background: var(--white);
}

.assign-option {
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--off-white); cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .15s; margin-bottom: 8px;
}
.assign-option:hover, .assign-option:active { background: var(--green-xpale); border-color: var(--green-pale); }
.assign-option-name { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.assign-option-preview { font-size: 12px; color: var(--text-light); }

.modal-footer {
  padding: 12px 20px;
  display: flex; gap: 10px;
  border-top: 1px solid var(--gray-lt);
  position: sticky; bottom: 0; background: var(--white);
}
.btn-cancel {
  flex: 1; padding: 14px; border: 1.5px solid var(--gray-lt);
  background: var(--white); border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; font-family: 'DM Sans', sans-serif;
  color: var(--gray-dark); cursor: pointer; transition: background .2s;
}
.btn-cancel:active { background: var(--gray-lt); }
.btn-save {
  flex: 2; padding: 14px; border: none;
  background: var(--green-dark); color: #fff;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700; font-family: 'DM Sans', sans-serif;
  cursor: pointer; transition: background .2s;
}
.btn-save:active { background: var(--green-deep); }

/* ── TOAST ───────────────────────────────────────── */
.toast {
  position: fixed; bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  left: 50%; transform: translateX(-50%);
  background: var(--green-deep); color: #fff;
  padding: 10px 22px; border-radius: 99px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 300;
  transition: opacity .3s, transform .3s;
  white-space: nowrap;
}
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(12px); pointer-events: none; }

/* ── UTILITIES ───────────────────────────────────── */
.hidden { display: none !important; }

/* Scrollbar hide */
.main-scroll::-webkit-scrollbar { display: none; }

/* Safe area for notched phones */
.topbar { padding-top: max(env(safe-area-inset-top, 0px), 8px); height: calc(var(--top-height) + env(safe-area-inset-top, 0px)); }
