/* ==========================================================================
   StudyCare — Design tokens & styles
   --------------------------------------------------------------------------
   Fichier de style CENTRALISÉ. Tout passe par les variables de :root ci-dessous.
   Règle : ne jamais écrire une couleur/rayon/espacement "en dur" dans un
   composant — toujours référencer un token var(--...). Ça garantit un style
   cohérent partout et évite les oublis.
   ========================================================================== */

:root {
  /* ---- Couleurs de marque (navy StudyCare) ---- */
  --c-primary:        #22357b;   /* boutons pleins : Jour actif, Exporter */
  --c-primary-hover:  #1a2a63;
  --c-primary-soft:   #eaeffb;   /* fond léger (chips, segment survolé) */
  --c-on-primary:     #ffffff;

  /* ---- Neutres ---- */
  --c-bg:            #f4f6fa;
  --c-surface:       #ffffff;
  --c-surface-2:     #fbfcfe;    /* lignes en-tête / couverture */
  --c-border:        #e9ecf3;
  --c-border-strong: #d8dce7;
  --c-text:          #1f2a44;    /* titres */
  --c-text-body:     #3a4256;
  --c-text-soft:     #868686;   /* gris foncé StudyCare */
  --c-text-mute:     #a4abbb;

  /* ---- Accents ---- */
  --c-accent-pink:   #e0417a;    /* "Effacer tout" */
  --c-chip-bg:       #e9efff;
  --c-chip-text:     #2f4bc0;

  /* ---- Avatar (uniforme, pas multicolore) ---- */
  --c-avatar-bg:     #eef3fc;
  --c-avatar-text:   #3a4d94;

  /* ---- Feedback couverture ---- */
  --c-green:   #12a150;  --c-green-bg:  #e9f7ef;
  --c-amber:   #e0891e;  --c-amber-bg:  #fdf3e4;  --c-amber-border: #f2ddb5;
  --c-red:     #e0413a;  --c-red-bg:    #fdece9;  --c-red-border: #f6c9c4;
  --c-pink:    #c03672;  --c-pink-bg:   #fce7f0;

  /* ---- Bandes de dispo ---- */
  --c-band-bg:       #e9effb;  --c-band-border: #dbe4f7;  --c-band-text: #3a4d94;
  --c-astreinte-bg:  #f2ecfd;  --c-astreinte-border: #e3d5f7; --c-astreinte-text: #7c4dd0;

  /* ---- Rayons ---- */
  --r-xs: 5px; --r-sm: 8px; --r-md: 10px; --r-lg: 14px; --r-xl: 16px; --r-full: 999px;

  /* ---- Ombres ---- */
  --shadow-sm:   0 1px 2px rgba(20,30,70,.05);
  --shadow-card: 0 1px 2px rgba(20,30,70,.04), 0 10px 34px rgba(20,30,70,.06);

  /* ---- Espacements ---- */
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:20px; --sp-6:24px;

  /* ---- Typo ---- */
  --font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fs-title: 22px; --fs-h2: 17px; --fs-base: 14px; --fs-sm: 13px; --fs-xs: 12px;

  /* ---- Dimensions grille ---- */
  --col-label-w: 268px;
  --hour-min-w:  60px;
}

/* ==========================================================================
   Base
   ========================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--c-text-body);
  background: var(--c-bg);
  font-size: var(--fs-base);
  -webkit-font-smoothing: antialiased;
}
.app { max-width: 1320px; margin: 0 auto; padding: var(--sp-5) var(--sp-6) 60px; }
.hidden { display: none !important; }

/* ---- En-tête de page ---- */
.page-head { margin-bottom: var(--sp-5); }
.page-title { font-size: var(--fs-title); font-weight: 600; color: var(--c-text); margin: 0 0 4px; letter-spacing: -0.01em; }
.page-sub { color: var(--c-text-soft); font-size: var(--fs-sm); margin: 0; }

