/*
 * To-Do, Planning et Tableau de bord CM (refonte simplicite, lot 9) : les ecrans
 * web/suivi/todo.js, planning.js et tableau-cm.js. Reference :
 * maquette/refonte-simplicite.html (ecranTodo, ecranPlanning, ecranTableauCM).
 *
 * Les lignes, pastilles, nombres, boutons, formulaires en ligne et erreurs viennent du
 * socle (socle.css : classes p-* et ent-*) : rien n'y est redefini ici. Ce fichier ne
 * pose que ce qui est propre a ces trois ecrans, prefixe v- :
 *   .v-ecran (.v-todo, .v-planning, .v-tableau)   la section de l'ecran
 *   .v-tete > .v-titre                             le titre (h2)
 *   .v-outils, .v-choix                            la rangee des choix : menu d'une
 *                                                  personne, semaine, + RDV
 *   .v-section > .v-section-titre                  une rubrique et son titre (p-nombre)
 *   .v-pli                                         une rubrique repliee (details)
 *   .v-vide, .v-chargement, .v-erreur-ecran        rien ici ; chargement ; erreur de lecture
 *   .v-semaine > .v-jour (.v-auj) > .v-evt         le planning : sept jours et leurs
 *                                                  evenements (.v-evt-limite avec fort ou
 *                                                  moyen, .v-evt-rdv, .v-evt-source : la marque
 *                                                  « Agenda Google », .v-evt-serie : le rythme
 *                                                  d'un RDV d'une serie) ; .v-edition : la place
 *                                                  du formulaire ou de la confirmation d'un RDV
 *                                                  (.v-edition-titre, .v-edition-aide)
 *   .v-compteurs > .v-compteur, .v-rangees > .v-rangee   le tableau de bord CM ;
 *   .v-cette (.v-cette-tete, .v-cette-client, .v-cette-volume, .v-cette-note,
 *   .v-cette-videos)                               Cette semaine : un bloc par client, ses
 *                                                  lignes de videos sont celles du socle
 *                                                  (.p-video) ;
 *   .v-client                                      Mes clients : la rangee d'un client et,
 *                                                  dessous, ses videos repliees (.p-videos)
 *
 * Jamais de rouge ni d'orange (API.md 11.10, tests/couleurs-refonte.test.js) : les
 * couleurs sont celles du theme (style.css) et du socle. Une agence se lit a son lisere
 * (--ent), la priorite au contraste (date limite forte : cadre plein et clair ; moyenne :
 * cadre doux), et le vert (--accent) marque aujourd'hui dans le planning, comme la
 * maquette.
 *
 * Telephone (700 px et moins) : le planning devient une liste par jour, les rangees
 * passent a la ligne, les cibles font 44 px (aussi au doigt, pointer: coarse) et la page
 * ne defile pas a l'horizontale a 375 px.
 */

/* ---------- commun aux trois ecrans ---------- */

.v-ecran { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }

.v-tete {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 6px 16px; min-width: 0; margin: 0 0 14px;
}
/* Deux classes : passe devant h2 de style.css (majuscules, marge de 40 px). */
.v-ecran .v-titre {
  margin: 0; color: var(--texte); font-size: 20px; font-weight: 650; line-height: 1.25;
  text-transform: none; letter-spacing: 0;
}
.v-aide { margin: 0; color: var(--doux); font-size: 13px; max-width: 80ch; }
/* Le titre ne prend le focus que par le code (apres un geste) : pas de cadre. */
.v-ecran .v-titre:focus { outline: none; }

.v-erreur-ecran { margin: 0 0 12px; }
.v-chargement { margin: 0; color: var(--doux); font-size: 13.5px; }

.v-outils { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; min-width: 0; margin: 0 0 12px; }
/* Le libelle et son menu sur une ligne : style.css met les label en bloc et les menus a 100 %. */
.v-choix {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; margin: 0;
  color: var(--doux); font-size: 12.5px;
}
.v-choix select { width: auto; min-width: 0; max-width: 100%; padding: 7px 10px; font-size: 13.5px; }

.v-section { min-width: 0; margin-top: 22px; }
.v-section-titre {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px;
  color: var(--doux); font-size: 12px; font-weight: 600; line-height: 1.4;
  text-transform: uppercase; letter-spacing: .09em;
}

.v-vide {
  margin: 0; padding: 14px; border: 1px dashed var(--bord-haut); border-radius: 10px;
  background: var(--carte); color: var(--doux); font-size: 13px;
}

