/* ============================================================
   NUTRITRACK — Styles (mobile-first, dark sporty)
   ============================================================ */
:root {
  --bg: #0d1117;
  --bg-soft: #141b26;
  --card: #1a2332;
  --card-2: #202c40;
  --border: #2a3850;
  --text: #e8eef7;
  --text-dim: #8fa1b8;
  --accent: #7ee081;
  --accent-2: #22c55e;
  --orange: #fbbf24;
  --blue: #60a5fa;
  --pink: #f472b6;
  --danger: #f87171;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  background-image: radial-gradient(1200px 600px at 80% -10%, rgba(34, 197, 94, 0.08), transparent),
                    radial-gradient(900px 500px at -10% 10%, rgba(96, 165, 250, 0.06), transparent);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

body { padding-bottom: 24px; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-emoji { font-size: 28px; }
.app-header h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.3px; }
.tagline { font-size: 11px; color: var(--text-dim); margin-top: 1px; }

.btn-icon {
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  width: 42px; height: 42px; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, background .15s;
}
.btn-icon:active { transform: scale(0.92); }

/* ---------- Calendrier ---------- */
.calendar {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 12px 8px;
  background: linear-gradient(180deg, rgba(13,17,23,0.95), rgba(13,17,23,0.6));
  position: sticky; top: 66px; z-index: 40;
  backdrop-filter: blur(8px);
}
.cal-nav {
  flex: 0 0 auto;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.cal-nav:active { transform: scale(0.9); }
.cal-wrap { flex: 1; min-width: 0; }
.cal-month {
  font-size: 12px; font-weight: 700; color: var(--text-dim);
  text-align: center; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.6px;
}
.cal-days {
  display: flex; gap: 5px; overflow-x: auto;
  scrollbar-width: none; padding-bottom: 4px;
  scroll-snap-type: x proximity;
}
.cal-days::-webkit-scrollbar { display: none; }

.day {
  flex: 0 0 auto; width: 52px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 6px;
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: 14px; cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s;
  scroll-snap-align: center;
  user-select: none;
}
.day:active { transform: scale(0.94); }
.day .d-name { font-size: 10px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; }
.day .d-num { font-size: 17px; font-weight: 800; }
.day .d-kcal {
  font-size: 9.5px; color: var(--accent); font-weight: 700;
  background: rgba(126, 224, 129, 0.1); border-radius: 8px; padding: 1px 6px;
  max-width: 46px; overflow: hidden; white-space: nowrap;
}
.day .d-kcal.empty { color: transparent; background: none; }
.day.today { border-color: var(--accent); background: rgba(126, 224, 129, 0.08); }
.day.today .d-num { color: var(--accent); }
.day.selected { border-color: var(--accent-2); background: rgba(34, 197, 94, 0.18); box-shadow: 0 0 0 3px rgba(34,197,94,0.15); }
.day.weekend .d-name { color: var(--orange); }

/* ---------- Main ---------- */
main { padding: 10px 14px; display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin: 0 auto; }

.date-title {
  font-size: 17px; font-weight: 800;
  padding: 4px 2px;
  display: flex; align-items: center; gap: 8px;
}
.date-title .rel { font-size: 12px; font-weight: 600; color: var(--accent); background: rgba(126,224,129,0.12); padding: 3px 10px; border-radius: 20px; }

/* ---------- Summary ---------- */
.summary {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.stat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
}
.stat .s-top { display: flex; justify-content: space-between; align-items: baseline; }
.stat .s-label { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.stat .s-value { font-size: 15px; font-weight: 800; }
.stat .s-value .unit { font-size: 11px; color: var(--text-dim); font-weight: 600; margin-left: 2px; }
.stat .s-goal { font-size: 11px; color: var(--text-dim); }
.stat.main-stat { grid-column: 1 / -1; }
.stat.main-stat .s-value { font-size: 26px; }
.bar {
  margin-top: 8px; height: 8px; border-radius: 6px;
  background: var(--bg-soft); overflow: hidden;
}
.bar > i {
  display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width .4s ease;
  width: 0%;
}
.bar.over > i { background: linear-gradient(90deg, var(--orange), var(--danger)); }
.stat[data-key="proteines"] .bar > i { background: linear-gradient(90deg, #3b82f6, var(--blue)); }
.stat[data-key="glucides"] .bar > i { background: linear-gradient(90deg, #f59e0b, var(--orange)); }
.stat[data-key="lipides"] .bar > i { background: linear-gradient(90deg, #ec4899, var(--pink)); }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.card h2 { font-size: 15px; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.journal-date { color: var(--text-dim); font-weight: 600; font-size: 13px; }

/* ---------- Add meal ---------- */
.input-row { display: flex; gap: 8px; }
.input-row input {
  flex: 1; min-width: 0;
  background: var(--bg-soft); border: 1.5px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font-size: 15px; outline: none;
  transition: border-color .15s;
}
.input-row input:focus { border-color: var(--accent-2); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), #16a34a);
  color: #06250d; font-weight: 800; border: none;
  border-radius: 12px; padding: 0 18px; font-size: 14px; cursor: pointer;
  white-space: nowrap;
}
.btn-primary:active { transform: scale(0.96); }
.btn-ghost {
  background: var(--card-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
}

.suggestions { display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; scrollbar-width: none; }
.suggestions::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 20px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.chip:active { background: var(--card-2); color: var(--text); }

/* ---------- Estimation ---------- */
.estimation {
  margin-top: 12px; border: 1px solid rgba(126, 224, 129, 0.35);
  background: rgba(126, 224, 129, 0.05);
  border-radius: 14px; padding: 12px;
}
.estimation .est-title { font-size: 12px; font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.est-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--card-2); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px;
}
.est-item .ei-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.est-item input.qty {
  width: 64px; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 5px 6px; font-size: 13px; text-align: right; outline: none;
}
.est-item .ei-unit { font-size: 11px; color: var(--text-dim); width: 34px; }
.est-item .ei-macros { font-size: 10.5px; color: var(--text-dim); white-space: nowrap; }
.est-item .ei-macros b { color: var(--text); }
.est-total {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 700; margin-top: 8px;
}
.est-total .et-kcal { color: var(--accent); font-size: 16px; }
.est-actions { display: flex; gap: 8px; margin-top: 10px; }
.est-actions .btn-primary { flex: 1; padding: 10px; }

/* ---------- Journal ---------- */
.journal-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 9px 12px; margin-bottom: 8px;
}
.ji-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--accent-2); }
.ji-main { flex: 1; min-width: 0; }
.ji-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ji-macros { font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.ji-macros b { color: var(--text); }
.ji-qty { display: flex; align-items: center; gap: 4px; }
.ji-qty input {
  width: 58px; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 4px 5px; font-size: 13px; text-align: right; outline: none;
}
.ji-qty .ji-unit { font-size: 10.5px; color: var(--text-dim); }
.ji-kcal { font-size: 14px; font-weight: 800; color: var(--accent); min-width: 52px; text-align: right; }
.ji-del {
  background: none; border: none; color: var(--danger); font-size: 17px; cursor: pointer;
  padding: 4px; border-radius: 8px;
}
.ji-del:hover { background: rgba(248, 113, 113, 0.12); }

.empty { text-align: center; color: var(--text-dim); font-size: 13.5px; padding: 26px 10px; line-height: 1.6; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 8, 12, 0.7); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 520px; padding: 18px;
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-header h2 { font-size: 17px; }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-body label {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; font-weight: 700; color: var(--text-dim);
}
.modal-body label small { font-size: 10px; color: var(--text-dim); opacity: .8; }
.modal-body input {
  flex: 1; background: var(--bg-soft); border: 1.5px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 15px; font-weight: 700; outline: none; text-align: right;
}
.modal-body input:focus { border-color: var(--accent-2); }
.modal-footer { margin-top: 16px; display: flex; justify-content: flex-end; }
.modal-footer .btn-primary { padding: 12px 26px; }

.app-footer { text-align: center; color: var(--text-dim); font-size: 11px; padding: 18px 14px 6px; opacity: 0.8; }

@media (min-width: 560px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 20px; }
}
