/* Confirmation d'envoi de fichier sur l'élément (voir assets/js/modules/upload_fb.js).
   Couleurs du badge fixes : il est posé sur une photo assombrie, quel que soit le thème.
   Format "inline" (ligne, bouton) : suit les couleurs du thème, avec replis pour les pages autonomes. */
.upfb-host { position: relative; }
.upfb-wrap { display: inline-block; max-width: 100%; vertical-align: top; line-height: 0; }
.upfb-wrap > img, .upfb-wrap > canvas, .upfb-wrap > video { display: block; max-width: 100%; }
.upfb-host > img, .upfb-host > canvas, .upfb-host > video { transition: filter .25s ease; }
.upfb-host.upfb-busy > img, .upfb-host.upfb-busy > canvas, .upfb-host.upfb-busy > video,
.upfb-host.upfb-busy .upfb-wrap > img { filter: brightness(.45); }
.upfb-host.upfb-failed > img, .upfb-host.upfb-failed .upfb-wrap > img { filter: brightness(.45) grayscale(.6); }

.upfb {
  --upfb-ok: #1e9e4a; --upfb-err: #e0352b; --upfb-off: #c46a00;
  font-family: inherit; line-height: 1.2; pointer-events: none;
  transition: opacity .3s ease;
}
.upfb.is-out { opacity: 0; }

/* ── Sur la vignette ── */
.upfb--overlay {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: #fff; text-align: center; padding: 6px;
  animation: upfbIn .2s ease-out;
}
.upfb--overlay.is-ok, .upfb--overlay.is-off { background: rgba(0,0,0,.28); }
.upfb--overlay.is-err { background: rgba(0,0,0,.5); }
.upfb--overlay .upfb-text {
  font-size: .79rem; font-weight: 600; letter-spacing: .01em; max-width: 100%;
  text-shadow: 0 1px 3px rgba(0,0,0,.7); font-variant-numeric: tabular-nums;
}

/* Badge : anneau de progression, puis disque coloré avec l'icône tracée */
.upfb-badge { position: relative; width: 36px; height: 36px; flex: none; display: block; }
.upfb-badge svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.upfb-ring { transform: rotate(-90deg); }
.upfb-track { fill: none; stroke: rgba(255,255,255,.28); stroke-width: 3; }
.upfb-bar { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset .25s linear, fill .2s ease, stroke .2s ease; }
.upfb.is-wait .upfb-ring { animation: upfbSpin .9s linear infinite; transform-origin: 50% 50%; }
.upfb.is-wait .upfb-bar { transition: none; }
.upfb.is-ok .upfb-bar { fill: var(--upfb-ok); stroke: var(--upfb-ok); }
.upfb.is-err .upfb-bar { fill: var(--upfb-err); stroke: var(--upfb-err); }
.upfb.is-off .upfb-bar { fill: var(--upfb-off); stroke: var(--upfb-off); }
.upfb.is-ok .upfb-track, .upfb.is-err .upfb-track, .upfb.is-off .upfb-track { stroke: transparent; }
.upfb.is-ok .upfb-badge, .upfb.is-err .upfb-badge, .upfb.is-off .upfb-badge { animation: upfbPop .42s cubic-bezier(.34,1.56,.64,1); }
.upfb-icon { padding: 6px; box-sizing: border-box; }
.upfb-mark { fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 30; stroke-dashoffset: 30; animation: upfbDraw .34s cubic-bezier(.65,0,.35,1) .1s forwards; }
.upfb-mark2 { animation-delay: .22s; }

