/* ============================================
   StudyHub – CSS v2
   Mobile-first · Thèmes · Personnalisation
   ============================================ */

:root {
  /* Couleurs principales (overridées par JS) */
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --secondary: #06b6d4;
  /* Fonds (overridés par JS) */
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-card2: #16213e;
  --border: #2a2a4a;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-light: #cbd5e1;
  /* Couleurs fixes */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  /* Dimensions */
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --bottom-nav-h: 64px;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --glow: 0 0 20px rgba(99,102,241,0.3);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

/* Light theme overrides */
body.theme-light .card { box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
body.theme-light .topbar { background: rgba(241,245,249,0.92); }
body.theme-light .sidebar { border-right-color: var(--border); }
body.theme-light .notes-table th { background: #f8fafc; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width:5px; height:5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius:3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ===== MOBILE OVERLAY ===== */
.mobile-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
  backdrop-filter: blur(2px);
}
.mobile-overlay.active { display: block; }

/* ========== SIDEBAR ========== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: width 0.3s ease, transform 0.3s ease;
  overflow: hidden;
}

.sidebar.collapsed { width: 70px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  min-width: 0;
}

.logo-icon { font-size: 1.4rem; flex-shrink: 0; }

.logo-text {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  transition: opacity 0.3s;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-details,
.sidebar.collapsed .user-info i { opacity:0; width:0; overflow:hidden; }

.sidebar-toggle {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 1rem; padding: 0.35rem;
  border-radius: 8px; transition: all 0.2s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--border); color: var(--text); }

.nav-menu {
  flex: 1; list-style: none;
  padding: 0.75rem 0.65rem;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 3px;
}

.nav-item {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.88rem; font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
}

.nav-item i { font-size: 0.95rem; width: 18px; text-align: center; flex-shrink: 0; }

.nav-item:hover { background: rgba(99,102,241,0.1); color: var(--text); }

.nav-item.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(6,182,212,0.08));
  color: var(--primary-light);
  box-shadow: inset 3px 0 0 var(--primary);
}

.sidebar-footer {
  padding: 0.85rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-info {
  display: flex; align-items: center; gap: 0.65rem;
  cursor: pointer; padding: 0.5rem; border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.user-info:hover { background: rgba(99,102,241,0.1); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}

.user-details { display: flex; flex-direction: column; overflow: hidden; transition: all 0.3s; }

.user-name { font-weight: 600; font-size: 0.83rem; white-space: nowrap; }
.user-level { font-size: 0.72rem; color: var(--text-muted); }

/* ========== MAIN CONTENT ========== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
  padding-bottom: 0;
}
.main-content.expanded { margin-left: 70px; }

/* ========== TOPBAR ========== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  background: rgba(15,15,26,0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 1.25rem; gap: 0.75rem;
}

.menu-btn {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 1.05rem; padding: 0.45rem;
  border-radius: 8px; display: none;
  transition: all 0.2s;
}
.menu-btn:hover { background: var(--border); color: var(--text); }

.page-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem; font-weight: 600; flex: 1;
}

.topbar-right {
  display: flex; align-items: center; gap: 0.75rem;
}

.date-display {
  font-size: 0.8rem; color: var(--text-muted);
  background: var(--bg-card);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.topbar-avatar-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: transform 0.2s, box-shadow 0.2s;
}
.topbar-avatar-btn:hover { transform: scale(1.08); box-shadow: var(--glow); }

/* ========== PAGES ========== */
.page {
  display: none; padding: 1.25rem;
  flex: 1; animation: fadeInUp 0.3s ease;
}
.page.active { display: block; }

@keyframes fadeInUp {
  from { opacity:0; transform:translateY(10px); }
  to { opacity:1; transform:translateY(0); }
}

/* ========== PAGE HEADER ========== */
.page-header { margin-bottom: 1.25rem; }

.page-header h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem; font-weight: 700;
  background: linear-gradient(135deg, var(--text), var(--primary-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-header p { color: var(--text-muted); margin-top: 0.25rem; font-size: 0.88rem; }

.flex-between { display:flex; align-items:flex-start; justify-content:space-between; flex-wrap:wrap; gap:0.75rem; }

/* ========== PROFILE BANNER ========== */
.profile-banner {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary), var(--secondary));
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
}

.profile-banner::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.profile-banner-content {
  display: flex; align-items: center; gap: 1rem; position: relative;
}

.profile-banner-avatar {
  font-size: 3rem; flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.profile-banner-info h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem; font-weight: 700; color: #fff;
  background: none; -webkit-text-fill-color: #fff;
  margin: 0;
}

.profile-banner-info p { color: rgba(255,255,255,0.8); font-size: 0.85rem; margin-top: 0.2rem; }

.objectif-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.2rem 0.7rem;
  border-radius: 20px;
  margin-top: 0.4rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.objectif-bar-wrap {
  margin-top: 1rem; position: relative;
}

.objectif-bar-track {
  height: 6px; background: rgba(255,255,255,0.2);
  border-radius: 3px; overflow: hidden;
}

.objectif-bar-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.8s ease;
  background: rgba(255,255,255,0.85);
}

.objectif-bar-label {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.7);
  margin-top: 0.3rem;
  display: block;
}

