/* =========================================================================
   Module Tâches — CŒUR (Lot A) : styles communs
   -------------------------------------------------------------------------
   Tout est préfixé `.tk-` (ou vit sous `.tk2`) pour ne jamais entrer en
   collision avec tablette.css. On réutilise exclusivement ses variables
   (--card, --txt, --txt2, --sep, --bg, --blue, --red…) : le module suit donc
   automatiquement le thème de l'app, y compris en mode sombre.
   ========================================================================= */

.tk2 {
  /* jetons locaux, dérivés des variables de tablette.css */
  --tk-gap: 10px;
  --tk-r: 14px;
  --tk-shadow: 0 1px 3px rgba(0, 0, 0, .06);
  --tk-hover: var(--fill-3);
}

/* ------------------------------ barre d'outils ------------------------- */
.tk-tools {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin-bottom: 10px;
}
.tk-tools .grow { flex: 1; min-width: 0; }
.tk-badge {
  display: inline-block; margin-left: 6px; min-width: 19px; padding: 0 5px;
  background: var(--blue); color: #fff; border-radius: 10px;
  font-size: 12px; font-weight: 700; line-height: 19px; text-align: center;
}

/* v427 : outils ET sélecteur Liste/Trello sur UNE ligne (avant : deux
   lignes d'outils + un sélecteur pleine largeur = la moitié de la hauteur du
   Trello perdue avant la première carte). */
.tk-barre { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.tk-barre .tk-tools { flex: 1; min-width: 0; margin-bottom: 0; }
.tk-viewsel { flex: none; margin-bottom: 0; }
.tk-viewsel .seg { width: auto; }
.tk-seg button { white-space: nowrap; }

/* ------------------------------ filtres actifs ------------------------- */
.tk-actifs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tk-fchip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 11px; font-size: 13px; font-weight: 600;
  background: var(--fill); color: var(--txt);
  transition: background .18s ease, opacity .18s ease;
}
.tk-fchip b { color: var(--txt2); font-weight: 700; }
.tk-fchip:active { opacity: .6; }
.tk-fchip-clear { background: transparent; color: var(--blue); }

/* ------------------------------ compteurs ------------------------------ */
.tk-stats {
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 0 4px 10px; font-size: 13px; color: var(--txt2);
}
.tk-stat { font-weight: 600; }
.tk-stat.neg { color: var(--red); }
.tk-stat.warn { color: var(--warn); }
.tk-stat.ok { color: var(--ok); }

/* ------------------------------ groupes -------------------------------- */
.tk-groupe { margin-bottom: 18px; }
.tk-groupe-tt {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--txt2); padding: 0 4px 8px;
}
.tk-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto;
  display: inline-block;
}
.tk-n {
  margin-left: auto; background: var(--fill);
  border-radius: 9px; padding: 1px 8px; font-size: 12px;
  letter-spacing: 0; color: var(--txt2);
}

/* ------------------------------ liste ---------------------------------- */
.tk-list {
  background: var(--card); border-radius: var(--radius, 18px);
  overflow: hidden; box-shadow: var(--tk-shadow);
}
.tk-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px 12px 12px;
  border-bottom: 1px solid var(--sep);
  border-left: 3px solid transparent;
  transition: background .18s ease, border-color .18s ease, opacity .18s ease;
}
.tk-row:last-child { border-bottom: 0; }
.tk-row:hover { background: var(--tk-hover); }
.tk-row.sel { background: rgba(0, 122, 255, .1); }
/* liseré gauche = priorité ; le retard prend le dessus */
.tk-row.p-basse { border-left-color: var(--blue); }
.tk-row.p-haute { border-left-color: var(--red); }
.tk-row.late { border-left-color: var(--red); }
.tk-row.done { opacity: .55; }
.tk-row.done .tk-titre { text-decoration: line-through; color: var(--txt2); }
.tk-row.arch { opacity: .5; }