/* ==========================================================================
   Login
   ========================================================================== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--sp-5); }
.login-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-xl); padding: 30px 28px; width: 100%; max-width: 360px; box-shadow: var(--shadow-card); }
.login-card h1 { font-size: 19px; margin: 0 0 4px; color: var(--c-text); }
.login-card p { color: var(--c-text-soft); margin: 0 0 var(--sp-5); font-size: var(--fs-sm); }
.field { margin-bottom: var(--sp-4); }
.field label { display: block; font-size: var(--fs-xs); font-weight: 600; color: var(--c-text-soft); margin-bottom: 5px; }
.field input { width: 100%; padding: 10px 12px; border: 1px solid var(--c-border); border-radius: var(--r-md); font-family: inherit; font-size: var(--fs-base); color: var(--c-text); }
.field input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-soft); }
.login-err { color: var(--c-red); font-size: 12.5px; margin: -4px 0 var(--sp-3); min-height: 16px; }
.btn-block { width: 100%; justify-content: center; }

/* ==========================================================================
   Toolbar : segment, recherche, boutons
   ========================================================================== */
.toolbar { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }

.seg { display: inline-flex; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--c-text-soft); padding: 8px 18px; border-radius: var(--r-sm); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; font-family: inherit; }
.seg button:hover { color: var(--c-text); }
.seg button.active { background: var(--c-primary); color: var(--c-on-primary); box-shadow: var(--shadow-sm); }

.search { flex: 1 1 220px; min-width: 180px; position: relative; }
.search input { width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); font-family: inherit; font-size: var(--fs-sm); color: var(--c-text); }
.search input::placeholder { color: var(--c-text-mute); }
.search input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-soft); }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--c-text-mute); }

/* Boutons — base + variantes */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text-body); padding: 9px 14px; border-radius: var(--r-md); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; font-family: inherit; white-space: nowrap; transition: border-color .12s, background .12s; }
.btn:hover { border-color: var(--c-border-strong); }
.btn-primary { background: var(--c-primary); color: var(--c-on-primary); border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--c-text-soft); }
.btn-ghost:hover { background: var(--c-primary-soft); border-color: transparent; color: var(--c-text); }

/* Picker de date (jour/semaine/mois selon la vue) */
.date-pick { position: relative; user-select: none; }
.date-pick #date-input { position: absolute; left: 0; bottom: -2px; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; margin: 0; }

/* ==========================================================================
   Filtres actifs + navigation de date
   ========================================================================== */
.filters-active { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; color: var(--c-text-soft); font-size: var(--fs-sm); }
.filters-active:empty { display: none; }
.filters-active .lbl { font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--c-chip-bg); color: var(--c-chip-text); border-radius: var(--r-full); padding: 4px 10px; font-weight: 600; font-size: 12.5px; }
.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 13px; line-height: 1; padding: 0; }
.link-danger { margin-left: auto; color: var(--c-accent-pink); font-weight: 600; cursor: pointer; }

/* Menu déroulant (choix de classe) */
.dropdown { position: absolute; z-index: 50; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); box-shadow: var(--shadow-card); padding: 6px; min-width: 220px; max-height: 320px; overflow-y: auto; }
.dropdown-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-body); cursor: pointer; }
.dropdown-item:hover { background: var(--c-primary-soft); }
.dropdown-item.sel { background: var(--c-primary-soft); color: var(--c-primary); }
.active-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-green); flex: none; }

.datenav { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.datenav .nav-btn { width: 30px; height: 30px; border-radius: var(--r-sm); border: 1px solid var(--c-border); background: var(--c-surface); cursor: pointer; color: var(--c-text-soft); font-size: 15px; display: inline-flex; align-items: center; justify-content: center; }
.datenav .nav-btn:hover { border-color: var(--c-border-strong); color: var(--c-text); }
.datenav h2 { font-size: var(--fs-h2); margin: 0; font-weight: 600; text-transform: capitalize; color: var(--c-text); }
.datenav .today { margin-left: 6px; }
.userbar { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); color: var(--c-text-soft); font-size: 12.5px; }

/* ==========================================================================
   Grille (commune aux vues)
   ========================================================================== */
