/* NutriCoach — Design system partagé */
:root {
  --bg:       #0d1b2a;
  --bg2:      #1a2a3a;
  --bg3:      #243447;
  --border:   #2d4057;
  --text:     #e8f4f8;
  --text2:    #7a9bb5;
  --green:    #00c97a;
  --green-d:  #009f60;
  --green-glow: rgba(0,201,122,.15);
  --orange:   #f97316;
  --blue:     #38bdf8;
  --purple:   #a78bfa;
  --yellow:   #fbbf24;
  --red:      #f87171;
  --radius:   13px;
  --shadow:   0 4px 24px rgba(0,0,0,.35);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  font-size: 15px;
}

/* ── Nav ─────────────────────────────────────────────────── */
.topnav {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}
.nav-logo {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--green);
  margin-right: auto;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-logo small {
  font-size: .65rem;
  color: var(--text2);
  font-weight: 400;
  display: block;
  letter-spacing: 0;
  margin-top: 1px;
}
.nav-btn {
  background: none;
  border: none;
  color: var(--text2);
  padding: 6px 11px;
  border-radius: 7px;
  cursor: pointer;
  font-size: .82rem;
  transition: all .18s;
  white-space: nowrap;
}
.nav-btn:hover { background: var(--bg3); color: var(--text); }
.nav-btn.active { background: var(--green); color: #fff; font-weight: 600; }
.nav-btn.logout { color: var(--text2); }
.nav-btn.logout:hover { background: #7f1d1d44; color: var(--red); }

/* ── Layout ──────────────────────────────────────────────── */
.page { display: none; padding: 20px; max-width: 980px; margin: 0 auto; }
.page.active { display: block; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:none; } }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card-title {
  font-size: .7rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 14px;
  font-weight: 600;
}

/* ── Grid ────────────────────────────────────────────────── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.g3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.g4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }

/* ── Stats ───────────────────────────────────────────────── */
.stat { text-align: center; }
.stat .val { font-size: 1.65rem; font-weight: 800; line-height: 1; }
.stat .lbl { font-size: .7rem; color: var(--text2); margin-top: 3px; }

/* ── Progress ────────────────────────────────────────────── */
.bar-wrap { background: var(--bg3); border-radius: 99px; height: 7px; overflow: hidden; }
.bar { height: 100%; border-radius: 99px; transition: width .5s ease; }

/* ── Forms ───────────────────────────────────────────────── */
label { display: block; font-size: .78rem; color: var(--text2); margin-bottom: 4px; }
input, textarea, select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 13px;
  font-size: .9rem;
  width: 100%;
  outline: none;
  transition: border-color .18s;
}
input:focus, textarea:focus, select:focus { border-color: var(--green); }
textarea { resize: vertical; min-height: 72px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > * { flex: 1; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: .88rem;
  cursor: pointer;
  font-weight: 600;
  transition: all .18s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-d); }
.btn-green:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: var(--bg3); color: var(--text2); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: #7f1d1d44; color: var(--red); border: 1px solid #7f1d1d66; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: .76rem; border-radius: 6px; }

/* ── Meal slot ───────────────────────────────────────────── */
.slot {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 10px;
  transition: border-color .2s;
}
.slot.filled { border-style: solid; }
.slot.slot-keto { border-color: var(--blue); }
.slot.slot-keto.filled { background: #38bdf808; }
.slot.slot-soir { border-color: var(--green); }
.slot.slot-soir.filled { background: #00c97a08; }
.slot.slot-generic { border-color: var(--purple); }
.slot.slot-generic.filled { background: #a78bfa08; }
.slot-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.slot-time { font-size: .75rem; color: var(--text2); background: var(--bg3); padding: 3px 9px; border-radius: 99px; }

/* ── Activity item ───────────────────────────────────────── */
.act-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--bg3); border-radius: 9px; margin-bottom: 7px; }
.act-item .info { flex: 1; }
.act-item .name { font-weight: 600; font-size: .88rem; }
.act-item .detail { font-size: .73rem; color: var(--text2); margin-top: 1px; }
.act-item .cal { font-weight: 700; color: var(--orange); font-size: .95rem; }

/* ── Fasting timer ───────────────────────────────────────── */
.fast-status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.fast-eating { background: #00c97a18; border: 1px solid var(--green); color: #86efac; }
.fast-fasting { background: #38bdf818; border: 1px solid var(--blue); color: #93c5fd; }

/* ── Chat ────────────────────────────────────────────────── */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 130px); background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-head { padding: 13px 17px; border-bottom: 1px solid var(--border); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 9px; }
.msg { max-width: 76%; padding: 10px 14px; border-radius: 12px; font-size: .87rem; line-height: 1.55; }
.msg.user { background: var(--green); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
.msg.bot { background: var(--bg3); align-self: flex-start; border-bottom-left-radius: 3px; }
.chat-in { display: flex; gap: 8px; padding: 11px 15px; border-top: 1px solid var(--border); }
.chat-in textarea { height: 41px; min-height: 41px; resize: none; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text2); display: inline-block; animation: bounce 1.2s infinite; margin: 0 2px; }
.typing span:nth-child(2){animation-delay:.2s}.typing span:nth-child(3){animation-delay:.4s}
@keyframes bounce{0%,60%,100%{transform:none}30%{transform:translateY(-5px)}}

/* ── Badges ──────────────────────────────────────────────── */
.badge { padding: 2px 8px; border-radius: 99px; font-size: .7rem; font-weight: 700; display: inline-block; }
.bg  { background:#14532d; color:#86efac; }
.bo  { background:#7c2d12; color:#fdba74; }
.br  { background:#7f1d1d; color:#fca5a5; }
.bb  { background:#1e3a5f; color:#93c5fd; }

/* ── Spinner / Toast ─────────────────────────────────────── */
.spin { display:inline-block;width:13px;height:13px;border:2px solid rgba(255,255,255,.3);border-top-color:#fff;border-radius:50%;animation:spin .55s linear infinite; }
@keyframes spin{to{transform:rotate(360deg)}}
#toast { position:fixed;bottom:18px;right:18px;background:var(--bg2);border:1px solid var(--border);padding:9px 16px;border-radius:9px;font-size:.85rem;opacity:0;transform:translateY(14px);transition:all .25s;z-index:999;pointer-events:none;max-width:280px; }
#toast.show { opacity:1;transform:none; }

/* ── History row ─────────────────────────────────────────── */
.hist-row { display:flex;justify-content:space-between;align-items:center;padding:9px 13px;background:var(--bg3);border-radius:9px;margin-bottom:6px; }

/* ── Advice box ──────────────────────────────────────────── */
.advice { background:var(--green-glow);border:1px solid var(--green-d);border-radius:var(--radius);padding:13px 15px; }
.advice-lbl { font-size:.68rem;text-transform:uppercase;letter-spacing:.08em;color:var(--green);margin-bottom:5px; }

/* ── Responsive ──────────────────────────────────────────── */
@media(max-width:640px){
  .g4{grid-template-columns:1fr 1fr}
  .g3{grid-template-columns:1fr 1fr}
  .g2{grid-template-columns:1fr}
  .nav-btn .lbl{display:none}
}