/* ========== STATS GRID ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  display: flex; align-items: center; gap: 0.85rem;
  position: relative; overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card::before {
  content: ''; position: absolute; top:0; left:0; right:0; height:3px;
}
.stat-primary::before { background: linear-gradient(90deg, var(--primary), var(--secondary)); }
.stat-success::before { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-warning::before { background: linear-gradient(90deg, var(--warning), #fcd34d); }
.stat-info::before    { background: linear-gradient(90deg, var(--info), var(--secondary)); }

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
  width: 44px; height: 44px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.stat-primary .stat-icon { background: rgba(99,102,241,0.15); color: var(--primary-light); }
.stat-success .stat-icon { background: rgba(16,185,129,0.15); color: var(--success); }
.stat-warning .stat-icon { background: rgba(245,158,11,0.15); color: var(--warning); }
.stat-info    .stat-icon { background: rgba(59,130,246,0.15); color: var(--info); }

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.55rem; font-weight: 700; line-height: 1;
}

.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ========== DASHBOARD GRID ========== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
}

/* ========== CARDS ========== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover { border-color: rgba(99,102,241,0.3); }

.card-header {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 {
  font-size: 0.9rem; font-weight: 600;
  display: flex; align-items: center; gap: 0.45rem;
}
.card-header h3 i { color: var(--primary-light); }

.card-body { padding: 1.1rem; }
.card-body.p0 { padding: 0; }

/* ========== MOTIVATION CARD ========== */
.motivation-card {
  background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(6,182,212,0.08));
  border: 1px solid rgba(99,102,241,0.25);
}

.motivation-content {
  padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}

.motivation-icon { font-size: 2.2rem; flex-shrink: 0; }

.motivation-quote {
  font-size: 0.88rem; line-height: 1.6;
  font-style: italic; color: var(--text-light);
}

/* ========== MINI LISTS ========== */
.mini-task-list { display: flex; flex-direction: column; gap: 0.5rem; }

.mini-task {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg); border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  font-size: 0.83rem; cursor: pointer;
  transition: transform 0.15s;
}
.mini-task:hover { transform: translateX(3px); }
.mini-task.urgent { border-left-color: var(--danger); }
.mini-task.medium { border-left-color: var(--warning); }
.mini-task.low    { border-left-color: var(--success); }

.mini-task-title { font-weight: 500; flex: 1; }
.mini-task-date  { font-size: 0.73rem; color: var(--text-muted); white-space: nowrap; }
.mini-task-date.overdue { color: var(--danger); }

.mini-schedule { display: flex; flex-direction: column; gap: 0.45rem; }

