/* ==========================================================================
   PIPO v65 — Planning (hub matières + échéances)
   S'appuie sur les tokens de styles.css (--bg, --surface, --border, --accent…)
   ========================================================================== */

.planning-page .planning-formation {
  margin-top: 10px;
  font-size: 15px;
  color: var(--text-muted);
}

.planning-page .planning-edit-link {
  color: var(--accent);
  text-decoration: none;
  margin-left: 6px;
}
.planning-page .planning-edit-link:hover { color: var(--accent-hover); }

.planning-status {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}
.planning-status.is-error { color: var(--danger); }

/* ---------- Bandeau visiteur non connecté ---------- */
.planning-auth-hint {
  margin-top: 22px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-size: 14px;
  color: var(--text-muted);
}
.planning-auth-hint a { color: var(--accent); }

/* ---------- Sections ---------- */
.planning-section { margin-top: 40px; }

.planning-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.planning-section-title {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  margin: 0;
}

/* ---------- Timeline échéances ---------- */
.echeances-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.echeance-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.echeance-count {
  flex: 0 0 auto;
  min-width: 72px;
  text-align: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 700;
  font-size: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}
.echeance-count.is-urgent { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.echeance-count.is-past   { background: var(--surface-alt); color: var(--text-faint); }
.echeance-count-sm { min-width: 58px; font-size: 12px; padding: 2px 8px; }

.echeance-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.echeance-titre { font-weight: 700; font-size: 15px; color: var(--text); }
.echeance-meta { font-size: 13px; color: var(--text-muted); }

/* ---------- Grille matières ---------- */
.matieres-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.matiere-tile {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.matiere-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.matiere-tile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.matiere-tile-nom {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text);
}

.matiere-tile-eval {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.matiere-tile-stats {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.matiere-echeances {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.matiere-echeance {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}
.matiere-echeance-label { flex: 1 1 auto; min-width: 0; }

.matiere-echeance-remove {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-faint);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.matiere-echeance-remove:hover { background: var(--surface-alt); color: var(--danger); }

.matiere-add-echeance {
  align-self: flex-start;
  border: none;
  background: transparent;
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}
.matiere-add-echeance:hover { color: var(--accent-hover); }

.echeance-form { display: flex; flex-direction: column; gap: 8px; }
.echeance-form-row { display: flex; gap: 8px; }
.echeance-form-row > * { flex: 1 1 0; min-width: 0; }
.echeance-form-actions { display: flex; justify-content: flex-end; gap: 8px; }

.matiere-tile-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.matiere-tile-actions .btn { flex: 1 1 0; text-align: center; }

.planning-unassigned-note {
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}
.planning-unassigned-note a { color: var(--accent); }

/* ---------- Empty state / ajout rapide ---------- */
.planning-empty {
  margin-top: 40px;
  padding: clamp(24px, 4vw, 40px);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
}

.planning-empty-title {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.planning-empty-desc {
  margin: 0 0 20px;
  font-size: 15px;
  color: var(--text-muted);
  max-width: 560px;
}

.quick-add-form {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1fr auto;
  gap: 10px;
  align-items: end;
}
.quick-add-field { display: flex; flex-direction: column; gap: 6px; }
.quick-add-label { font-size: 13px; font-weight: 500; color: var(--text-muted); }

.planning-empty-alt {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}
.planning-empty-alt a { color: var(--accent); }

@media (max-width: 720px) {
  .quick-add-form { grid-template-columns: 1fr; }
  .echeance-form-row { flex-direction: column; }
}

/* ---------- Emploi du temps (import ICS) ---------- */
.edt-connect {
  padding: 18px 20px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: var(--surface);
  margin-bottom: 16px;
}
.edt-connect-desc { margin: 0 0 12px; font-size: 14px; color: var(--text); }
.edt-connect-form { display: flex; gap: 10px; }
.edt-connect-form input { flex: 1 1 auto; min-width: 0; }
.edt-connect-hint { margin: 10px 0 0; font-size: 12.5px; color: var(--text-muted); }

.edt-source-info {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.edt-review {
  margin: 0 0 18px;
  padding: 16px 18px;
  border: 1px solid var(--warning-border);
  background: var(--warning-bg);
  border-radius: 14px;
}
.edt-review-title {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 700;
  font-size: 16px;
  margin: 0 0 4px;
  color: var(--warning);
}
.edt-review-desc { margin: 0 0 12px; font-size: 13px; color: var(--text); }
.edt-review-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.edt-review-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
}
.edt-review-nom { font-weight: 700; }
.edt-review-meta { font-size: 12.5px; color: var(--text-muted); }
.edt-review-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Grille semaine */
.edt-cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.edt-week-label {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 700;
  font-size: 15px;
}
.edt-cal-toolbar-right { display: flex; gap: 8px; }

.edt-grid {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow-x: auto;
}
.edt-grid-inner {
  display: grid;
  grid-template-columns: 46px repeat(6, minmax(110px, 1fr));
  min-width: 720px;
}
.edt-dayhead {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.edt-daycol { border-left: 1px solid var(--border); min-width: 0; }
.edt-daycol.is-today .edt-dayhead { color: var(--accent); font-weight: 700; }
.edt-daycol.is-today .edt-daybody { background: color-mix(in srgb, var(--accent-soft) 36%, transparent); }
.edt-timecol-body, .edt-daybody { position: relative; }
.edt-daybody { cursor: copy; }
.edt-timelabel {
  position: absolute;
  right: 6px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-faint);
}
.edt-hourline {
  position: absolute;
  left: 0; right: 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  pointer-events: none;
}

.edt-event {
  position: absolute;
  left: 3px; right: 3px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 3px 6px;
  border: none;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--text);
  text-align: left;
  font-size: 11.5px;
  line-height: 1.25;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}
.edt-event:hover { box-shadow: var(--shadow-sm); }
.edt-event-nom {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.edt-event-meta {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.edt-event.is-manuel {
  border-left-style: dashed;
  border-left-color: var(--ambre-strong);
  background: var(--ambre-soft);
}
.edt-event.is-averifier { opacity: 0.75; }

.edt-legend {
  margin: 10px 2px 0;
  font-size: 12.5px;
  color: var(--text-muted);
}
.edt-legend-swatch {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  vertical-align: -1px;
}
.edt-legend-import { background: var(--accent-soft); border-left: 3px solid var(--accent); }
.edt-legend-manuel { background: var(--ambre-soft); border-left: 3px dashed var(--ambre-strong); }

/* Modale */
.edt-modal { position: fixed; inset: 0; z-index: 80; }
.edt-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 31, 33, 0.45);
}
.edt-modal-card {
  position: relative;
  max-width: 440px;
  margin: 10vh auto 0;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.edt-modal-card form { display: flex; flex-direction: column; gap: 12px; }
.edt-modal-head { display: flex; align-items: center; justify-content: space-between; }
.edt-modal-title {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 800;
  font-size: 19px;
  margin: 0;
}
.edt-modal-close {
  width: 28px; height: 28px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}
.edt-modal-close:hover { background: var(--surface-alt); color: var(--text); }
.edt-modal-context { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.edt-modal-times { display: flex; flex-direction: column; gap: 10px; }
.edt-modal-lock-hint { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.edt-modal-error { margin: 0; font-size: 13px; color: var(--danger); }

@media (max-width: 720px) {
  .edt-connect-form { flex-direction: column; }
  .edt-modal-card { margin: 6vh 14px 0; }
}

/* ---------- Bloc-notes matière (onglets du panneau) ---------- */
.edt-modal-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface-alt);
  border-radius: 999px;
  align-self: flex-start;
}
.edt-modal-tab {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.edt-modal-tab.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.edt-note-panel { display: flex; flex-direction: column; gap: 8px; }
.edt-note-textarea {
  min-height: 300px;
  resize: vertical;
  line-height: 1.55;
  font-size: 14.5px;
}
.edt-note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 18px;
}
.edt-note-status { font-size: 12.5px; color: var(--text-muted); }
.edt-note-status.is-error { color: var(--danger); }
.edt-note-count { font-size: 12px; color: var(--text-faint); }

/* Panneau un peu plus large : on y écrit un cours */
.edt-modal-card { max-width: 620px; }

/* ---------- v69 : couleur par matière (hash stable sur le nom) ----------
   8 teintes calées sur la palette chaude de la charte. La teinte sert de
   bordure/pastille ; le fond est un mix léger — lisible en clair et sombre. */
.msub-0 { --msub: #0E8C82; }  /* teal (marque) */
.msub-1 { --msub: #C05B3C; }  /* terracotta */
.msub-2 { --msub: #A87A1E; }  /* ambre foncé */
.msub-3 { --msub: #5E8C5A; }  /* sauge */
.msub-4 { --msub: #4E7796; }  /* bleu ardoise */
.msub-5 { --msub: #8A5B7C; }  /* prune */
.msub-6 { --msub: #7E7C33; }  /* olive */
.msub-7 { --msub: #B25E6B; }  /* rose thé */

.matiere-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--msub, var(--accent));
}
.matiere-dot-sm { width: 8px; height: 8px; }

/* Le calendrier EDT prend la couleur de la matière */
.edt-event {
  border-left-color: var(--msub, var(--accent));
  background: color-mix(in srgb, var(--msub, var(--accent)) 13%, var(--surface));
}
.edt-event.is-manuel {
  border-left-color: var(--msub, var(--ambre-strong));
  background: color-mix(in srgb, var(--msub, var(--ambre-strong)) 13%, var(--surface));
}

.edt-review-item .matiere-dot { margin-right: 2px; }
.matiere-tile-head .matiere-dot { margin-top: 6px; margin-right: 8px; }

/* La pastille s'insère avant le nom : la puce d'évaluation reste à droite */
.matiere-tile-head { justify-content: flex-start; }
.matiere-tile-head .matiere-tile-eval { margin-left: auto; }
.matiere-tile-head .matiere-tile-nom { min-width: 0; }

/* v71 : méta des cartes matières (enseignant, prochain cours) */
.matiere-tile-meta {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.matiere-tile-meta strong { color: var(--text); font-weight: 700; }

/* ---------- v74 : suggestions d'échéances depuis l'EDT ---------- */
.echeances-suggestions { margin-top: 18px; }
.echeances-suggestions-title {
  font-family: 'Cabinet Grotesk', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-muted);
  margin: 0 0 10px;
}
.echeance-item.is-suggestion {
  border-style: dashed;
  flex-wrap: wrap;
}
.echeance-suggestion-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* Pré-étiquettes de l'écran de review (heuristique) */
.edt-review-tag {
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
  white-space: nowrap;
}
.edt-review-tag-eval {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

/* ---------- v75 : vue « jour » du calendrier (mobile) ---------- */
.edt-grid-inner.is-day {
  grid-template-columns: 46px 1fr;
  min-width: 0;
}