.grid-wrap { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); overflow-x: auto; box-shadow: var(--shadow-card); }
.grid { min-width: 880px; }
.row { display: grid; grid-template-columns: var(--col-label-w) 1fr; border-bottom: 1px solid var(--c-border); }
.row:last-child { border-bottom: 0; }
.cell-label { padding: 11px 14px; border-right: 1px solid var(--c-border); display: flex; align-items: center; gap: 11px; }
.track { position: relative; }
.row-head { background: var(--c-surface-2); }
.row-head .cell-label { font-size: 11px; letter-spacing: .06em; color: var(--c-text-mute); font-weight: 600; text-transform: uppercase; }

/* En-têtes de colonnes (heures / jours) */
.ticks { display: flex; }
.tick { flex: 1 1 0; min-width: var(--hour-min-w); text-align: center; padding: 11px 2px; font-size: var(--fs-xs); color: var(--c-text-soft); font-weight: 600; border-left: 1px solid var(--c-border); }
.tick:first-child { border-left: 0; }
.tick .sub { display: block; font-size: 10px; color: var(--c-text-mute); font-weight: 600; text-transform: capitalize; }

/* Ligne couverture */
.row-cov { background: var(--c-surface-2); }
.row-cov .cell-label { font-weight: 600; color: var(--c-text); }
.star { color: var(--c-text-mute); }
.cov-cells { display: flex; }
.cov-cell { flex: 1 1 0; min-width: var(--hour-min-w); text-align: center; padding: 8px 2px; border-left: 1px solid var(--c-border); }
.cov-cell:first-child { border-left: 0; }
.cov-num { font-weight: 600; font-size: 15px; line-height: 1.1; }
.cov-lbl { font-size: 10px; font-weight: 600; opacity: .85; }

/* États de couverture (réutilisés partout : ligne, semaine, mois) */
.g-green { background: var(--c-green-bg); color: var(--c-green); }
.g-amber { background: var(--c-amber-bg); color: var(--c-amber); }
.g-red   { background: var(--c-red-bg);   color: var(--c-red); }
.g-none  { color: var(--c-text-mute); }

/* ==========================================================================
   Identité étudiant (avatar + nom + badge + jauge)
   ========================================================================== */