/* Une rubrique repliee : un triangle, son titre et son nombre. */
.v-pli { min-width: 0; margin-top: 22px; }
.v-pli > summary {
  display: flex; align-items: center; gap: 8px; width: max-content; max-width: 100%;
  padding: 6px 0; cursor: pointer; list-style: none;
  color: var(--doux); font-size: 12px; font-weight: 600; line-height: 1.4;
  text-transform: uppercase; letter-spacing: .09em;
}
.v-pli > summary::-webkit-details-marker { display: none; }
.v-pli > summary::before { content: "\25B8"; font-size: 11px; }
.v-pli[open] > summary::before { content: "\25BE"; }
.v-pli[open] > summary { margin-bottom: 10px; }
.v-pli > summary:hover { color: var(--texte); }
.v-pli > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------- planning ---------- */

.v-semaine-nav { display: flex; align-items: center; gap: 8px; min-width: 0; }
.v-semaine-nav .p-btn { min-width: 40px; font-size: 17px; line-height: 1; }
.v-semaine-lib { font-size: 14px; font-variant-numeric: tabular-nums; }

/* Sept colonnes, du lundi au dimanche. */
.v-semaine { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; min-width: 0; }
.v-jour {
  display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 230px;
  padding: 8px; border: 1px solid var(--bord); border-radius: 10px; background: var(--carte);
}
/* Aujourd'hui : son cadre et son nom en vert, comme la maquette. */
.v-jour.v-auj { border-color: var(--accent); }
/* Deux classes : passe devant h3 de style.css. */
.v-jour .v-jour-tete {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 6px; margin: 0;
  color: var(--doux); font-size: 12px; font-weight: 400; line-height: 1.4;
  text-transform: none; letter-spacing: 0;
}
.v-jour.v-auj .v-jour-tete { color: var(--accent); }
.v-rien { margin: 0; color: var(--doux); font-size: 12px; }

/* Un evenement : le lisere de son agence, son type (et son heure), son titre, son detail. */
.v-evt {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: 6px 7px; border: 1px solid var(--bord); border-radius: 7px;
  background: var(--carte-haut); box-shadow: inset 3px 0 0 var(--ent, transparent);
  color: var(--texte); font-size: 12px; line-height: 1.35; text-align: left; text-decoration: none;
}
a.v-evt:hover { border-color: var(--p-pale); }
a.v-evt:focus-visible, .v-evt-lien:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.v-evt-type { color: var(--doux); font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; }
.v-evt-titre { font-weight: 650; }
.v-evt-detail, .v-evt-note { color: var(--doux); }
.v-evt-note { white-space: pre-line; }
/* Le titre d'un RDV lie a un projet : un lien vers sa fiche, qui garde la couleur du texte. */
.v-evt-lien {
  color: var(--texte); text-decoration: underline; text-decoration-color: var(--p-pale); text-underline-offset: 2px;
}
.v-evt .p-pastille { align-self: flex-start; margin-top: 3px; }
/* « Agenda Google » (un RDV lu dans l'agenda de l'agence) : passe a la ligne dans une colonne etroite. */
.v-evt .v-evt-source { max-width: 100%; white-space: normal; }
/* Le rythme d'un RDV d'une serie (« Chaque mois le 2e mardi ») : de meme. */
.v-evt .v-evt-serie { max-width: 100%; white-space: normal; }
/* Une date limite : un cadre en pointille ; forte, un cadre plein et clair ; moyenne, un cadre doux. */
.v-evt.v-evt-limite { background: transparent; border-style: dashed; }
.v-evt.v-evt-limite.fort { border-color: var(--alerte); border-style: solid; }
.v-evt.v-evt-limite.moyen { border-color: var(--attente); }
.v-evt-gestes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.v-evt .p-fi-err { margin-top: 4px; }

/*
 * La place du formulaire ou de la confirmation d'un RDV, posee juste apres son jour :
 * sur ordinateur, une deuxieme rangee de la grille, sous la semaine, du cote du jour
 * (v-edition-fin : jeudi a dimanche) ; les sept jours restent sur la premiere.
 */