.tk-main {
  flex: 1; min-width: 0; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
}
.tk-main:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 8px; }
.tk-l1 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tk-titre {
  font-size: 16px; font-weight: 600; color: var(--txt);
  overflow-wrap: anywhere;
}
.tk-l2 {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 13px; color: var(--txt2);
}
.tk-sep {
  width: 3px; height: 3px; border-radius: 50%;
  background: currentColor; opacity: .5; display: inline-block;
}
.tk-late { color: var(--red); font-weight: 600; }
.tk-ok { color: var(--ok); font-weight: 600; }
.tk-badge-b { font-size: 13px; line-height: 1; }

.tk-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 5px;
  flex: 0 0 auto; padding-top: 1px;
}

/* pastille ronde de cochage */
.tk-check {
  flex: 0 0 auto; width: 26px; height: 26px; margin-top: 1px;
  border-radius: 50%; border: 2px solid rgba(120, 120, 128, .4);
  background: transparent; color: #fff;
  font-size: 14px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .18s ease, border-color .18s ease, transform .12s ease;
}
.tk-check:hover { border-color: var(--blue); }
.tk-check:active { transform: scale(.9); }
.tk-check.on { background: var(--green); border-color: var(--green); }
.tk-check.sm { width: 22px; height: 22px; font-size: 12px; }
.tk-check:disabled { opacity: .45; }

