/* Cookzer shared shell styles — sidebar, header, reset, scrollbar, mobile nav.
   Page-specific styles stay inline in each page's <style> block. */
:root {
  /* "Fresh Market" palette — basil green + tomato coral + lemon,
     replacing the earlier Italian-flag-coded green/red. */
  --cream: #FAFAF5;
  --card-bg: #FFFFFF;
  --ink: #26251F;
  --ink-soft: #66695C;
  --olive: #2E8F5C;
  --olive-dark: #1F7A4A;
  --mustard: #F4B942;
  --brick: #FF6B4A;
  --line: #E3E6DC;
  --plus-tint: rgba(244, 185, 66, 0.07);
  --plus-border: rgba(244, 185, 66, 0.30);
  --plus-hover: rgba(244, 185, 66, 0.14);
}

/* Dark mode — same token names, different values. Explicit toggle only
   (data-theme="dark" set by theme.js from a saved localStorage choice),
   not driven by prefers-color-scheme, since Cookzer's shell renders on
   a fixed cream background by design until the user opts in. */
[data-theme="dark"] {
  --cream: #181A13;
  --card-bg: #22251C;
  --ink: #F0EEE2;
  --ink-soft: #AEB39C;
  --olive: #2E8F5C;
  --olive-dark: #1F7A4A;
  --mustard: #F6C55B;
  --brick: #FF6B4A;
  --line: #34362A;
  --plus-tint: rgba(246, 197, 91, 0.08);
  --plus-border: rgba(246, 197, 91, 0.28);
  --plus-hover: rgba(246, 197, 91, 0.16);
}

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

/* A couple of elements pair the hidden attribute with an inline
   display: value for their shown state (e.g. #restaurantTag) — inline
   styles otherwise beat the UA stylesheet's [hidden]{display:none},
   so the element never actually hides. !important here always wins
   over a plain (non-important) inline style, closing that off site-wide
   rather than patching each occurrence. */
[hidden] { display: none !important; }

html, body {
  font-family: 'Work Sans', sans-serif;
  color: var(--ink);
  background: var(--cream);
}

h1, h2, h3, .brand {
  font-family: 'Fraunces', serif;
  font-weight: 600;
}

/* Layout — capped and centered on wide screens (Facebook-style framing)
   instead of the sidebar sitting flush against the browser's left edge
   and stretching everything else to fill an arbitrarily wide window.
   position: relative also makes body the containing block for .header
   below (position: absolute), so the header's left/right offsets — and
   its own overflow clipping via this rule's overflow: hidden — resolve
   against this centered frame instead of the raw viewport. */
body {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  max-width: 1440px;
  margin: 0 auto;
  position: relative;
}

/* Sidebar — padding-top also covers the mobile drawer variant (each
   page's own media query makes it position: fixed; top: 0 as a
   full-height overlay), which sits under the status bar the same way
   .header does; --cz-viewport-inset-fix-top is 0px everywhere this
   doesn't apply, so it's harmless to include unconditionally. */
.sidebar {
  width: 280px;
  background: var(--card-bg);
  border-right: 1px solid var(--line);
  padding: 20px 0;
  padding-top: calc(20px + var(--cz-viewport-inset-fix-top, 0px));
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  flex-shrink: 0;
}

/* Real fix for the Android WebView bottom-cutoff bug, replacing an
   earlier data-native-app-gated attempt (both signals it relied on —
   window.Capacitor.isNativePlatform() and a WebView user-agent check —
   turned out false on the actual reporting device, so it silently
   never fired). --cz-viewport-inset-fix is set by theme.js from
   window.visualViewport, which measures the genuinely-visible area
   directly instead of assuming the browser's own env(safe-area-inset-*)
   already accounts for the system nav bar; it resolves to 0px (and
   changes nothing) everywhere that assumption happens to hold, no
   environment detection required. !important because these need to
   beat each page's own single-class .main rule regardless of source
   order, and a plain selector here can't outrank it on specificity
   alone the way the old attribute-qualified one did. */
.main,
.feed-container,
.msg-list,
.thread-messages,
.sidebar {
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px), var(--cz-viewport-inset-fix, 0px)) !important;
}

.sidebar-brand {
  padding: 0 16px;
  margin-bottom: 20px;
  font-size: 22px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  color: var(--olive-dark);
  letter-spacing: -0.5px;
}

.sidebar-brand span {
  color: var(--brick);
}

.sidebar-item {
  padding: 10px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.2s;
  font-size: 15px;
  color: var(--ink-soft);
}

.sidebar-item:hover {
  background: var(--cream);
  color: var(--olive);
}

.sidebar-item.active {
  border-left-color: var(--olive);
  color: var(--olive-dark);
  font-weight: 500;
  background: rgba(78, 90, 62, 0.05);
}