.upfb-retry {
  pointer-events: auto; margin-top: 2px; min-height: 32px; padding: 6px 14px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: #fff; color: #1a1a1a; font: inherit; font-size: .79rem; font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,.35); transition: transform .15s ease;
}
.upfb-retry { display: inline-flex; align-items: center; gap: 5px; }
.upfb-retry svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
/* Vignette moyenne (téléphone) : badge plus petit ; en échec, le bouton Réessayer porte le sens */
.upfb--compact { gap: 4px; }
.upfb--compact .upfb-badge { width: 30px; height: 30px; }
.upfb--compact.is-err .upfb-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.upfb--compact.is-err { flex-direction: row; }
.upfb--compact .upfb-retry { min-height: 32px; min-width: 32px; padding: 6px; justify-content: center; }
.upfb--compact .upfb-retry span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Petite vignette : texte réservé aux lecteurs d'écran, bouton réduit à l'icône */
.upfb--mini .upfb-text, .upfb--mini .upfb-retry span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.upfb--mini .upfb-badge { width: 28px; height: 28px; }
.upfb--mini .upfb-retry { min-height: 28px; min-width: 28px; padding: 6px; justify-content: center; }
.upfb-retry:hover { transform: scale(1.04); }
.upfb-retry:active { transform: scale(.96); }
.upfb-retry:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ── En ligne (document sans vignette, bouton d'import) ── */
.upfb--inline {
  display: inline-flex; align-items: center; gap: 7px; vertical-align: middle;
  margin: 2px 6px; font-size: .79rem; font-weight: 600;
  color: var(--text, inherit); animation: upfbIn .2s ease-out;
}
.upfb--inline .upfb-badge { width: 20px; height: 20px; }
.upfb--inline .upfb-track { stroke: var(--border, rgba(127,127,127,.3)); }
.upfb--inline .upfb-bar { stroke: var(--accent, #4a7312); }
.upfb--inline .upfb-icon { padding: 3px; }
.upfb--inline .upfb-mark { stroke-width: 3; }
.upfb--inline .upfb-text { font-variant-numeric: tabular-nums; }
.upfb--inline.is-ok .upfb-text { color: var(--green, #12702d); }
.upfb--inline.is-err .upfb-text { color: var(--red, #c02010); }
.upfb--inline.is-off .upfb-text { color: var(--orange, #955300); }
.upfb--inline.is-err { pointer-events: auto; }
.upfb--inline .upfb-retry { margin: 0 0 0 2px; min-height: 28px; padding: 4px 12px;
  background: var(--glass-h, #f0f0f0); color: var(--text, #1a1a1a); box-shadow: none; border: 1px solid var(--border, rgba(0,0,0,.15)); }
.upfb--inline .upfb-retry:focus-visible { outline-color: var(--accent, #4a7312); }

/* ── Récapitulatif d'envoi multiple ── */
.upfb-recap {
  display: flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%;
  margin: 0 0 8px; padding: 6px 12px 6px 8px; border-radius: 999px;
  font-size: .82rem; font-weight: 600; line-height: 1.25;
  background: var(--green-bg, rgba(26,138,58,.11)); color: var(--green, #12702d);
  animation: upfbRecapIn .32s cubic-bezier(.34,1.4,.64,1); transition: opacity .3s ease, transform .3s ease;
}
.upfb-recap.is-off { background: var(--orange-bg, rgba(170,96,0,.09)); color: var(--orange, #955300); }
.upfb-recap.is-err { background: var(--red-bg, rgba(192,32,16,.09)); color: var(--red, #c02010); }
.upfb-recap svg { width: 18px; height: 18px; flex: none; }
.upfb-recap .upfb-mark { stroke: currentColor; }
.upfb-recap.is-out { opacity: 0; transform: translateY(-4px); }

@keyframes upfbIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes upfbSpin { to { transform: rotate(270deg); } }
@keyframes upfbPop { 0% { transform: scale(.7); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes upfbDraw { to { stroke-dashoffset: 0; } }
@keyframes upfbRecapIn { from { opacity: 0; transform: translateY(-6px) scale(.96); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .upfb, .upfb-badge, .upfb-recap { animation: none !important; }
  .upfb.is-wait .upfb-ring { animation-duration: 2.4s; }
  .upfb-mark { animation: none; stroke-dashoffset: 0; }
  .upfb-bar { transition: none; }
}
