/* === Variables === */
:root {
  --bg-main: #0d0d1a;
  --bg-card: #12122a;
  --bg-elevated: #1e1e3a;
  --bg-input: #0f3460;
  --border: #1e1e3a;
  --text: #eee;
  --text-muted: #888;
  --sleep: #e94560;
  --nutrition: #00b4d8;
  --activity: #06d6a0;
  --wellbeing: #f9c74f;
  --sidebar-width: 220px;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg-main); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; height: 100vh; overflow: hidden; }

/* === Shell === */
.app-shell { display: flex; height: 100vh; }

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  flex-shrink: 0;
}
.sidebar-logo { padding: 0 20px 24px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.sidebar-logo h1 { font-size: 15px; color: #fff; font-weight: 700; }
.sidebar-logo p { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.sidebar-footer { margin-top: auto; padding: 16px 20px; border-top: 1px solid var(--border); }

/* === Nav items === */
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 8px;
  font-size: 13px; color: var(--text-muted);
  background: none; border: none; cursor: pointer; text-align: left; width: 100%;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-elevated); color: #ccc; }
.nav-item.active { background: #1e1e4a; color: #fff; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

/* === Install button === */
.install-btn {
  width: 100%; background: linear-gradient(135deg, var(--sleep), #c73652);
  color: #fff; border: none; border-radius: 8px;
  padding: 10px; font-size: 12px; cursor: pointer; font-weight: 600;
}

/* === Mobile nav (hidden on desktop) === */
.mobile-nav { display: none; }

/* === Main === */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar {
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 16px 24px; display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.topbar h2 { font-size: 16px; color: #fff; }
.date-sub { font-size: 11px; color: var(--text-muted); }
.score-badge {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 20px; padding: 6px 14px; font-size: 12px; color: #ccc;
}
.score-badge span { color: var(--activity); font-weight: bold; }

/* === Views === */
.view { display: none; flex: 1; overflow-y: auto; padding: 20px 24px; }
.view.active { display: block; }

/* === Categories grid === */
.categories-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* === Category card === */
.cat-card {
  background: var(--bg-card); border-radius: 14px;
  padding: 18px; border: 1px solid var(--border);
}
.cat-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.cat-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.cat-title { font-size: 13px; font-weight: 700; }
.cat-sub { font-size: 10px; color: var(--text-muted); }

/* === Widgets communs === */
.widget-label { font-size: 10px; color: var(--text-muted); margin-bottom: 6px; }

/* Counter +/- */
.counter-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.counter-label { font-size: 10px; color: var(--text-muted); flex: 1; }
.counter-btn {
  width: 28px; height: 28px; background: var(--bg-elevated);
  border: none; border-radius: 8px; color: #fff; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.1s;
}
.counter-btn:hover { background: #2a2a5a; }
.counter-val { font-size: 15px; font-weight: bold; color: #fff; min-width: 52px; text-align: center; }

/* Stars */
.stars { display: flex; gap: 4px; }
.star { font-size: 20px; cursor: pointer; filter: grayscale(1); opacity: 0.3; transition: all 0.1s; }
.star.active { filter: none; opacity: 1; }

/* Water cups */
.water-cups { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.water-cup { font-size: 22px; cursor: pointer; filter: grayscale(1); opacity: 0.25; transition: all 0.1s; }
.water-cup.filled { filter: none; opacity: 1; }

/* Progress bar */
.progress-wrap { background: var(--bg-elevated); border-radius: 6px; height: 6px; margin-top: 4px; }
.progress-fill { height: 6px; border-radius: 6px; transition: width 0.3s; }

/* Chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 4px 10px; border-radius: 20px; font-size: 10px; cursor: pointer;
  border: 1px solid var(--activity); color: var(--activity); background: transparent;
  transition: all 0.1s;
}
.chip.active { background: var(--activity); color: #0d0d1a; font-weight: 700; }

/* Mood icons */
.mood-icons { display: flex; gap: 8px; margin-bottom: 12px; justify-content: space-between; }
.mood-icon { font-size: 24px; cursor: pointer; opacity: 0.25; transition: all 0.1s; }
.mood-icon.active { opacity: 1; transform: scale(1.2); }

/* Slider */
.slider-row { margin-bottom: 10px; }
.slider-header { font-size: 10px; color: var(--text-muted); display: flex; justify-content: space-between; margin-bottom: 4px; }
input[type="range"] { width: 100%; accent-color: var(--wellbeing); cursor: pointer; }

/* Toggle */
.toggle-row { display: flex; align-items: center; gap: 8px; }
.toggle-label { font-size: 11px; color: var(--text-muted); flex: 1; }
.toggle { display: flex; gap: 6px; }
.toggle-btn {
  padding: 4px 12px; border-radius: 6px; font-size: 10px;
  border: 1px solid var(--border); cursor: pointer;
  background: var(--bg-elevated); color: var(--text-muted); transition: all 0.1s;
}
.toggle-btn.on { background: var(--wellbeing); color: #1a1a1a; border-color: var(--wellbeing); font-weight: 700; }

/* === Dashboard === */
.dashboard-controls { display: flex; gap: 8px; margin-bottom: 20px; }
.period-btn {
  padding: 6px 16px; border-radius: 20px; font-size: 12px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-muted);
}
.period-btn.active { background: var(--bg-input); color: #fff; border-color: var(--nutrition); }
.chart-block { background: var(--bg-card); border-radius: 14px; padding: 16px; margin-bottom: 16px; border: 1px solid var(--border); }
.chart-title { font-size: 13px; font-weight: 700; margin-bottom: 12px; }

/* === Historique === */
.history-actions {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
  padding: 12px 16px; background: var(--bg-card); border-radius: 10px; border: 1px solid var(--border);
}
.history-actions label { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.history-actions input[type="date"] {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px;
  color: #fff; padding: 4px 8px; font-size: 12px;
}
.danger-btn {
  background: var(--sleep); color: #fff; border: none; border-radius: 8px;
  padding: 6px 14px; font-size: 12px; cursor: pointer; font-weight: 600;
}
.history-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card); border-radius: 10px; padding: 12px 16px; border: 1px solid var(--border);
}
.history-date { font-size: 13px; font-weight: 600; color: #fff; flex: 1; }
.history-summary { font-size: 11px; color: var(--text-muted); }
.delete-btn {
  background: none; border: none; color: var(--text-muted); font-size: 18px;
  cursor: pointer; padding: 4px; border-radius: 6px; transition: color 0.1s;
}
.delete-btn:hover { color: var(--sleep); }

/* === Responsive mobile === */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg-card); border-top: 1px solid var(--border);
    z-index: 100;
  }
  .mobile-nav .nav-item {
    flex: 1; flex-direction: column; gap: 2px; padding: 8px 4px;
    font-size: 10px; justify-content: center;
  }
  .mobile-nav .nav-icon { font-size: 22px; width: auto; }
  .main { padding-bottom: 60px; }
  .categories-grid { grid-template-columns: 1fr; }
  .view { padding: 12px 16px; }
}
