/* taches.css : module Tâches de Synapse. Tout est limité à .synapse-taches (module intégrable dans d'autres applications). */
.synapse-taches {
  --st-fond: #f5f5f4;
  --st-surface: #ffffff;
  --st-texte: #1c1917;
  --st-doux: #78716c;
  --st-trait: #e7e5e4;
  --st-accent: #1d4ed8;
  --st-accent-texte: #ffffff;
  --st-retard: #dc2626;
  --st-etoile: #d97706;
  --st-bandeau: #fef3c7;
  --st-bandeau-texte: #78350f;
  --st-ombre: 0 10px 40px rgba(0, 0, 0, .18);
  color: var(--st-texte);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  min-width: 0;
}
@media (prefers-color-scheme: dark) {
  .synapse-taches {
    --st-fond: #0c0a09;
    --st-surface: #1c1917;
    --st-texte: #f5f5f4;
    --st-doux: #a8a29e;
    --st-trait: #292524;
    --st-accent: #60a5fa;
    --st-accent-texte: #0c0a09;
    --st-retard: #f87171;
    --st-etoile: #fbbf24;
    --st-bandeau: #422006;
    --st-bandeau-texte: #fde68a;
    --st-ombre: 0 10px 40px rgba(0, 0, 0, .6);
  }
}
.synapse-taches *, .synapse-taches *::before, .synapse-taches *::after { box-sizing: border-box; }
.synapse-taches button, .synapse-taches input, .synapse-taches textarea { font: inherit; color: inherit; }
.synapse-taches button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.synapse-taches button:disabled { cursor: default; }
.synapse-taches :focus-visible { outline: 2px solid var(--st-accent); outline-offset: 2px; }
.synapse-taches ul { list-style: none; margin: 0; padding: 0; }
.synapse-taches [hidden] { display: none !important; }

