/* Agenda Scolaire — styles autonomes, chargés uniquement par agenda.html */
:root {
  --primary: #a78bfa;
  --primary-dark: #7c3aed;
  --primary-light: rgba(167,139,250,0.15);
  --bg: #0a0a1a;
  --bg-card: #111128;
  --bg-input: #1a1a35;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: rgba(255,255,255,0.1);
  --success: #34d399;
  --warning: #f97316;
  --danger: #fb7185;
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Layout ────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  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: 200;
}
.sidebar-brand { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.sidebar-brand h1 { font-size: 1.05rem; font-weight: 700; color: var(--primary); }
.sidebar-brand .sb-user { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-brand .sb-back { display: inline-flex; align-items: center; gap: 4px; font-size: 0.72rem; color: var(--text-muted); text-decoration: none; margin-top: 6px; transition: color .15s; }
.sidebar-brand .sb-back:hover { color: var(--primary); }

.sidebar-nav { flex: 1; padding: 10px 0; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: var(--text-muted);
  font-size: 0.875rem; font-weight: 500;
  border: none; background: none; width: 100%; text-align: left;
  cursor: pointer; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--primary-light); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-item .icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer { padding: 12px 20px; border-top: 1px solid var(--border); }

.main { flex: 1; margin-left: 220px; min-height: 100vh; overflow-x: hidden; }
.page-header {
  padding: 20px 24px 0;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
}
.page-header h2 { font-size: 1.3rem; font-weight: 700; }
.page-content { padding: 16px 24px 24px; }

/* ── Bottom Nav (mobile) ───────────────────── */
.bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-card); border-top: 1px solid var(--border); z-index: 200; height: 58px; }
.bottom-nav-inner { display: flex; height: 100%; }
.bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-muted); font-size: 0.62rem; font-weight: 500; cursor: pointer; border: none; background: none; text-decoration: none; transition: color .15s; }
.bn-item .icon { font-size: 1.15rem; }
.bn-item.active { color: var(--primary); }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: 58px; }
  .bottom-nav { display: block; }
}

/* ── Buttons ───────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: none;
  font-size: 0.85rem; font-weight: 500; cursor: pointer;
  transition: opacity .15s, transform .1s; text-decoration: none; white-space: nowrap;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--bg-input); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,0.08); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-icon { padding: 6px; border-radius: 7px; }

/* ── Forms ─────────────────────────────────── */
.form-group { margin-bottom: 13px; }
.form-group label { display: block; font-size: 0.72rem; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control { width: 100%; padding: 9px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 0.875rem; transition: border-color .15s; font-family: inherit; }
.form-control:focus { outline: none; border-color: var(--primary); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control option { background: var(--bg-card); }
textarea.form-control { resize: vertical; min-height: 68px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

/* ── Color Picker ──────────────────────────── */
.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.color-swatch { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: transform .15s, border-color .15s; }
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: #fff; transform: scale(1.1); }

/* ── Modal ─────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 500; display: flex; align-items: flex-end; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--bg-card); border-radius: 16px 16px 0 0; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; padding: 20px; transform: translateY(20px); transition: transform .2s; }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { background: var(--bg-input); border: none; color: var(--text-muted); font-size: 1rem; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
@media (min-width: 520px) { .modal-overlay { align-items: center; } .modal { border-radius: 16px; } }

/* ── Toast ─────────────────────────────────── */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 8px; padding: 10px 14px; font-size: 0.83rem; min-width: 190px; max-width: 270px; animation: slideIn .2s ease; pointer-events: all; }
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(100%); } }

