/* ui.css — composants communs (voir ui.js) : tiroirs, lignes à glisser, messages, bouton flottant. */
:root {
  --vert: #047857;
  --rouge: #b91c1c;
  --bleu: #0369a1;
  --barre-bas: 64px;
  --sur-bas: env(safe-area-inset-bottom, 0px);
}

/* Navigation douce entre les pages (navigateurs récents) : fondu au lieu d'un écran blanc */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.15s; }

html { -webkit-tap-highlight-color: transparent; }
body.tiroir-ouvert { overflow: hidden; }
a, button, label, summary { touch-action: manipulation; } /* pas d'attente du double-tap */

/* Retour visuel au toucher */
.ligne:active, .tactile:active { background-color: #f1f5f9; }
.btn:active, .fab:active { transform: scale(0.97); }

/* ─── Boutons ─── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 18px;
       border-radius: 10px; border: 0; font: inherit; font-weight: 600; background: #f1f5f9; color: #1e293b; cursor: pointer;
       transition: transform 0.1s; }
.btn.primaire { background: var(--vert); color: #fff; }
.btn.danger { background: #fee2e2; color: var(--rouge); }
.btn.plein { width: 100%; }
.boutons { display: flex; gap: 8px; margin-top: 16px; }
.boutons .btn { flex: 1; }
.doux { color: #64748b; margin: 4px 0 0; }

/* ─── Lignes de liste ─── */
.ligne { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 56px; background: #fff;
         color: inherit; text-decoration: none; }

/* ─── Lignes à glisser ─── */
.swipe { position: relative; overflow: hidden; background: #fff; }
.swipe + .swipe { border-top: 1px solid #f1f5f9; }
.swipe .swipe-actions { position: absolute; top: 0; bottom: 0; right: 0; display: flex; }
.swipe:not(.glisse):not([data-ouvert="1"]) .swipe-actions { visibility: hidden; }
.swipe .swipe-actions button { width: 76px; border: 0; color: #fff; font: inherit; font-size: 13px; font-weight: 600;
                               display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; }
.swipe .swipe-actions svg { width: 22px; height: 22px; }
.swipe .a-modifier { background: var(--bleu); }
.swipe .a-supprimer { background: var(--rouge); }
.swipe > .ligne { position: relative; transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); will-change: transform; touch-action: pan-y; }
.swipe.glisse > .ligne { transition: none; }

/* ─── Tiroirs (panneaux qui montent du bas) ─── */
.voile { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); z-index: 60; opacity: 0; pointer-events: none;
         transition: opacity 0.22s; }
.voile.ouvert { opacity: 1; pointer-events: auto; }
.tiroir { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; background: #fff; border-radius: 18px 18px 0 0;
          max-height: 92vh; display: flex; flex-direction: column; padding-bottom: var(--sur-bas);
          transform: translateY(105%); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
          box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.15); }
.tiroir.ouvert { transform: translateY(0); }
.tiroir.glisse { transition: none; }
.tiroir .tiroir-tete { padding: 8px 16px 4px; flex-shrink: 0; touch-action: none; cursor: grab; }
.tiroir .tiroir-tete::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: #cbd5e1;
                               margin: 0 auto 10px; }
.tiroir .tiroir-tete h2 { margin: 0; font-size: 19px; font-weight: 700; }
.tiroir .tiroir-corps { padding: 8px 16px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
@media (min-width: 700px) {
  .tiroir { left: 50%; right: auto; bottom: auto; top: 50%; width: 520px; border-radius: 16px; max-height: 86vh;
            transform: translate(-50%, -46%); opacity: 0; pointer-events: none; transition: transform 0.2s, opacity 0.2s; }
  .tiroir.ouvert { transform: translate(-50%, -50%); opacity: 1; pointer-events: auto; }
  .tiroir .tiroir-tete { cursor: default; }
  .tiroir .tiroir-tete::before { display: none; }
}

/* ─── Messages en bas de l'écran ─── */
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--barre-bas) + var(--sur-bas) + 12px); z-index: 90;
          display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #1e293b; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 15px; max-width: 480px;
         box-shadow: 0 6px 20px rgba(15, 23, 42, 0.25); animation: toast-entre 0.22s ease-out; transition: opacity 0.3s; }
.toast.erreur { background: var(--rouge); }
.toast.part { opacity: 0; }
@keyframes toast-entre { from { transform: translateY(12px); opacity: 0; } }
@media (min-width: 768px) { .toasts { bottom: 24px; } }

/* ─── Bouton flottant « + » ─── */
.fab { position: fixed; right: 18px; bottom: calc(var(--barre-bas) + var(--sur-bas) + 16px); z-index: 40; width: 58px; height: 58px;
       border-radius: 18px; border: 0; background: var(--vert); color: #fff; display: grid; place-items: center; cursor: pointer;
       box-shadow: 0 6px 18px rgba(4, 120, 87, 0.4); transition: transform 0.1s; }
.fab svg { width: 28px; height: 28px; }
@media (min-width: 768px) { .fab { bottom: 28px; right: 32px; } }

/* Info-bulle des graphiques */
.bulle { position: fixed; z-index: 95; display: none; max-width: 260px; padding: 8px 10px; border-radius: 8px;
         background: #0b0b0b; color: #fff; font-size: 13px; line-height: 1.4; white-space: pre-line;
         pointer-events: none; box-shadow: 0 6px 18px rgba(11, 11, 11, 0.25); }
svg [data-info] { cursor: pointer; }

/* Ligne qui vient d'apparaître après une mise à jour sans rechargement (UI.rafraichir) */
li.arrive { animation: arrive 0.9s ease-out; }
@keyframes arrive {
  0% { opacity: 0; transform: translateY(-6px); background-color: #fef3c7; }
  40% { opacity: 1; transform: none; background-color: #fef3c7; }
}

/* Pendant un enregistrement : boutons bloqués (évite les doubles envois sur réseau lent) */
body.occupe { cursor: progress; }
body.occupe .tiroir button[type="submit"], body.occupe [data-ok], body.occupe .fab { opacity: 0.5; pointer-events: none; }