.v-semaine > .v-edition {
  grid-column: 1 / -1; grid-row: 2; justify-self: start;
  width: min(100%, 640px); min-width: 0;
}
.v-semaine > .v-edition.v-edition-fin { justify-self: end; }
.v-edition:empty { display: none; }
.v-edition-titre { margin: 0; color: var(--texte); font-size: 13.5px; font-weight: 650; }
/* Une phrase d'aide dans le formulaire d'un RDV : le jour d'une serie, qui sort du planning. */
.v-edition-aide { margin: 0; color: var(--doux); font-size: 12.5px; }

/* Les participants d'un RDV : une case par personne. */
.v-cases { display: flex; flex-wrap: wrap; gap: 6px 16px; min-width: 0; margin: 0; padding: 0; border: 0; }
.v-cases legend { margin-bottom: 6px; padding: 0; color: var(--doux); font-size: 12.5px; }
/* Deux classes : passe devant .p-fi label du socle (le libelle au-dessus du champ). */
.p-fi .v-cases label {
  flex-direction: row; align-items: center; gap: 8px;
  color: var(--texte); font-size: 13px; cursor: pointer;
}
.v-cases input { flex: 0 0 auto; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

/* ---------- tableau de bord CM ---------- */

.v-compteurs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.v-compteur {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: 10px 12px; border: 1px solid var(--bord); border-radius: 10px;
  background: var(--carte); color: var(--texte); text-decoration: none;
}
.v-compteur b { font-size: 22px; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.v-compteur span { color: var(--doux); font-size: 12px; }

.v-rangees { display: flex; flex-direction: column; gap: 6px; }
.v-rangee {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0;
  padding: 11px 12px; border: 1px solid var(--bord); border-radius: 10px;
  background: var(--carte); box-shadow: inset 3px 0 0 var(--ent, transparent);
  color: var(--texte); text-decoration: none;
}
.v-rangee-texte { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13.5px; }
.v-rangee-texte small { color: var(--doux); font-size: 12.5px; }
.v-rangee-droite { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; min-width: 0; }

.v-compteur:hover, .v-rangee:hover { border-color: var(--bord-haut); }
.v-compteur:focus-visible, .v-rangee:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Cette semaine : un bloc par client, le lisere de son agence ; son nom et son volume sur
   une ligne, la note dessous, puis ses tournages et livraisons (lignes .p-video du socle). */
.v-cette {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  padding: 11px 12px; border: 1px solid var(--bord); border-radius: 10px;
  background: var(--carte); box-shadow: inset 3px 0 0 var(--ent, transparent);
}
.v-cette-tete {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 2px 12px; min-width: 0; margin: 0;
}
.v-cette-client {
  min-width: 0; color: var(--texte); font-size: 13.5px; font-weight: 650;
  text-decoration: none; overflow-wrap: anywhere;
}
a.v-cette-client:hover { text-decoration: underline; text-underline-offset: 2px; }
a.v-cette-client:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.v-cette-volume { color: var(--texte); font-size: 13px; font-variant-numeric: tabular-nums; }
.v-cette-note { color: var(--doux); font-size: 12.5px; white-space: pre-line; overflow-wrap: anywhere; }
.v-cette .v-cette-videos { margin-top: 4px; }
.v-cette-videos b { color: var(--texte); font-weight: 600; }

/* Mes clients : la rangee du client, et dessous, un peu en retrait, ses videos repliees. */
.v-client { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.v-client > .p-videos { padding-left: 14px; }

/* ---------- telephone ---------- */

@media (max-width: 700px) {
  .v-ecran .v-titre { font-size: 18px; }
  /* Le planning : une liste par jour ; la place d'un formulaire de RDV suit son jour. */
  .v-semaine { display: flex; flex-direction: column; }
  .v-jour { min-height: 0; }
  .v-semaine > .v-edition { width: 100%; }
  .v-rangee { flex-wrap: wrap; align-items: flex-start; }
  .v-rangee-droite { justify-content: flex-start; }
}

/* Au doigt, une cible de moins de 44 px se rate : rubriques repliees, liens, cases. */
@media (max-width: 700px), (pointer: coarse) {
  .v-pli > summary, .v-compteur, .v-rangee, a.v-evt { min-height: 44px; }
  a.v-cette-client { display: inline-flex; align-items: center; min-height: 44px; }
  .v-semaine-nav .p-btn { min-width: 44px; }
  .v-evt-lien { display: inline-flex; align-items: center; min-height: 44px; }
  .p-fi .v-cases label { min-height: 44px; }
  .v-cases input { width: 20px; height: 20px; }
}