/* ── Schedule ──────────────────────────────── */
.schedule-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.week-label { font-size: 0.85rem; color: var(--text-muted); min-width: 150px; text-align: center; }
.schedule-wrapper { overflow-x: auto; margin-top: 14px; border-radius: var(--radius); border: 1px solid var(--border); }
.schedule-grid { display: grid; grid-template-columns: 46px repeat(5, minmax(75px, 1fr)); min-width: 460px; background: var(--bg-card); }
.schedule-day-header { background: var(--bg-card); border-bottom: 1px solid var(--border); padding: 8px 4px; text-align: center; position: sticky; top: 0; z-index: 10; }
.schedule-day-header .day-name { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }
.schedule-day-header .day-date { font-size: 0.78rem; font-weight: 600; color: var(--text); margin-top: 2px; }
.schedule-day-header.today .day-date { background: var(--primary); color: #fff; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; margin: 2px auto 0; }
.time-col-body { border-right: 1px solid var(--border); }
.day-col { position: relative; border-left: 1px solid var(--border); }
.time-label { position: absolute; right: 5px; font-size: 0.65rem; color: var(--text-muted); transform: translateY(-50%); white-space: nowrap; }
.hour-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); opacity: 0.4; }
.half-line  { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--border); opacity: 0.2; }
.creneau-block { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 3px 5px; font-size: 0.7rem; font-weight: 600; overflow: hidden; cursor: pointer; transition: filter .15s, transform .1s; color: #fff; line-height: 1.3; }
.creneau-block:hover { filter: brightness(1.15); transform: scale(1.02); }
.creneau-block .cb-time { opacity: 0.85; font-weight: 400; font-size: 0.64rem; }
.schedule-add-hint { text-align: center; color: var(--text-muted); font-size: 0.8rem; padding: 14px; }

/* ── Kanban ────────────────────────────────── */
.kanban-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kanban-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; align-items: start; }
@media (max-width: 640px) { .kanban-board { grid-template-columns: 1fr; } }
.kanban-col { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); min-height: 100px; }
.kanban-col-header { padding: 11px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.kanban-col-header h3 { font-size: 0.85rem; font-weight: 700; }
.col-count { background: var(--bg-input); color: var(--text-muted); font-size: 0.72rem; font-weight: 600; padding: 2px 7px; border-radius: 20px; }
.col-todo       .kanban-col-header { border-top: 3px solid var(--warning); border-radius: var(--radius) var(--radius) 0 0; }
.col-inprogress .kanban-col-header { border-top: 3px solid var(--primary); border-radius: var(--radius) var(--radius) 0 0; }
.col-done       .kanban-col-header { border-top: 3px solid var(--success); border-radius: var(--radius) var(--radius) 0 0; }
.kanban-cards { padding: 8px; display: flex; flex-direction: column; gap: 7px; min-height: 50px; }
.kanban-cards.drag-over { background: var(--primary-light); border-radius: 0 0 var(--radius) var(--radius); }
.devoir-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: grab; border-left: 3px solid var(--border); transition: box-shadow .15s, transform .1s; user-select: none; }
.devoir-card:active { cursor: grabbing; }
.devoir-card.dragging { opacity: 0.4; }
.devoir-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.4); transform: translateY(-1px); }
.devoir-card-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; line-height: 1.3; }
.devoir-card-meta { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px; border-radius: 20px; font-size: 0.68rem; font-weight: 600; }
.badge-matiere { color: #fff; }
.badge-prio-haute   { background: rgba(251,113,133,0.2); color: #fb7185; }
.badge-prio-moyenne { background: rgba(249,115,22,0.2);  color: #f97316; }
.badge-prio-basse   { background: rgba(148,163,184,0.15); color: #94a3b8; }
.badge-deadline       { background: var(--bg-input); color: var(--text-muted); }
.badge-deadline.overdue { background: rgba(251,113,133,0.15); color: var(--danger); }
.badge-deadline.soon    { background: rgba(249,115,22,0.15);  color: var(--warning); }
.devoir-card-actions { margin-top: 7px; display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity .15s; }
.devoir-card:hover .devoir-card-actions { opacity: 1; }

/* ── Matières ──────────────────────────────── */
.matiere-list { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; }
.matiere-item { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; display: flex; align-items: center; gap: 12px; }
.matiere-dot { width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0; }
.matiere-info { flex: 1; min-width: 0; }
.matiere-name { font-size: 0.875rem; font-weight: 600; }
.matiere-dates { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.matiere-actions { display: flex; gap: 5px; flex-shrink: 0; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 8px; }
.empty-state p { font-size: 0.875rem; }

/* ── Stats ─────────────────────────────────── */
.stats-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
@media (max-width: 640px) { .stats-summary { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-card .stat-num { font-size: 1.8rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-card .stat-label { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.3px; }
.stat-card.danger  .stat-num { color: var(--danger); }
.stat-card.success .stat-num { color: var(--success); }
.charts-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
@media (max-width: 768px) { .charts-grid { grid-template-columns: 1fr; } }
.chart-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.chart-card h3 { font-size: 0.78rem; font-weight: 700; margin-bottom: 14px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Tests à venir ─────────────────────────── */
.test-cards-grid { display: flex; flex-direction: column; gap: 8px; }
.test-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  transition: border-color .15s;
}
.test-card:hover { border-color: rgba(167,139,250,0.3); }
.test-card-past { opacity: 0.5; }
.test-card-left { min-width: 0; }
.test-card-subject { font-size: .875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.test-card-date    { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.test-card-right   { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.test-card-coef    { font-size: .72rem; color: var(--text-muted); }
.test-card-note    { font-size: .8rem; font-weight: 700; color: var(--success); }
.test-badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: .7rem; font-weight: 700;
}
.tbadge-green  { background: rgba(52,211,153,0.15);  color: #34d399; }
.tbadge-orange { background: rgba(249,115,22,0.15);  color: #f97316; }
.tbadge-red    { background: rgba(251,113,133,0.15); color: #fb7185; }
.tbadge-past   { background: rgba(148,163,184,0.12); color: #94a3b8; }

/* ── Utils ─────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 0.82rem; }
.hidden     { display: none !important; }