.sidebar-item.icon {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-item.icon:before {
  font-size: 20px;
  min-width: 20px;
}

.sidebar-item.feed:before { content: "📰"; }
.sidebar-item.cookbook:before { content: "📚"; }
.sidebar-item.planner:before { content: "📅"; }
.sidebar-item.health:before { content: "🩺"; }
.sidebar-item.pantry:before { content: "🥕"; }
.sidebar-item.challenges:before { content: "🏆"; }
.sidebar-item.groups:before { content: "👥"; }
.sidebar-item.restaurants:before { content: "🧾"; }
.sidebar-item.profile:before { content: "👤"; }
.sidebar-item.messenger:before { content: "💬"; }
.sidebar-item.convert:before { content: "📏"; }
.sidebar-item.tips:before { content: "💡"; }

/* Cookzer+ sidebar panel — a distinct, minimal corner for the 3
   AI-backed paid modules. A soft mustard-tinted card (not another plain
   list under the main nav) with its own gold hover/active state, since
   olive is already "you are here" for the regular nav above it. */
.sidebar-plus {
  margin: 14px 14px 4px;
  padding: 12px 10px;
  border-radius: 14px;
  background: var(--plus-tint);
  border: 1px solid var(--plus-border);
}

.sidebar-plus-label {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 12px;
  color: var(--mustard);
  padding: 0 6px;
  margin-bottom: 6px;
}

.sidebar-plus-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 6px;
  border-radius: 9px;
  font-size: 13.5px;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-plus-item:before { font-size: 15px; min-width: 16px; text-align: center; }
.sidebar-plus-item:hover { background: var(--plus-hover); color: var(--ink); }
.sidebar-plus-item.active { background: var(--plus-hover); color: var(--ink); font-weight: 600; }

.sidebar-plus-item.pantry:before { content: "🥕"; }
.sidebar-plus-item.leftovers:before { content: "🍲"; }
.sidebar-plus-item.health:before { content: "🩺"; }

.sidebar-friends-widget {
  margin-top: 20px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.sidebar-friends-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-faint);
  margin-bottom: 10px;
}

.sidebar-friends-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sidebar-friend-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--olive), var(--olive-dark));
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-friends-settings {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--cream);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  text-decoration: none;
  flex-shrink: 0;
  margin-left: auto;
}

/* Header — extends up to the true top of the screen (top: 0) and paints
   its own background through the status-bar area, rather than leaving a
   gap; the row of icons/logo is pushed down out of that area via
   padding-top instead, so the header's own height grows to match
   (box-sizing: border-box is set globally above). --cz-viewport-inset-fix-top
   is set by theme.js the same way --cz-viewport-inset-fix is for the
   bottom nav-bar overlap (see .main etc. below) — it's usually 0px (an
   ordinary browser, or a native app where the OS already reserves status
   bar space) and only engages on a device where it doesn't. */
.header {
  position: absolute;
  top: 0;
  left: 280px;
  right: 0;
  height: calc(60px + var(--cz-viewport-inset-fix-top, 0px));
  background: var(--card-bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  padding-top: var(--cz-viewport-inset-fix-top, 0px);
  justify-content: space-between;
  z-index: 10;
}

.brand-header span {
  color: var(--brick);
}

.header-right {
  display: flex;
  gap: 16px;
  align-items: center;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--cream);
  border: 1px solid var(--line);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: #f0e6d2;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-soft);
}

/* Mobile nav */
.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--cream);
  border: 1px solid var(--line);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 32, 0.4);
  z-index: 90;
}

/* Photo lightbox (shared component, see photo-lightbox.js) */
.pl-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 14, 10, 0.88);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.pl-overlay.open { display: flex; }

.pl-frame {
  display: flex;
  width: 100%;
  max-width: 1080px;
  max-height: 88vh;
  background: var(--card-bg);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  position: relative;
}

.pl-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.pl-close:hover { background: rgba(0, 0, 0, 0.65); }

.pl-image-wrap {
  flex: 1 1 auto;
  min-width: 0;
  background: #0d0b09;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pl-image-wrap img {
  max-width: 100%;
  max-height: 88vh;
  object-fit: contain;
  display: block;
}

.pl-panel {
  width: 300px;
  flex-shrink: 0;
  border-left: 1px solid var(--line);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.pl-author {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.pl-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--olive), var(--olive-dark));
  background-size: cover;
  background-position: center;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pl-author-info { min-width: 0; }
.pl-author-name { font-weight: 600; font-size: 14px; }
.pl-time { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }

.pl-caption {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
}

.pl-meta-list { display: flex; flex-direction: column; gap: 8px; }

