/* =========================================================
   Chef Victor Eymael — design system
   ========================================================= */
:root {
  /* cores */
  --bg: #F2F3F5;
  --bg-desktop: #E6E7EA;
  --surface: #FFFFFF;
  --border: #E6E7EA;
  --text: #1F2A24;
  --text-muted: #8A8F98;
  --text-soft: #B4B8BF;
  --ink: #222222;
  --ink-text: #FFFFFF;
  --star: #F5B92E;
  --heart: #E5484D;
  --lime: #E3F0C4;
  --lime-ink: #4E6B1A;
  --peach: #FBE3CF;
  --peach-ink: #9A5521;
  --mint: #D6F0EE;
  --mint-ink: #22706A;
  --neutral-tag: #EEEFF1;

  /* raios */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* espaçamentos */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --gutter: 20px;

  /* layout */
  --frame: 420px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow-soft: 0 1px 2px rgba(20, 24, 22, 0.04);
  --shadow-float: 0 8px 24px rgba(20, 24, 22, 0.18);

  --font: "Outfit", "Urbanist", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
img, svg { display: block; }

/* ---------- frame ---------- */
.app {
  position: relative;
  max-width: var(--frame);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  overflow-x: hidden;
}
@media (min-width: 480px) {
  body { background: var(--bg-desktop); }
  .app { box-shadow: 0 0 0 1px var(--border); }
}
.fixed-in-frame {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--frame);
}

.view {
  padding: 0 var(--gutter) calc(var(--tabbar-h) + var(--safe-b) + var(--s-6));
}
.view.no-tabbar { padding-bottom: calc(96px + var(--safe-b)); }
.view.chat-view { padding-bottom: 0; }

/* ---------- header ---------- */
.header {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) 0 var(--s-3);
  padding-top: max(var(--s-4), env(safe-area-inset-top, 0px));
}
.header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.header .spacer { flex: 1; }
.subtitle { margin: -4px 0 var(--s-4); color: var(--text-muted); font-weight: 300; font-size: 15px; }

.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--text);
}
.icon-btn:active { transform: scale(0.96); }
.icon-btn.on { color: var(--heart); }
.icon-btn.on svg { fill: var(--heart); }

/* ---------- busca ---------- */
.search {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  height: 52px;
  padding: 0 var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text-muted);
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  color: var(--text);
}
.search input::placeholder { color: var(--text-muted); font-weight: 300; }

/* ---------- chips ---------- */
.chips {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  scrollbar-width: none;
  margin: var(--s-4) calc(-1 * var(--gutter));
  padding: 0 var(--gutter);
  scroll-padding: 0 var(--gutter);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  height: 40px;
  padding: 0 var(--s-4);
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 15px;
  font-weight: 400;
  color: var(--text);
  white-space: nowrap;
}
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--ink-text); font-weight: 500; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chips.wrap .chip { height: auto; min-height: 36px; padding: 8px 14px; white-space: normal; text-align: left; font-size: 14px; }

/* ---------- lista de receitas ---------- */
.list { display: flex; flex-direction: column; gap: var(--s-3); }
.row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-soft);
  min-width: 0;
}
.row:active { transform: scale(0.99); }
.thumb {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 32px;
  line-height: 1;
}
.thumb.sm { width: 52px; height: 52px; font-size: 26px; border-radius: var(--r-sm); }
.row-body { flex: 1; min-width: 0; }
.row-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 300;
}
.meta svg { color: var(--text-muted); }
.meta .star { color: var(--star); fill: var(--star); }
.chev { flex: none; color: var(--text-soft); }

.empty {
  padding: var(--s-8) var(--s-4);
  text-align: center;
  color: var(--text-muted);
  font-weight: 300;
}
.empty .big { font-size: 40px; margin-bottom: var(--s-2); }