/* ---------- Barre, boutons ---------- */
.synapse-taches .barre { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.synapse-taches .barre h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.synapse-taches .actions { display: flex; gap: 4px; align-items: center; }
.synapse-taches .bouton, .synapse-taches .bouton-icone {
  min-height: 44px; min-width: 44px; padding: 0 14px; border: 0; border-radius: 10px;
  background: transparent; color: var(--st-accent); font-weight: 600;
}
.synapse-taches .bouton-icone { padding: 0; font-size: 22px; }
.synapse-taches .bouton.principal { background: var(--st-accent); color: var(--st-accent-texte); }
.synapse-taches .bouton.principal:disabled { opacity: .5; }
.synapse-taches .bouton.discret { color: var(--st-doux); font-weight: 500; margin-top: 24px; }

.synapse-taches .bandeau {
  background: var(--st-bandeau); color: var(--st-bandeau-texte); border-radius: 10px; padding: 8px 12px; margin: 4px 0 8px;
  font-size: 15px;
}
.synapse-taches .bandeau p { margin: 2px 0; }

/* ---------- Recherche et filtres ---------- */
.synapse-taches .outils { display: grid; gap: 8px; margin-bottom: 8px; }
.synapse-taches .recherche {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 10px;
  background: var(--st-trait); font-size: 16px; -webkit-appearance: none; appearance: none;
}
.synapse-taches .filtres { display: flex; flex-wrap: wrap; gap: 6px; }
.synapse-taches .puce {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; max-width: 100%; padding: 0 14px;
  border: 1px solid var(--st-trait); border-radius: 22px; background: var(--st-surface); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.synapse-taches .puce[aria-pressed="true"] { background: var(--st-texte); color: var(--st-fond); border-color: var(--st-texte); }

/* ---------- Groupes et tâches ---------- */
.synapse-taches .groupe { margin-top: 14px; }
.synapse-taches .groupe h2, .synapse-taches .faites summary {
  display: flex; align-items: baseline; gap: 8px; margin: 0 0 4px; padding: 0 4px;
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--st-doux);
}
.synapse-taches .groupe-retard h2 { color: var(--st-retard); }
.synapse-taches .compte { font-weight: 500; opacity: .8; }
.synapse-taches .groupe ul, .synapse-taches .faites ul {
  background: var(--st-surface); border-radius: 12px; overflow: hidden;
}
.synapse-taches .tache { display: flex; align-items: stretch; min-width: 0; }
.synapse-taches .tache + .tache .corps { border-top: 1px solid var(--st-trait); }
.synapse-taches .coche {
  flex: none; width: 48px; min-height: 48px; border: 0; background: transparent; padding: 0;
  display: grid; place-items: center;
}
.synapse-taches .case {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--st-doux); display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.synapse-taches .coche[aria-checked="true"] .case { background: var(--st-accent); border-color: var(--st-accent); }
.synapse-taches .coche[aria-checked="true"] .case::after {
  content: ""; width: 6px; height: 11px; border: solid var(--st-accent-texte); border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}
.synapse-taches .coche:disabled .case { border-style: dashed; opacity: .55; }
.synapse-taches .corps {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 48px;
  padding: 7px 12px 7px 0; border: 0; background: transparent; text-align: left;
}
.synapse-taches .pastille { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.synapse-taches .textes { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.synapse-taches .titre { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.synapse-taches .meta { display: flex; gap: 6px; min-width: 0; font-size: 13px; color: var(--st-doux); }
.synapse-taches .meta > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.synapse-taches .meta > * + *::before { content: "·"; margin-right: 6px; }
.synapse-taches .sous-theme { min-width: 0; }
.synapse-taches .date { flex: none; }
.synapse-taches .date.en-retard { color: var(--st-retard); font-weight: 600; }
.synapse-taches .etoile { flex: none; color: var(--st-etoile); font-size: 16px; }
.synapse-taches .tache.faite .titre { text-decoration: line-through; color: var(--st-doux); }
.synapse-taches .tache[aria-busy="true"] { opacity: .6; }
.synapse-taches .vide { margin: 32px 0; text-align: center; color: var(--st-doux); }
.synapse-taches .faites { margin-top: 20px; }
.synapse-taches .faites summary { min-height: 44px; align-items: center; cursor: pointer; list-style: none; }
.synapse-taches .faites summary::-webkit-details-marker { display: none; }
.synapse-taches .faites summary::before { content: "›"; display: inline-block; font-size: 18px; transition: transform .15s; }
.synapse-taches .faites[open] summary::before { transform: rotate(90deg); }

/* ---------- Écran Thèmes ---------- */
.synapse-taches .ecran-themes .aide { margin: 0 0 12px; }
.synapse-taches .liste-themes { background: var(--st-surface); border-radius: 12px; overflow: hidden; }
.synapse-taches .theme { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 4px 12px; }
.synapse-taches .theme + .theme { border-top: 1px solid var(--st-trait); }
.synapse-taches .theme[aria-busy="true"] { opacity: .6; }
.synapse-taches .ecran-themes h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--st-doux); margin: 24px 4px 6px; }
.synapse-taches .ajout { display: flex; gap: 8px; align-items: center; }
.synapse-taches .ajout input[type="text"] {
  flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px; border: 1px solid var(--st-trait); border-radius: 10px;
  background: var(--st-surface); font-size: 16px;
}
.synapse-taches input[type="color"] {
  flex: none; width: 44px; height: 44px; padding: 2px; border: 1px solid var(--st-trait); border-radius: 10px; background: var(--st-surface);
}
.synapse-taches .interrupteur {
  flex: none; -webkit-appearance: none; appearance: none; width: 51px; height: 31px; margin: 0; border-radius: 16px;
  background: var(--st-trait); position: relative; cursor: pointer; transition: background .15s;
}
.synapse-taches .interrupteur::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s;
}
.synapse-taches .interrupteur:checked { background: #22c55e; }
.synapse-taches .interrupteur:checked::before { transform: translateX(20px); }
.synapse-taches .interrupteur:disabled { opacity: .45; cursor: default; }
.synapse-taches .aide { font-size: 14px; color: var(--st-doux); }
.synapse-taches .erreur { color: var(--st-retard); font-size: 14px; margin: 6px 0 0; min-height: 0; }
.synapse-taches .erreur:empty { display: none; }

/* ---------- Feuille de détail ---------- */
.synapse-taches .feuille-fond {
  position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, .32); opacity: 0; transition: opacity .2s;
}
.synapse-taches .feuille-fond.ouvert { opacity: 1; }
.synapse-taches .feuille {
  position: fixed; z-index: 1001; left: 0; right: 0; bottom: 0; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  overscroll-behavior: contain; background: var(--st-surface); border-radius: 16px 16px 0 0; box-shadow: var(--st-ombre);
  padding: 6px 16px calc(16px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .25s ease-out;
  outline: none;
}
.synapse-taches .feuille.ouvert { transform: none; }
.synapse-taches .feuille form { display: grid; gap: 12px; }
.synapse-taches .poignee { width: 36px; height: 5px; border-radius: 3px; background: var(--st-trait); margin: 0 auto; }
.synapse-taches .feuille header { display: flex; align-items: center; gap: 10px; min-width: 0; }
.synapse-taches .feuille header h2 {
  flex: 1; min-width: 0; margin: 0; font-size: 15px; font-weight: 600; color: var(--st-doux);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.synapse-taches .feuille header .bouton { margin-right: -10px; }
.synapse-taches .feuille .aide { margin: 0; }
.synapse-taches .champ { display: grid; gap: 4px; min-width: 0; }
.synapse-taches .champ > span { font-size: 13px; color: var(--st-doux); }
.synapse-taches .champ textarea, .synapse-taches .champ input[type="date"] {
  width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid var(--st-trait); border-radius: 10px;
  background: var(--st-fond); font-size: 16px; resize: vertical; -webkit-appearance: none; appearance: none;
}
.synapse-taches .champ textarea[name="titre"] { font-weight: 600; }
.synapse-taches .champ :disabled { opacity: 1; color: var(--st-texte); -webkit-text-fill-color: var(--st-texte); background: transparent; }
.synapse-taches .rangee { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; }
.synapse-taches .rangee .champ:first-child { flex: 1 1 160px; }
.synapse-taches .bascule { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.synapse-taches .pied { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.synapse-taches .lien { color: var(--st-accent); font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }
.synapse-taches .pied .bouton.principal { margin-left: auto; }

@media (min-width: 700px) {
  .synapse-taches .feuille {
    left: auto; top: 0; bottom: 0; width: 420px; max-height: none; border-radius: 0;
    padding: calc(12px + env(safe-area-inset-top)) 20px 20px; transform: translateX(100%);
  }
  .synapse-taches .feuille .poignee { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .synapse-taches .feuille, .synapse-taches .feuille-fond { transition: none; }
}

/* ---------- Message en bas ---------- */
.synapse-taches .toast {
  position: fixed; z-index: 1002; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  background: var(--st-texte); color: var(--st-fond); border-radius: 12px; padding: 10px 16px; font-size: 15px; box-shadow: var(--st-ombre);
}
.synapse-taches .toast.visible { opacity: 1; transform: translate(-50%, 0); }