.avatar { width: 34px; height: 34px; border-radius: var(--r-full); flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; overflow: hidden; background: var(--c-avatar-bg); color: var(--c-avatar-text); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.who { min-width: 0; flex: 1; }
.who .name { font-weight: 600; font-size: 13.5px; color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.tag { font-size: 9.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; padding: 2px 6px; border-radius: var(--r-xs); background: var(--c-astreinte-bg); color: var(--c-astreinte-text); }
.who .meta { color: var(--c-text-soft); font-size: var(--fs-xs); margin-top: 1px; }
.who .strong-meta { color: var(--c-text-body); font-weight: 600; margin-top: 3px; }
.gauge { margin-top: 5px; }
.gauge-bar { height: 5px; border-radius: 4px; background: #eef0f6; overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 4px; background: var(--c-primary); transition: width .2s; }
.gauge-fill.done { background: var(--c-green); }
.gauge-txt { font-size: 10.5px; color: var(--c-text-mute); margin-top: 2px; }

/* KPI (jauges heures réalisées / observateur) */
.kpi { margin-top: 7px; }
.kpi-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.kpi-title { font-size: 10.5px; color: var(--c-text-soft); font-weight: 600; }
.kpi-val { font-size: 11px; color: var(--c-text-body); font-weight: 600; white-space: nowrap; }
.kpi .gauge-bar { height: 6px; }
.kpi.obs .gauge-fill { background: var(--c-astreinte-text); }
.kpi-status { font-size: 10px; color: var(--c-green); font-weight: 600; margin-top: 3px; }

/* ==========================================================================
   Vue JOUR — timeline & bandes
   ========================================================================== */
.track-grid { position: absolute; inset: 0; display: flex; pointer-events: none; }
.track-grid span { flex: 1 1 0; min-width: var(--hour-min-w); border-left: 1px solid var(--c-border); }
.track-grid span:first-child { border-left: 0; }
.closed { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg,#f5f6fa,#f5f6fa 6px,#eef0f6 6px,#eef0f6 12px); opacity: .55; }
.band { position: absolute; border-radius: var(--r-sm); background: var(--c-band-bg); border: 1px solid var(--c-band-border); color: var(--c-band-text); font-size: 11px; font-weight: 600; display: flex; align-items: center; padding: 0 9px; white-space: nowrap; overflow: hidden; }
.band.astreinte { background: var(--c-astreinte-bg); border-color: var(--c-astreinte-border); color: var(--c-astreinte-text); }
.row-student { min-height: 72px; }
.row-student .track { min-height: 72px; }

/* ==========================================================================
   Vue SEMAINE — cellules par jour
   ========================================================================== */
.day-cells { display: flex; }
.day-cell { flex: 1 1 0; min-width: var(--hour-min-w); border-left: 1px solid var(--c-border); padding: 10px 4px; text-align: center; min-height: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.day-cell:first-child { border-left: 0; }
.day-cell.has { background: var(--c-band-bg); }
.day-cell .h { font-weight: 600; font-size: 13px; color: var(--c-band-text); }
.day-cell .astinfo { font-size: 10px; color: var(--c-astreinte-text); font-weight: 600; }
/* Astreinte prioritaire → cellule violette (gagne sur .has) */
.day-cell.astreinte { background: var(--c-astreinte-bg); }
.day-cell.astreinte .h { color: var(--c-astreinte-text); }

/* ==========================================================================
   Vue MOIS — calendrier
   ========================================================================== */
.month { padding: 10px; }
.month-head, .month-week { display: grid; grid-template-columns: repeat(7, 1fr); }
.month-head div { padding: 8px 6px; text-align: center; font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--c-text-mute); letter-spacing: .05em; }
.mcell { border: 1px solid var(--c-border); margin: -0.5px 0 0 -0.5px; min-height: 88px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.mcell.out { background: var(--c-surface-2); }
.mcell .dnum { font-size: var(--fs-xs); font-weight: 600; color: var(--c-text-soft); }
.mcell.today .dnum { background: var(--c-primary); color: var(--c-on-primary); border-radius: var(--r-full); width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.mcell .cov { margin-top: auto; border-radius: var(--r-sm); padding: 6px; text-align: center; }
.mcell .cov .n { font-weight: 600; font-size: 16px; }
.mcell .cov .l { font-size: 10px; font-weight: 600; }

/* ==========================================================================
   Divers
   ========================================================================== */
.empty { padding: 26px; text-align: center; color: var(--c-text-mute); grid-column: 1 / -1; }
.legend { margin-top: var(--sp-3); display: flex; gap: var(--sp-4); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--c-text-soft); align-items: center; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }
footer.note { margin-top: var(--sp-3); font-size: var(--fs-xs); color: var(--c-text-mute); }

/* ==========================================================================
   Vue ENSEIGNANTS — couverture par demi-journée (bandeau + KPI + calendrier)
   ========================================================================== */
.ens-extra { display: flex; flex-direction: column; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.ens-extra:empty { display: none; }
.ens-alert { display: flex; align-items: center; gap: 8px; background: var(--c-red-bg); border: 1px solid var(--c-red-border); color: var(--c-red); border-radius: var(--r-md); padding: 12px 16px; font-size: var(--fs-sm); }
.ens-alert .ic { font-size: 15px; }
.ens-alert b { font-weight: 600; }
.ens-alert.warn { background: var(--c-amber-bg); border-color: var(--c-amber-border); color: var(--c-amber); }

.ens-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-3); }
.ens-kpi { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.ens-kpi.alert { background: var(--c-red-bg); border-color: var(--c-red-border); }
.ens-kpi .kh { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ens-kpi .ki { font-size: 14px; }
.ens-kpi .kt { font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-soft); }
.ens-kpi.alert .kt, .ens-kpi.alert .kv, .ens-kpi.alert .ks { color: var(--c-red); }
.ens-kpi .kv { font-size: 26px; font-weight: 600; color: var(--c-text); line-height: 1; }
.ens-kpi .kv .u { font-size: 15px; font-weight: 600; color: var(--c-text-mute); }
.ens-kpi .ks { font-size: var(--fs-xs); color: var(--c-text-soft); margin-top: 6px; }

/* Grille enseignants */
.ens-days { display: flex; }
.ens-dhead, .ens-covcell, .ens-daycol { flex: 1 1 0; min-width: var(--hour-min-w); border-left: 1px solid var(--c-border); }
.ens-dhead:first-child, .ens-covcell:first-child, .ens-daycol:first-child { border-left: 0; }
.ens-dhead { text-align: center; padding: 9px 2px; }
.ens-dhead .dow { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--c-text-mute); letter-spacing: .05em; }
.ens-dhead .dnum { display: block; font-size: 15px; font-weight: 600; color: var(--c-text); }
.ens-dhead.repos { background: var(--c-surface-2); }
.ens-dhead.repos .dnum { color: var(--c-text-mute); }
.ens-covcell { text-align: center; padding: 7px 2px; }

.ens-hours { flex-direction: column; align-items: stretch; padding: 0; }
.ens-hour { height: 56px; padding: 2px 12px; font-size: var(--fs-xs); color: var(--c-text-soft); font-weight: 600; border-top: 1px solid var(--c-border); }
.ens-hour:first-child { border-top: 0; }
.ens-canvas { position: relative; }
.ens-daycol { position: relative; }
.ens-daycol.repos { background: var(--c-surface-2); }
.ens-hline { height: 56px; border-top: 1px solid var(--c-border); }
.ens-hline:first-child { border-top: 0; }
.ens-closed { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(45deg,#f5f6fa,#f5f6fa 6px,#eef0f6 6px,#eef0f6 12px); opacity: .5; }

.ens-card { position: absolute; left: 6px; right: 6px; border-radius: var(--r-sm); padding: 8px 9px; overflow: hidden; }
.ens-card .nm { font-weight: 600; font-size: 12.5px; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ens-card .hr { font-size: 11px; opacity: .82; margin-top: 2px; }
.ens-card .nm-row { display: flex; align-items: center; gap: 6px; }
.ens-card .nm-row .nm { flex: 1 1 auto; min-width: 0; display: block; }
.ens-card .more { flex: none; border: 0; cursor: pointer; font-family: inherit; font-size: 10.5px; font-weight: 600; color: inherit; background: rgba(20,30,70,.10); border-radius: var(--r-full); padding: 2px 8px; }
.ens-card .more:hover { background: rgba(20,30,70,.18); }

/* Popover « +N » : liste des enseignants d'un créneau */
.ens-pop { min-width: 214px; padding: 6px; }
.ens-pop-head { font-size: 10.5px; font-weight: 600; color: var(--c-text-mute); text-transform: uppercase; letter-spacing: .05em; padding: 4px 9px 6px; }
.ens-pop-item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: var(--r-sm); }
.ens-pop-item:hover { background: var(--c-primary-soft); }
.ens-pop-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.ens-pop-item .pn { font-weight: 600; color: var(--c-text); flex: 1; font-size: var(--fs-sm); white-space: nowrap; }
.ens-pop-item .pr { color: var(--c-text-soft); font-size: var(--fs-xs); }
.dot.t0 { background: var(--c-band-text); } .dot.t1 { background: var(--c-green); }
.dot.t2 { background: var(--c-astreinte-text); } .dot.t3 { background: var(--c-pink); } .dot.t4 { background: var(--c-amber); }
.ens-uncov { position: absolute; left: 6px; right: 6px; border: 1px dashed var(--c-red); border-radius: var(--r-sm); background: var(--c-red-bg); color: var(--c-red); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; min-height: 18px; }

/* Palette enseignants (via tokens) */
.ens-card.t0 { background: var(--c-band-bg); color: var(--c-band-text); }
.ens-card.t1 { background: var(--c-green-bg); color: var(--c-green); }
.ens-card.t2 { background: var(--c-astreinte-bg); color: var(--c-astreinte-text); }
.ens-card.t3 { background: var(--c-pink-bg); color: var(--c-pink); }
.ens-card.t4 { background: var(--c-amber-bg); color: var(--c-amber); }