/* ---------- detalhe ---------- */
.hero {
  position: relative;
  margin: 0 calc(-1 * var(--gutter));
  height: 340px;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.hero.has-photo > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb.has-photo { overflow: hidden; }
.thumb.has-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero .emoji { font-size: 140px; line-height: 1; filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.12)); }
.hero-actions {
  position: absolute;
  top: max(var(--s-4), env(safe-area-inset-top, 0px));
  left: var(--gutter);
  right: var(--gutter);
  display: flex;
  justify-content: space-between;
}
.hero-actions .icon-btn { border-color: transparent; }
.detail-title { margin: var(--s-6) 0 var(--s-2); font-size: 28px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; }
.detail-desc { margin: 0 0 var(--s-5); color: var(--text-muted); font-weight: 300; font-size: 15px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.stat {
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-width: 0;
}
.stat svg { color: var(--text); margin-bottom: var(--s-2); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 300; }
.stat-value { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.section-title { margin: var(--s-8) 0 var(--s-3); font-size: 20px; font-weight: 500; letter-spacing: -0.01em; }
.section-title small { color: var(--text-muted); font-weight: 300; font-size: 16px; }

.ing { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); }
.ing-name { margin: 0 0 2px; font-size: 15px; font-weight: 500; }
.ing-qty { font-size: 14px; color: var(--text-muted); font-weight: 300; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag { padding: 2px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 500; background: var(--neutral-tag); color: var(--text); }
.tag.lime { background: var(--lime); color: var(--lime-ink); }
.tag.peach { background: var(--peach); color: var(--peach-ink); }
.tag.mint { background: var(--mint); color: var(--mint-ink); }

a.stat { color: inherit; text-decoration: none; }
.group-title { margin: var(--s-4) 0 var(--s-2); font-size: 14px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ing-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-1) var(--s-4); }
.ing-line { display: flex; align-items: baseline; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
.ing-line:last-child { border-bottom: 0; }
.ing-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; transform: translateY(-1px); }
.ing-line .ing-name { flex: 1; min-width: 0; margin: 0; font-weight: 400; overflow-wrap: anywhere; }
.ing-line .ing-qty { flex: none; max-width: 42%; text-align: right; overflow-wrap: anywhere; }
.tips { display: flex; flex-direction: column; gap: var(--s-2); }
.tip { display: flex; gap: var(--s-3); margin: 0; padding: var(--s-4); background: var(--surface); border-radius: var(--r-md); font-size: 15px; line-height: 1.5; }
.tip svg { flex: none; margin-top: 2px; }
.sides { margin: 2px 0 var(--s-3); padding: var(--s-2) var(--s-3); background: var(--lime); color: var(--lime-ink); border-radius: var(--r-sm); font-size: 13px; line-height: 1.4; }
.note { margin: 0 0 var(--s-3); padding: var(--s-3); background: var(--peach); color: var(--peach-ink); border-radius: var(--r-sm); font-size: 13px; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.steps li { display: flex; gap: var(--s-3); padding: var(--s-4); background: var(--surface); border-radius: var(--r-md); font-size: 15px; line-height: 1.5; }
.step-n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--ink-text); display: grid; place-items: center; font-size: 13px; font-weight: 600; }

/* ---------- CTA flutuante ---------- */
.cta-wrap {
  bottom: 0;
  padding: var(--s-3) var(--gutter) calc(var(--s-4) + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 60%, rgba(242, 243, 245, 0));
  z-index: 20;
}
.cta {
  width: 100%;
  height: 58px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--ink-text);
  font-size: 17px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  box-shadow: var(--shadow-float);
}
.cta .star { color: var(--star); fill: var(--star); }
.cta:active { transform: scale(0.99); }
.cta.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: none; height: 48px; font-size: 15px; }

/* ---------- bottom sheet (avaliar) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(20, 24, 22, 0.35); z-index: 40; display: flex; justify-content: center; align-items: flex-end; }
.sheet { width: 100%; max-width: var(--frame); background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0; padding: var(--s-6) var(--gutter) calc(var(--s-6) + var(--safe-b)); text-align: center; }
.sheet h3 { margin: 0 0 4px; font-size: 20px; font-weight: 500; }
.sheet p { margin: 0 0 var(--s-5); color: var(--text-muted); font-weight: 300; }
.stars-pick { display: flex; justify-content: center; gap: var(--s-2); margin-bottom: var(--s-6); }
.stars-pick button { color: var(--text-soft); padding: 4px; }
.stars-pick button.on { color: var(--star); }
.stars-pick button.on svg { fill: var(--star); }

/* ---------- cardápio ---------- */
.week { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-soft); }
.week-head { width: 100%; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4); text-align: left; }
.week-badge { flex: none; width: 48px; height: 48px; border-radius: var(--r-md); background: var(--lime); display: grid; place-items: center; font-weight: 600; font-size: 18px; color: var(--lime-ink); }
.week:nth-child(3n+2) .week-badge { background: var(--peach); color: var(--peach-ink); }
.week:nth-child(3n) .week-badge { background: var(--mint); color: var(--mint-ink); }
.week-head .chev { transition: transform 0.2s ease; }
.week.open .week-head .chev { transform: rotate(180deg); }
.week-body { display: none; padding: 0 var(--s-4) var(--s-4); }
.week.open .week-body { display: block; }
.day { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; border-top: 1px solid var(--border); min-width: 0; }
.day-label { flex: none; width: 64px; font-size: 13px; color: var(--text-muted); font-weight: 400; }
.day .row-title { font-size: 15px; margin: 0; }
.week-body .cta { margin-top: var(--s-3); }