/* chips */
.tk-chip {
  display: inline-block; padding: 2px 9px; border-radius: 10px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--c, var(--txt2));
  background: color-mix(in srgb, var(--c, #8e8e93) 15%, transparent);
}
.tk-chip-st { color: var(--c); }
/* v425 — échéance en pastille colorée selon l'urgence (liste ET Trello) */
.tk-ech-chip {
  display: inline-block; padding: 2px 9px; border-radius: 10px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
  color: var(--txt); background: var(--fill);
}
.tk-ech-chip.retard  { color: #fff; background: var(--red); }
.tk-ech-chip.auj     { color: #fff; background: #ff9500; }
.tk-ech-chip.semaine { color: var(--blue); background: rgba(0, 122, 255, .14); }
.tk-ech-chip.fini    { color: var(--txt2); font-weight: 600; text-decoration: line-through; }
/* repli pour les navigateurs sans color-mix (WebKit ancien / iOS 15) */
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  .tk-chip { background: var(--fill); color: var(--txt2); }
  .tk-chip-st { color: var(--txt); }
}

.tk-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.tk-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 9px;
  font-size: 12px; font-weight: 600;
  color: var(--c, var(--txt2));
  background: color-mix(in srgb, var(--c, #8e8e93) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, #8e8e93) 28%, transparent);
}
.tk-tag button {
  font-size: 11px; opacity: .6; padding: 0 1px; line-height: 1;
}
.tk-tag button:hover { opacity: 1; }

/* avatar */
.tk-av {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; margin-right: 4px;
  font-size: 10px; font-weight: 700; color: #fff; letter-spacing: .02em;
  vertical-align: -5px;
}
.tk-av-tous { background: var(--fill-2); font-size: 11px; }

/* barre d'avancement */
.tk-prog {
  height: 4px; border-radius: 2px; margin-top: 5px;
  background: rgba(120, 120, 128, .18); overflow: hidden;
}
.tk-prog i {
  display: block; height: 100%; border-radius: 2px;
  background: var(--blue); transition: width .25s ease;
}

/* ------------------------------ états vides ---------------------------- */
.tk-vide { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.tk-vide-ic { font-size: 42px; line-height: 1; opacity: .55; }
.tk-vide-t { font-size: 17px; font-weight: 600; color: var(--txt); }
.tk-vide-s { font-size: 14px; color: var(--txt2); margin-bottom: 6px; }
.tk-vide-sm { font-size: 14px; color: var(--txt2); padding: 8px 2px; }

/* ------------------------- barre de sélection -------------------------- */
.tk-selbar {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  z-index: 40; display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; padding: 10px 12px;
  background: var(--card); border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .22);
  animation: tk-up .18s ease;
}
.tk-selbar[hidden] { display: none; }
.tk-selnb { font-size: 14px; font-weight: 700; margin-right: 4px; }
.tk-selbar .btn { padding: 8px 12px; font-size: 14px; }
@keyframes tk-up { from { transform: translateY(14px); opacity: 0; } }

/* ============================ feuilles / fiche ========================== */
.tk-frm .tk-multi {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px;
}
.tk-multi { display: flex; flex-wrap: wrap; gap: 6px; }
.tk-mchip {
  padding: 7px 13px; border-radius: 11px; font-size: 14px; font-weight: 600;
  background: var(--fill); color: var(--txt);
  border: 1.5px solid transparent;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.tk-mchip.on {
  background: color-mix(in srgb, var(--c, #007aff) 16%, transparent);
  border-color: var(--c, #007aff);
  color: var(--c, var(--blue));
}
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  .tk-mchip.on { background: rgba(0, 122, 255, .14); border-color: var(--blue); color: var(--blue); }
}
.tk-mchip:disabled { opacity: .5; }
.tk-mchip:active { transform: scale(.97); }

.tk-hide { display: none !important; }

.tk-fiche-h2 { margin-bottom: 4px; }
.tk-fiche { padding-bottom: 4px; }
.tk-frm label { margin-top: 12px; }
.tk-titre-in {
  font-size: 19px !important; font-weight: 700;
  margin-bottom: 4px;
}
.tk-in {
  border: 0; background: var(--card); border-radius: 12px;
  padding: 11px 14px; outline: none; font-size: 16px; color: var(--txt);
  box-shadow: inset 0 0 0 1px var(--sep);
}
.tk-addrow { gap: 8px; margin-top: 8px; }
.tk-range { width: 100%; accent-color: var(--blue); }
.tk-pct { float: right; font-weight: 700; color: var(--blue); }

.tk-alerte {
  margin: 6px 0 2px; padding: 9px 12px; border-radius: 11px;
  font-size: 14px; font-weight: 600;
  background: rgba(255, 149, 0, .14); color: var(--warn);
}
.tk-alerte-g { background: var(--fill); color: var(--txt2); }

.tk-sec {
  margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--sep);
}
.tk-sec > h3 {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--txt2); margin-bottom: 10px;
}
.tk-sslb {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--txt2); margin: 12px 0 6px;
}

/* checklist */
.tk-clprog {
  height: 5px; border-radius: 3px; margin-bottom: 10px;
  background: rgba(120, 120, 128, .18); overflow: hidden;
}
.tk-clprog i {
  display: block; height: 100%; background: var(--green);
  transition: width .25s ease;
}
.tk-cli {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 2px; font-size: 15px;
  border-bottom: 1px solid var(--sep);
}
.tk-cli:last-child { border-bottom: 0; }
.tk-cli.on > span { text-decoration: line-through; color: var(--txt2); }
.tk-mini {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px;
  font-size: 14px; color: var(--txt2);
  background: var(--fill);
  transition: background .18s ease, opacity .18s ease;
}
.tk-mini:hover { background: var(--fill-2); }
.tk-mini:disabled { opacity: .3; }
.tk-mini.danger { color: var(--red); }

/* sous-tâches & dépendances */
.tk-subrow, .tk-deprow {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 2px; border-bottom: 1px solid var(--sep); font-size: 15px;
}
.tk-subrow:last-child, .tk-deprow:last-child { border-bottom: 0; }
.tk-lien {
  text-align: left; color: var(--txt); font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tk-lien:hover { color: var(--blue); text-decoration: underline; }
.tk-depres { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.tk-depcand {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: 11px; text-align: left; font-size: 15px;
  background: rgba(120, 120, 128, .1);
  transition: background .18s ease;
}
.tk-depcand:hover { background: rgba(0, 122, 255, .12); }

/* champs personnalisés */
.tk-custom { display: flex; flex-direction: column; gap: 2px; }
.tk-cf label { margin-top: 8px; }

/* pied de fiche */
.tk-meta-bas {
  margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--sep);
  font-size: 12px; color: var(--txt2); text-align: center;
}
.tk-actions { flex-wrap: wrap; }
.tk-conf-txt {
  text-align: center; color: var(--txt2); font-size: 15px;
  margin: -6px 0 16px; line-height: 1.45;
}

/* interrupteurs */
.tk-switch {
  display: flex !important; align-items: center; gap: 8px;
  font-size: 15px !important; font-weight: 500 !important;
  color: var(--txt) !important; text-transform: none !important;
  letter-spacing: 0 !important; margin-top: 10px;
}
.tk-switch input { width: auto !important; accent-color: var(--blue); }
.tk-switch.sm { font-size: 13px !important; margin-top: 0; }

/* configuration */
.tk-cfrow {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--sep); flex-wrap: wrap;
}
.tk-cfrow:last-child { border-bottom: 0; }
.tk-cfrow input[type="color"] {
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 9px;
  background: none; flex: 0 0 auto; cursor: pointer;
}
.tk-cfrow .tk-in { min-width: 110px; font-size: 15px; padding: 8px 11px; }
.tk-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--txt2);
  background: var(--fill);
  padding: 2px 7px; border-radius: 7px;
}

/* v349 : barre d'outils à deux niveaux — sur téléphone les actions
   secondaires (.tk-2) vivent dans le menu « ⋯ Plus » ; sur ordinateur le
   menu disparaît et tout reste en clair. */
/* v427 : le troisième niveau (.tk-3 : vue par défaut, modules, réglages)
   est TOUJOURS dans « ⋯ Plus », sur ordinateur aussi. */
.tk-tools .tk-3 { display: none; }
@media (max-width: 699px) {
  .tk-tools .tk-2 { display: none; }
  .tk-tools .tk-plus { display: inline-flex; }
}
/* sections repliables de la fiche : le résumé remplace l'ancien <h3> */
details.tk-sec > summary + * { margin-top: 4px; }
details.tk-plan { margin-top: 14px; padding-top: 10px; }

/* ------------------------------ responsive ----------------------------- */
@media (max-width: 699px) {
  /* v427 : sur téléphone, sélecteur en pictogrammes seuls (☰ / 🗂) pour
     tenir sur la ligne de Filtres et ⋯ Plus. */
  .tk-seg-lb { display: none; }
  .tk-viewsel .seg button { padding-left: 14px; padding-right: 14px; }
  .tk-tools { gap: 6px; }
  .tk-tools .btn { padding: 10px 14px; font-size: 15px; }
  .tk-row { padding: 11px 12px 11px 10px; gap: 10px; }
  .tk-titre { font-size: 15px; }
  .tk-right { flex-direction: row; align-items: center; gap: 4px; }
  .tk-right .tk-chip { max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
  .tk-cfrow .tk-in { min-width: 90px; }
  .tk-selbar { gap: 6px; padding: 9px 10px; }
  .tk-selbar .btn { padding: 7px 10px; font-size: 13px; }
}

/* Confort au clavier : la mise au point reste visible partout. */
.tk2 button:focus-visible,
.tk-fiche button:focus-visible,
.tk-mchip:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .tk-row, .tk-check, .tk-mchip, .tk-prog i, .tk-clprog i, .tk-fchip,
  .tk-selbar { transition: none; animation: none; }
}

/* ------------------------------ v427 : Trello pleine largeur ------------ */
/* Le Trello (vue « large ») pose .wide sur .content : plus de plafond de
   largeur, sur tablette comme sur ordinateur (la règle v194 ne le levait
   qu'au-delà de 1024 px). */
.content.tk2.wide { max-width: none; }
/* v427 : sur téléphone, « ＋ Nouvelle tâche » reste sur la ligne du fil
   d'Ariane (la règle v330 le poussait sur une 2e ligne) — il ne passe à la
   ligne que s'il manque vraiment de place. */
@media (max-width: 640px) {
  .tbar.tb-pleine .spacer:has(#tkNewTop) { flex: 1 1 auto; }
}

/* ===== v436 — Équipes : sélecteur d'équipe affichée + pastille ===== */
.tk-eq-sel { flex: none; max-width: 220px; font-weight: 600; }
.tk-eq-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.tkb-carte .tk-eq-chip { margin-top: 6px; }
@media (max-width: 640px) { .tk-eq-sel { max-width: 160px; } }