.mini-cours {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.55rem 0.8rem;
  background: var(--bg); border-radius: var(--radius-sm);
  font-size: 0.83rem;
}
.mini-cours-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.mini-cours-info { flex: 1; }
.mini-cours-name { font-weight: 500; }
.mini-cours-time, .mini-cours-salle { font-size: 0.73rem; color: var(--text-muted); }

/* ========== NOTES SUMMARY ========== */
.notes-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem; text-align: center;
}

.summary-label {
  font-size: 0.73rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.4rem;
}

.summary-value { font-family: 'Space Grotesk', sans-serif; font-size: 1.8rem; font-weight: 700; }
.summary-value.green { color: var(--success); }
.summary-value.red   { color: var(--danger); }

.summary-bar {
  height: 4px; background: var(--border);
  border-radius: 2px; margin-top: 0.6rem; overflow: hidden;
}
.summary-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.8s ease;
}

/* ========== BADGE MOYENNE ========== */
.badge-moyenne {
  display: inline-block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem; padding: 0.2rem 0.65rem;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white; -webkit-text-fill-color: white;
  vertical-align: middle; margin-left: 0.5rem;
}

/* ========== FILTER BAR ========== */
.filter-bar {
  display: flex; gap: 0.65rem; margin-bottom: 0.9rem; flex-wrap: wrap;
}

.filter-bar input,
.filter-bar select {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.55rem 0.9rem;
  color: var(--text); font-size: 0.83rem; outline: none;
  transition: border-color 0.2s; font-family: inherit;
}
.filter-bar input { min-width: 150px; flex: 1; }
.filter-bar input:focus,
.filter-bar select:focus { border-color: var(--primary); }

/* ========== TABLE ========== */
.table-scroll { overflow-x: auto; }

.notes-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }

.notes-table th {
  background: var(--bg); padding: 0.8rem 0.9rem;
  text-align: left; font-weight: 600;
  font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted);
  position: sticky; top: 0; z-index: 2;
  white-space: nowrap;
}

.notes-table td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.notes-table tr:last-child td { border-bottom: none; }
.notes-table tr:hover td { background: rgba(99,102,241,0.04); }

.note-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 38px; border-radius: 9px;
  font-weight: 700; font-size: 0.88rem; padding: 0 0.4rem;
}
.note-excellent  { background: rgba(16,185,129,0.15); color: var(--success); }
.note-bien       { background: rgba(99,102,241,0.15); color: var(--primary-light); }
.note-moyen      { background: rgba(245,158,11,0.15); color: var(--warning); }
.note-insuffisant{ background: rgba(239,68,68,0.15);  color: var(--danger); }

.type-badge {
  display: inline-block; padding: 0.18rem 0.55rem;
  border-radius: 6px; font-size: 0.72rem; font-weight: 600;
  background: rgba(99,102,241,0.12); color: var(--primary-light);
}

.matiere-chip { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 500; }
.matiere-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.loading-row { text-align: center; padding: 2rem; color: var(--text-muted); }

/* ========== TASK TABS ========== */
.task-tabs { display: flex; gap: 0.45rem; margin-bottom: 1.1rem; flex-wrap: wrap; }

.task-tab {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-muted); padding: 0.5rem 1.1rem;
  border-radius: 20px; cursor: pointer;
  font-size: 0.83rem; font-weight: 500; transition: all 0.2s;
}
.task-tab:hover { color: var(--text); border-color: var(--primary); }
.task-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: var(--primary); color: white;
}

/* ========== TASKS GRID ========== */
.tasks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.9rem;
}

.task-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem;
  position: relative; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.task-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: rgba(99,102,241,0.35); }
.task-card.done { opacity: 0.6; }
.task-card.done .task-title { text-decoration: line-through; }

.task-priority-bar {
  position: absolute; top:0; left:0; right:0; height:3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.priority-haute .task-priority-bar  { background: var(--danger); }
.priority-moyenne .task-priority-bar { background: var(--warning); }
.priority-basse .task-priority-bar  { background: var(--success); }

.task-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; margin-top: 0.2rem; }
.task-title  { font-weight: 600; font-size: 0.92rem; line-height: 1.4; flex: 1; }