.pl-meta-row {
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.pl-meta-row b { color: var(--ink); font-weight: 600; }

.pl-recipe-link {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--olive-dark);
  text-decoration: none;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

@media (max-width: 720px) {
  .pl-frame { flex-direction: column; max-height: 92vh; }
  .pl-image-wrap { max-height: 50vh; }
  .pl-image-wrap img { max-height: 50vh; }
  .pl-panel { width: 100%; border-left: none; border-top: 1px solid var(--line); }
}

/* Shared picker/form modal ("cz2") — a real search-and-click list or a
   row of selectable chips, standing in for CookzerModal.prompt()
   wherever a page needs the person to choose among several options
   rather than type free text (see CLAUDE.md: never a numbered-list
   prompt for that). Originally built for cookzer-planner.html's meal
   and suggestion pickers; shared here so any page can reuse the same
   #pickerOverlay/#pickerModal markup instead of copying the CSS. */
.cz2-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 26, 20, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.cz2-modal {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 22px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.cz2-modal h3 {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--olive-dark);
  margin-bottom: 14px;
}

.cz2-modal input[type="text"],
.cz2-modal input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 10px;
}

.cz2-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.cz2-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 14px;
}

.cz2-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

.cz2-row:last-child { border-bottom: none; }
.cz2-row:hover { background: var(--cream); }

.cz2-row .cz2-row-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--olive), var(--olive-dark));
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cz2-row .cz2-row-action {
  margin-left: auto;
  background: var(--olive);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cz2-empty {
  padding: 14px;
  font-size: 13px;
  color: var(--ink-soft);
}

.cz2-divider {
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  margin: 4px 0 12px;
}

.cz2-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.cz2-chip {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--cream);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}

.cz2-chip.selected { background: var(--olive); color: #fff; border-color: var(--olive); }

.cz2-free-row { display: flex; gap: 8px; }
.cz2-free-row input { flex: 1; margin-bottom: 0; }

.cz2-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.cz2-field { margin-bottom: 14px; }
.cz2-field textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  resize: vertical;
}

.cz2-cover-preview {
  width: 100%;
  height: 90px;
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  margin-bottom: 10px;
  border: 1px solid var(--line);
}

/* Month calendar inside the cz2 picker (currently just the planner's
   "Jump to a date") — a real in-app grid rather than a native
   <input type="date"> popup, so it can be branded and stay consistent
   with the rest of the cz2-* picker family. The row for whichever week
   is currently on screen gets a solid olive band so "which week am I
   looking at" reads at a glance against the neutral month grid. */
.cz2-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.cz2-cal-month-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--cream);
  color: var(--olive-dark);
  font-size: 13px;
  cursor: pointer;
}

.cz2-cal-month-btn:hover:not(:disabled) { border-color: var(--olive); background: var(--plus-hover, var(--cream)); }
.cz2-cal-month-btn:disabled { opacity: 0.35; cursor: default; }

.cz2-cal-month-label {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--olive-dark);
  text-align: center;
}

.cz2-cal-weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 6px;
}

.cz2-cal-weekday {
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink-soft);
}

.cz2-cal-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.cz2-cal-week-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-radius: 999px;
  transition: background 0.15s;
}

.cz2-cal-week-row.current-week {
  background: rgba(46, 143, 92, 0.16);
}

.cz2-cal-cell {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.cz2-cal-cell:hover:not(:disabled) { background: var(--olive); color: #fff; }
.cz2-cal-cell.other-month { color: var(--ink-soft); opacity: 0.4; }
.cz2-cal-cell:disabled { opacity: 0.25; cursor: default; }

.cz2-cal-cell.today {
  font-weight: 700;
  box-shadow: inset 0 0 0 1.5px var(--mustard);
}

.cz2-cal-legend {
  display: flex;
  gap: 16px;
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.cz2-cal-legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

/* Profile hover card (profile-hover-card.js) — a quick peek shown when
   hovering any link to a Cookzer profile: avatar, bio/location, and a
   few stats, without navigating away. One shared element, repositioned
   and refilled per hover rather than built once per profile link. */
.cz-hovercard {
  position: fixed;
  z-index: 500;
  width: 240px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.cz-hovercard-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.cz-hovercard-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--olive), var(--olive-dark));
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
}

.cz-hovercard-titles { min-width: 0; }

.cz-hovercard-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cz-hovercard-meta {
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cz-hovercard-stats {
  display: flex;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.cz-hovercard-stat { text-align: center; flex: 1; }

.cz-hovercard-stat-num {
  display: block;
  font-weight: 700;
  font-size: 14px;
  color: var(--olive-dark);
}

.cz-hovercard-stat-label {
  display: block;
  font-size: 10px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.cz-hovercard-loading {
  font-size: 12px;
  color: var(--ink-soft);
  padding: 4px 0;
}