/* lista de compras */
.shop-group { margin-bottom: var(--s-5); }
.shop-group h3 { margin: 0 0 var(--s-2); font-size: 14px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.shop-item { width: 100%; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: var(--s-2); text-align: left; }
.check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--text-soft); display: grid; place-items: center; color: transparent; }
.shop-item.done .check { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.shop-item.done .shop-name { text-decoration: line-through; color: var(--text-muted); }
.shop-name { flex: 1; min-width: 0; font-size: 15px; }
.shop-qty { flex: none; max-width: 45%; font-size: 13px; color: var(--text-muted); font-weight: 300; text-align: right; }

/* ---------- chat ---------- */
.chat-view { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.chef-id { display: flex; align-items: center; gap: var(--s-3); flex: 1; min-width: 0; }
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--peach), var(--lime)); display: grid; place-items: center; font-size: 22px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.brand { padding-top: max(var(--s-3), env(safe-area-inset-top, 0px)); margin: 0 -6px -6px; }
.brand img { display: block; width: 100%; max-width: 300px; height: auto; }
.chef-name { font-size: 18px; font-weight: 500; line-height: 1.2; }
.chef-status { font-size: 13px; color: var(--text-muted); font-weight: 300; }
.messages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-2) 0 var(--s-4); }
.bubble { max-width: 82%; padding: var(--s-3) var(--s-4); border-radius: var(--r-lg); font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.bubble.chef { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 6px; }
.bubble.user { align-self: flex-end; background: var(--ink); color: var(--ink-text); border-bottom-right-radius: 6px; }
.bubble .source { display: inline-flex; align-items: center; gap: 4px; margin-top: var(--s-2); padding: 4px 10px; border-radius: var(--r-pill); background: var(--lime); color: var(--lime-ink); font-size: 13px; font-weight: 500; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-soft); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }
.suggest-label { font-size: 13px; color: var(--text-muted); font-weight: 300; margin: var(--s-2) 0; }
.composer-area { flex: none; padding: var(--s-2) 0 calc(var(--tabbar-h) + var(--safe-b) + var(--s-3)); }
.composer { display: flex; align-items: center; gap: var(--s-2); padding: 6px 6px 6px var(--s-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pill); }
.composer input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; height: 44px; }
.composer input::placeholder { color: var(--text-muted); font-weight: 300; }
.send { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: var(--ink-text); display: grid; place-items: center; }
.send:disabled { opacity: 0.35; }
.disclaimer { margin: var(--s-2) 0 0; text-align: center; font-size: 12px; color: var(--text-muted); font-weight: 300; }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--frame);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 30;
}
.tabbar.hidden { display: none; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--text-soft); font-weight: 400; }
.tab.active { color: var(--ink); font-weight: 500; }

/* ---------- toast ---------- */
.toast { bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 50; display: flex; justify-content: center; pointer-events: none; }
.toast span { background: var(--ink); color: var(--ink-text); padding: 10px 18px; border-radius: var(--r-pill); font-size: 14px; box-shadow: var(--shadow-float); }

.notice { margin: 0 0 var(--s-4); padding: var(--s-3) var(--s-4); background: var(--peach); color: var(--peach-ink); border-radius: var(--r-md); font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ajustes pós-validação */
.stat-label { min-height: 2.6em; line-height: 1.3; }
.day-label { width: 58px; }
.day .row-title { white-space: normal; line-height: 1.25; }
.toast { bottom: calc(96px + var(--safe-b)); }