.task-check {
  width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--border); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.2s;
}
.task-check.checked { background: var(--success); border-color: var(--success); color: white; }
.task-check:hover { border-color: var(--primary); }

.task-meta { display: flex; align-items: center; gap: 0.65rem; margin-top: 0.7rem; flex-wrap: wrap; }

.task-matiere {
  font-size: 0.75rem; padding: 0.18rem 0.55rem;
  border-radius: 6px; background: rgba(99,102,241,0.1);
  color: var(--primary-light); font-weight: 500;
}

.task-date { font-size: 0.75rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.3rem; }
.task-date.overdue { color: var(--danger); }

.task-description { font-size: 0.81rem; color: var(--text-muted); margin-top: 0.45rem; line-height: 1.5; }

.task-actions {
  display: flex; gap: 0.5rem;
  margin-top: 0.9rem; padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.task-status-badge {
  font-size: 0.7rem; padding: 0.18rem 0.55rem;
  border-radius: 20px; font-weight: 600; margin-left: auto;
}
.status-a_faire { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-en_cours { background: rgba(59,130,246,0.15); color: var(--info); }
.status-termine  { background: rgba(16,185,129,0.15); color: var(--success); }

/* ========== SCHEDULE ========== */
.schedule-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.schedule-header {
  display: grid; grid-template-columns: 60px repeat(6, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 5;
  min-width: 600px;
}

.day-col {
  padding: 0.75rem 0.5rem; text-align: center;
  font-size: 0.76rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); border-left: 1px solid var(--border);
}
.day-col.today { color: var(--primary-light); }

.time-col { padding: 0.75rem 0.5rem; }

.schedule-body { min-width: 600px; }

.day-column { border-left: 1px solid var(--border); position: relative; }

.schedule-hour-line {
  position: absolute; left:0; right:0; height:1px;
  background: var(--border); opacity: 0.4;
}

.cours-block {
  position: absolute; left: 3px; right: 3px;
  border-radius: 7px; padding: 0.35rem 0.5rem;
  font-size: 0.75rem; overflow: hidden;
  cursor: pointer; transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.cours-block:hover { opacity: 0.9; transform: scale(1.01); }
.cours-block-name { font-weight: 600; line-height: 1.3; }
.cours-block-time { font-size: 0.68rem; opacity: 0.85; margin-top: 1px; }
.cours-block-salle { font-size: 0.68rem; opacity: 0.75; display: flex; align-items: center; gap: 0.2rem; margin-top: 1px; }

.cours-delete-btn {
  position: absolute; top: 3px; right: 3px;
  width: 16px; height: 16px;
  background: rgba(0,0,0,0.35); border: none; border-radius: 50%;
  color: white; cursor: pointer; font-size: 0.55rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s;
}
.cours-block:hover .cours-delete-btn { opacity: 1; }

/* ========== POMODORO ========== */
.pomodoro-layout {
  display: grid; grid-template-columns: 1fr 310px; gap: 1.25rem; align-items: start;
}

.pomodoro-modes {
  display: flex; gap: 0.65rem; margin-bottom: 1.5rem;
  justify-content: center; flex-wrap: wrap;
}

.mode-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-muted); padding: 0.55rem 1.1rem;
  border-radius: 30px; cursor: pointer;
  font-size: 0.82rem; font-weight: 500; transition: all 0.2s;
  display: flex; align-items: center; gap: 0.45rem;
}
.mode-btn:hover { color: var(--text); border-color: var(--primary); }
.mode-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: transparent; color: white; box-shadow: var(--glow);
}

.timer-card {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2.5rem 2rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 1.25rem;
  overflow: hidden; min-height: 280px;
}

.timer-bg { position: absolute; inset: 0; transition: background 1s ease; opacity: 0.08; }

