/* ============================================================
   NutriTrack — Feuille de style (charte graphique appliquée)
   ============================================================ */
:root {
  --emerald: #10B981;
  --emerald-600: #059669;
  --emerald-300: #34D399;
  --amber: #F59E0B;
  --indigo: #6366F1;
  --sky: #0EA5E9;
  --rose: #FB7185;
  --slate-900: #0F172A;
  --slate-800: #1E293B;
  --slate-700: #334155;
  --slate-500: #64748B;
  --slate-300: #CBD5E1;
  --slate-100: #F1F5F9;
  --slate-50: #F8FAFC;
  --white: #FFFFFF;
  --red: #EF4444;
  --green: #22C55E;

  --grad: linear-gradient(135deg, #34D399 0%, #059669 100%);
  --radius-card: 16px;
  --radius-btn: 12px;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --font-head: 'Poppins', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
  font-family: var(--font-body);
  color: var(--slate-900);
  background: var(--slate-50);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .brand { font-family: var(--font-head); font-weight: 700; }
a { color: var(--emerald-600); text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Composants génériques ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: none;
  border-radius: var(--radius-btn); padding: 12px 20px;
  background: var(--grad); color: #fff; transition: 200ms ease;
}
.btn:hover { filter: brightness(1.05); box-shadow: var(--shadow-lg); }
.btn--ghost { background: transparent; color: var(--slate-700); border: 1px solid var(--slate-300); }
.btn--sm { padding: 8px 14px; font-size: .875rem; }
.btn--danger { background: var(--red); }

.input, select {
  font: inherit; width: 100%; padding: 12px 14px;
  border: 1px solid var(--slate-300); border-radius: var(--radius-btn);
  background: #fff; color: var(--slate-900); transition: 150ms ease;
}
.input:focus, select:focus { outline: none; border-color: var(--emerald); box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
label { font-size: .8rem; font-weight: 600; color: var(--slate-500); display: block; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.card {
  background: #fff; border-radius: var(--radius-card);
  box-shadow: var(--shadow); padding: 22px;
}
.card h3 { font-size: 1rem; margin-bottom: 14px; }
.muted { color: var(--slate-500); }
.tag { display:inline-block; font-size:.72rem; font-weight:600; padding:3px 10px; border-radius:999px; background:var(--slate-100); color:var(--slate-700);}
.tag--ok { background: #DCFCE7; color: #15803D; }
.tag--warn { background: #FEF3C7; color: #B45309; }

/* ---------- Logo ---------- */
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-row img { height: 38px; }

/* ============================================================
   PAGE AUTH (index.html)
   ============================================================ */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  background: var(--grad); color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-hero::after {
  content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%;
  background: rgba(255,255,255,.12); bottom: -120px; right: -120px;
}
.auth-hero h1 { font-size: 2.4rem; line-height: 1.15; margin-bottom: 16px; }
.auth-hero p { opacity: .92; max-width: 380px; }
.auth-hero .features { list-style: none; margin-top: 28px; }
.auth-hero .features li { margin-bottom: 12px; display: flex; gap: 10px; align-items: center; }
.auth-hero .features li::before { content: '✓'; background: rgba(255,255,255,.25); border-radius: 50%; width: 24px; height: 24px; display:grid; place-items:center; flex:0 0 24px; }
.auth-panel { display: grid; place-items: center; padding: 40px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h2 { font-size: 1.6rem; margin-bottom: 6px; }
.tabs { display: flex; gap: 6px; background: var(--slate-100); border-radius: var(--radius-btn); padding: 4px; margin: 22px 0; }
.tabs button { flex: 1; border: none; background: none; font: inherit; font-weight: 600; padding: 9px; border-radius: 9px; cursor: pointer; color: var(--slate-500); }
.tabs button.active { background: #fff; color: var(--emerald-600); box-shadow: var(--shadow); }
.alert { padding: 10px 14px; border-radius: 10px; font-size: .85rem; margin-bottom: 14px; display: none; }
.alert--err { background: #FEE2E2; color: #B91C1C; display: block; }
.alert--ok { background: #DCFCE7; color: #15803D; display: block; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ============================================================
   DASHBOARD (dashboard.html)
   ============================================================ */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--slate-900); color: #fff; padding: 24px 18px; display: flex; flex-direction: column; }
.sidebar .brand-row img { filter: brightness(0) invert(1); opacity:.96; }
.sidebar nav { margin-top: 34px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a { color: #CBD5E1; padding: 11px 14px; border-radius: 10px; font-weight: 500; display: flex; gap: 10px; }
.sidebar nav a.active, .sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar .userbox { font-size: .82rem; color: #94A3B8; border-top: 1px solid rgba(255,255,255,.1); padding-top: 16px; }

.main { padding: 28px 34px; max-width: 1200px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.topbar h1 { font-size: 1.5rem; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi { background:#fff; border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 18px; }
.kpi .label { font-size: .76rem; color: var(--slate-500); font-weight:600; text-transform: uppercase; letter-spacing:.04em; }
.kpi .value { font-family: var(--font-head); font-size: 1.7rem; margin-top: 4px; }
.kpi .value small { font-size: .85rem; color: var(--slate-500); font-weight:500; }

.dash-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; margin-bottom: 18px; }
/* Conteneurs de graphiques à hauteur fixe — évite la boucle de redimensionnement
   de Chart.js (canvas sans hauteur définie => CPU à 100 %, navigateur figé). */
.chart-box { position: relative; width: 100%; height: 240px; }
.chart-box.pie { height: 230px; }
.ring-box { position: relative; width: 170px; height: 170px; flex: 0 0 170px; }
.ring-wrap { display:flex; align-items:center; gap: 24px; }
.macro-row { display:flex; justify-content:space-between; font-size:.9rem; padding:7px 0; border-bottom:1px solid var(--slate-100); }
.macro-row span:first-child { display:flex; align-items:center; gap:8px; }
.dot { width:10px; height:10px; border-radius:50%; display:inline-block; }

/* Repas */
.meal { margin-bottom: 14px; }
.meal-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.meal-head h4 { font-family: var(--font-head); font-size: .95rem; }
.item-row { display:flex; justify-content:space-between; align-items:center; padding:8px 12px; background:var(--slate-50); border-radius:10px; margin-bottom:6px; font-size:.88rem; }
.item-row .x { cursor:pointer; color:var(--slate-500); font-weight:700; }
.item-row .x:hover { color: var(--red); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display:none; place-items:center; z-index:50; }
.modal-bg.open { display: grid; }
.modal { background:#fff; border-radius: var(--radius-card); padding: 24px; width: 92%; max-width: 460px; box-shadow: var(--shadow-lg); }
.modal h3 { margin-bottom: 14px; }
.results { max-height: 240px; overflow:auto; margin-top: 10px; }
.results .res { padding:10px 12px; border-radius:10px; cursor:pointer; display:flex; justify-content:space-between; }
.results .res:hover { background: var(--slate-100); }

@media (max-width: 980px) { .kpis { grid-template-columns: repeat(2,1fr);} .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .app { grid-template-columns: 1fr; } .sidebar { display:none; } }