.timer-progress {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}

.progress-ring { width: 260px; height: 260px; transform: rotate(-90deg); }

.ring-bg { fill: none; stroke: var(--border); stroke-width: 6; }
.ring-progress {
  fill: none; stroke: var(--primary); stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 565.48; stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.5s;
}

.timer-display {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 4.5rem; font-weight: 700;
  letter-spacing: -2px; z-index: 1; line-height: 1;
}

.timer-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.4rem; z-index: 1; }

.timer-controls {
  display: flex; align-items: center; justify-content: center;
  gap: 1.25rem; margin-bottom: 1.25rem;
}

.timer-btn {
  border: none; cursor: pointer; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}

.timer-btn.primary {
  width: 66px; height: 66px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; font-size: 1.3rem;
  box-shadow: var(--glow);
}
.timer-btn.primary:hover { transform: scale(1.06); }

.timer-btn.secondary {
  width: 46px; height: 46px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-muted);
}
.timer-btn.secondary:hover { border-color: var(--primary); color: var(--text); }

.session-counter {
  display: flex; align-items: center; gap: 0.65rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.85rem 1.25rem;
}

.session-label { font-size: 0.82rem; color: var(--text-muted); }

.session-dots { display: flex; gap: 0.35rem; }

.session-dot {
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--border); transition: all 0.3s;
}
.session-dot.done {
  background: var(--primary); border-color: var(--primary);
  box-shadow: 0 0 6px rgba(99,102,241,0.5);
}

.session-count { font-weight: 600; font-size: 0.82rem; margin-left: auto; }

.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 0.65rem;
}
.setting-row label { font-size: 0.82rem; color: var(--text-muted); }

.setting-row input[type="number"],
.setting-row input[type="text"] {
  width: 95px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.4rem 0.65rem;
  color: var(--text); font-size: 0.82rem; outline: none; text-align: center;
  font-family: inherit;
}

.setting-toggle {
  display: flex; align-items: center; gap: 0.65rem;
  cursor: pointer; font-size: 0.82rem; color: var(--text-muted);
  margin-top: 0.5rem;
}
.setting-toggle input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; }

.pomo-stat {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.45rem 0; font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
}
.pomo-stat:last-child { border-bottom: none; }
.pomo-stat i { color: var(--primary-light); width: 14px; }
.pomo-stat span { color: var(--text-muted); flex: 1; }

/* ========== PLANNING ========== */
.week-days {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.45rem;
}

.week-day {
  text-align: center; padding: 0.65rem 0.35rem;
  border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border);
}
.week-day.has-session { border-color: var(--primary); background: rgba(99,102,241,0.1); }
.week-day.today {
  background: rgba(99,102,241,0.2); border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99,102,241,0.3);
}

.week-day-label { font-size: 0.67rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.week-day-num   { font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 700; margin: 0.2rem 0; }
.week-day-min   { font-size: 0.67rem; color: var(--primary-light); }

.sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.9rem; margin-top: 1.1rem;
}

.session-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem;
  transition: transform 0.2s, box-shadow 0.2s;
}
.session-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.session-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.65rem;
}
.session-matiere { font-weight: 600; font-size: 0.95rem; }
.session-humeur  { font-size: 1.2rem; }

.session-meta {
  display: flex; gap: 0.85rem; margin-bottom: 0.65rem; flex-wrap: wrap;
}
.session-meta-item {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.8rem; color: var(--text-muted);
}
.session-meta-item i { color: var(--primary-light); font-size: 0.72rem; }

.session-notes {
  font-size: 0.8rem; color: var(--text-muted); line-height: 1.5;
  padding: 0.65rem; background: var(--bg); border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.6rem 1.15rem; border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  font-size: 0.85rem; font-weight: 500;
  transition: all 0.2s; font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(99,102,241,0.4); }

.btn-secondary {
  background: var(--bg-card); color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text); border-color: var(--primary); }

.btn-danger {
  background: rgba(239,68,68,0.12); color: var(--danger);
  border: 1px solid rgba(239,68,68,0.25);
}
.btn-danger:hover { background: rgba(239,68,68,0.22); }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.76rem; }

.btn-link {
  background: none; border: none; color: var(--primary-light);
  cursor: pointer; font-size: 0.8rem; padding: 0;
}
.btn-link:hover { color: var(--primary); text-decoration: underline; }

.btn-icon {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text-muted);
  cursor: pointer; font-size: 0.77rem; transition: all 0.2s;
}
.btn-icon:hover { border-color: var(--primary); color: var(--primary-light); }
.btn-icon.delete:hover { border-color: var(--danger); color: var(--danger); }

/* ========== MODALS ========== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(4px);
  z-index: 200; display: none;
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 500px;
  max-height: 92vh; overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal-wide { max-width: 620px; }

@keyframes slideUp {
  from { opacity:0; transform: translateY(18px); }
  to   { opacity:1; transform: translateY(0); }
}

.modal-header {
  padding: 1.1rem 1.35rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--bg-card); z-index: 2;
}

.modal-header h3 { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 1rem; }

.modal-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1rem; padding: 0.35rem;
  border-radius: 8px; transition: all 0.2s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
  padding: 1.35rem;
  display: flex; flex-direction: column; gap: 0.9rem;
}

.modal-footer {
  padding: 1.1rem 1.35rem; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 0.65rem;
  position: sticky; bottom: 0; background: var(--bg-card);
}

/* ========== PROFIL MODAL ========== */
.profil-avatar-preview {
  display: flex; align-items: center; gap: 1.25rem;
  padding: 1rem; background: var(--bg); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.profil-avatar-big {
  font-size: 3rem; width: 68px; height: 68px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}

.avatar-grid {
  display: flex; flex-wrap: wrap; gap: 0.4rem; max-width: 320px;
}

.avatar-btn {
  width: 36px; height: 36px; border-radius: 8px;
  border: 2px solid var(--border); background: var(--bg);
  cursor: pointer; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.avatar-btn:hover { border-color: var(--primary); transform: scale(1.1); }
.avatar-btn.active { border-color: var(--primary); background: rgba(99,102,241,0.15); box-shadow: 0 0 0 2px var(--primary); }

/* Theme swatches */
.theme-swatches { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.theme-swatch {
  width: 34px; height: 34px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  transition: all 0.2s; position: relative;
}
.theme-swatch:hover { transform: scale(1.12); }
.theme-swatch.active {
  border-color: white;
  box-shadow: 0 0 0 3px var(--primary), 0 0 10px rgba(99,102,241,0.4);
}

/* Bg swatches */
.bg-swatches { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.bg-swatch {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.85rem; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--bg);
  cursor: pointer; font-size: 0.8rem; color: var(--text-muted);
  transition: all 0.2s;
}
.bg-swatch:hover { border-color: var(--primary); color: var(--text); }
.bg-swatch.active { border-color: var(--primary); color: var(--text); background: rgba(99,102,241,0.1); }

.bg-preview {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
}

/* ========== FORMS ========== */
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }

.form-group label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.6rem 0.85rem;
  color: var(--text); font-size: 0.88rem; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: 'Inter', sans-serif;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.form-group textarea { resize: vertical; min-height: 75px; }

.color-picker { display: flex; align-items: center; gap: 0.65rem; }
.color-picker input[type="color"] {
  width: 38px; height: 38px; padding: 2px;
  border-radius: 8px; cursor: pointer; border: 1px solid var(--border);
}

/* ========== TOAST ========== */
.toast {
  position: fixed; bottom: calc(var(--bottom-nav-h) + 0.75rem); right: 1rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.8rem 1.1rem;
  font-size: 0.85rem; box-shadow: var(--shadow);
  z-index: 300; transform: translateY(20px); opacity: 0;
  transition: all 0.3s;
  display: flex; align-items: center; gap: 0.65rem;
  max-width: 300px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--info); }

/* ========== EMPTY / LOADING ========== */
.loading-msg {
  grid-column: 1/-1; text-align: center;
  padding: 3rem; color: var(--text-muted); font-size: 0.88rem;
}

.empty-state {
  grid-column: 1/-1; text-align: center; padding: 3rem; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.8rem; margin-bottom: 0.9rem; opacity: 0.5; }
.empty-state p { font-size: 0.88rem; }

/* ========== BOTTOM NAV (Mobile) ========== */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 80;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0.2rem; background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 0.65rem; font-weight: 500;
  font-family: 'Inter', sans-serif;
  transition: color 0.2s; padding: 0.5rem 0.2rem;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item i { font-size: 1.15rem; }
.bottom-nav-item .bottom-nav-emoji { font-size: 1.2rem; line-height: 1; }
.bottom-nav-item.active { color: var(--primary-light); }
.bottom-nav-item:active { transform: scale(0.93); }

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .pomodoro-layout { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .notes-summary { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Hide desktop sidebar on mobile */
  .sidebar {
    transform: translateX(-100%);
    width: 260px !important;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

  /* Show bottom nav */
  .bottom-nav {
    display: flex;
  }

  /* Main content adjustments */
  .main-content {
    margin-left: 0 !important;
    padding-bottom: var(--bottom-nav-h);
  }

  /* Show menu button */
  .menu-btn { display: flex; }

  /* Toast above bottom nav */
  .toast { bottom: calc(var(--bottom-nav-h) + 1rem); }

  /* Pages */
  .page { padding: 1rem; }

  /* Profile banner */
  .profile-banner { padding: 1.1rem; }
  .profile-banner-avatar { font-size: 2.2rem; }
  .profile-banner-info h2 { font-size: 1.15rem; }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.65rem; }
  .stat-card { padding: 0.9rem; }
  .stat-value { font-size: 1.3rem; }

  /* Notes summary */
  .notes-summary { grid-template-columns: repeat(2, 1fr); }

  /* Tasks grid */
  .tasks-grid { grid-template-columns: 1fr; }

  /* Schedule */
  .schedule-container { overflow-x: auto; }

  /* Pomodoro */
  .timer-display { font-size: 3.5rem; }
  .progress-ring { width: 220px; height: 220px; }
  .pomodoro-modes { gap: 0.45rem; }
  .mode-btn { padding: 0.45rem 0.9rem; font-size: 0.78rem; }

  /* Week days */
  .week-days { grid-template-columns: repeat(4, 1fr); }

  /* Sessions */
  .sessions-grid { grid-template-columns: 1fr; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }

  /* Date display on topbar (hide on very small) */
  .date-display { display: none; }

  /* Table */
  .notes-table { font-size: 0.8rem; }
  .notes-table th, .notes-table td { padding: 0.6rem 0.65rem; }

  /* Hide text in buttons */
  .btn-label { display: none; }

  /* Filter bar */
  .filter-bar { gap: 0.45rem; }
  .filter-bar input { min-width: 100px; }
}

@media (max-width: 480px) {
  .page { padding: 0.75rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .stat-icon { width: 36px; height: 36px; font-size: 1rem; }
  .stat-value { font-size: 1.2rem; }
  .notes-summary { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .summary-value { font-size: 1.5rem; }
  .modal-body { padding: 1rem; }
  .modal-footer { padding: 0.85rem 1rem; }
  .profil-avatar-preview { flex-direction: column; align-items: flex-start; }
  .avatar-grid { max-width: 100%; }
  .week-days { grid-template-columns: repeat(4, 1fr); gap: 0.3rem; }
  .pomodoro-layout { gap: 0.9rem; }
  .timer-display { font-size: 3rem; }
  .timer-btn.primary { width: 58px; height: 58px; }
  .timer-btn.secondary { width: 42px; height: 42px; }
}
