/* Upi, le guide du site : mascotte flottante + fenêtre de discussion */
.upi { position: fixed; right: 22px; bottom: 18px; z-index: 60; font-family: var(--body); }
.upi [hidden] { display: none !important; }

/* Portrait (lanceur) */
.upi-launch { position: relative; display: block; width: 92px; height: 100px; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.upi-launch:focus-visible { outline: 3px solid var(--sky); outline-offset: 4px; border-radius: 50%; }
.upi-ring { position: relative; z-index: 1; display: block; width: 84px; height: 84px; margin: 0 auto; padding: 3px; border-radius: 50%; background: conic-gradient(from 200deg, var(--orange), var(--yellow), var(--sky), var(--navy), var(--orange)); box-shadow: 0 14px 28px -10px rgba(6, 26, 71, .55); animation: upi-float 3.6s ease-in-out infinite; transition: transform .3s; }
.upi-ring .upi-photo { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 3px solid #fff; background: #d9cdcb; }
.upi-launch:hover .upi-ring { animation-play-state: paused; transform: scale(1.06); }
.upi-ring::after { content: ""; position: absolute; right: 6px; bottom: 6px; width: 14px; height: 14px; border-radius: 50%; background: #3ddc84; border: 3px solid #fff; }
.upi-badge { position: absolute; z-index: 2; left: 0; top: 6px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--orange); border: 2.5px solid #fff; box-shadow: 0 6px 12px -4px rgba(232, 93, 0, .7); animation: upi-badge 3.6s ease-in-out infinite; }
.upi-badge svg { width: 14px; height: 14px; fill: #fff; }
.upi-shadow { position: absolute; left: 50%; bottom: 0; width: 52px; height: 9px; margin-left: -26px; border-radius: 50%; background: rgba(6, 26, 71, .22); filter: blur(2px); animation: upi-shadow 3.6s ease-in-out infinite; }
.upi-halo { position: absolute; left: 50%; top: 45px; width: 100px; height: 100px; margin: -50px 0 0 -50px; border-radius: 50%; background: radial-gradient(closest-side, rgba(255, 106, 0, .35), rgba(255, 106, 0, 0)); animation: upi-pulse 2.8s ease-out infinite; }
.upi.is-open .upi-halo, .upi.is-open .upi-badge { animation: none; opacity: 0; }
.upi.is-open .upi-ring { transform: scale(.86); animation: none; }

/* Bulle d'accueil */
.upi-teaser { position: absolute; right: 94px; bottom: 50px; width: max-content; max-width: 230px; display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 12px 34px 12px 16px; border: 0; border-radius: 18px 18px 4px 18px; background: #fff; color: var(--navy); font: inherit; cursor: pointer; box-shadow: 0 18px 40px -14px rgba(6, 26, 71, .45), 0 0 0 1px rgba(10, 42, 102, .08); animation: upi-pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.upi-teaser b { font-family: var(--head); font-size: .88rem; white-space: nowrap; }
.upi-teaser span { font-size: .82rem; color: var(--muted); }
.upi-teaser .upi-teaser-x { position: absolute; top: 6px; right: 10px; font-size: 1.1rem; line-height: 1; color: #9aa6c0; }

/* Fenêtre */
.upi-panel { position: absolute; right: 0; bottom: 110px; width: 370px; height: min(590px, calc(100vh - 150px)); display: flex; flex-direction: column; overflow: hidden; border-radius: 28px 28px 8px 28px; background: #f4f7fd; box-shadow: 0 40px 80px -30px rgba(6, 26, 71, .6), 0 0 0 1px rgba(10, 42, 102, .1); transform-origin: 100% 100%; animation: upi-open .35s cubic-bezier(.2, 1.2, .4, 1) both; }
.upi-head { position: relative; display: flex; align-items: center; gap: 12px; padding: 18px 14px 26px 18px; color: #fff; background: radial-gradient(90% 120% at 100% 0%, rgba(0, 178, 255, .45), transparent 60%), linear-gradient(150deg, #143a85, #061a47); }
.upi-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 16px; background: #f4f7fd; border-radius: 16px 16px 0 0; }
.upi-av { flex: none; width: 50px; height: 50px; border-radius: 50%; overflow: hidden; background: linear-gradient(#7fdcff, #0a8fe0); box-shadow: 0 0 0 2px #fff, 0 6px 14px -6px rgba(0, 0, 0, .5); }
.upi-av .upi-photo { display: block; width: 100%; height: 100%; object-fit: cover; }
.upi-ht { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.upi-ht b { font-family: var(--head); font-size: 1.05rem; }
.upi-ht span { font-size: .78rem; color: #b9cdf5; display: inline-flex; align-items: center; gap: 6px; }
.upi-ht span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 3px rgba(61, 220, 132, .25); }
.upi-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .1); color: #fff; cursor: pointer; }
.upi-icon:hover { background: rgba(255, 255, 255, .2); }
.upi-icon svg, .upi-send svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.upi-log { flex: 1; overflow-y: auto; padding: 8px 14px 6px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.upi-row { display: flex; align-items: flex-end; gap: 8px; animation: upi-in .3s ease both; }
.upi-user { justify-content: flex-end; }
.upi-mini { flex: none; width: 30px; height: 30px; border-radius: 50%; overflow: hidden; background: linear-gradient(#7fdcff, #0a8fe0); box-shadow: 0 0 0 1.5px #fff, 0 3px 8px -3px rgba(10, 42, 102, .5); }
.upi-mini .upi-photo { display: block; width: 100%; height: 100%; object-fit: cover; }
.upi-msg { max-width: 82%; padding: 10px 14px; font-size: .88rem; line-height: 1.45; border-radius: 18px; }
.upi-msg p { margin: 0; }
.upi-msg p + p { margin-top: 6px; }
.upi-bot .upi-msg { background: #fff; color: #23314f; border-bottom-left-radius: 5px; box-shadow: 0 6px 16px -10px rgba(10, 42, 102, .35); }
.upi-user .upi-msg { background: linear-gradient(135deg, #ff7f22, var(--orange-600)); color: #fff; border-bottom-right-radius: 5px; }
.upi-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.upi-links a { font-family: var(--head); font-size: .76rem; font-weight: 700; color: var(--navy); text-decoration: none; padding: 6px 10px; border-radius: 10px; background: #eaf6ff; box-shadow: inset 0 0 0 1px rgba(0, 178, 255, .35); }
.upi-links a:hover { background: var(--navy); color: #fff; box-shadow: none; }
.upi-typing .upi-msg { display: flex; gap: 5px; padding: 14px 16px; }
.upi-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--sky); animation: upi-dot 1s infinite; }
.upi-typing i:nth-child(2) { animation-delay: .15s; }
.upi-typing i:nth-child(3) { animation-delay: .3s; }

.upi-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 8px 50px; }
.upi-chips:empty { display: none; }
.upi-chips button { font: inherit; font-family: var(--head); font-size: .74rem; font-weight: 700; color: var(--orange-600); padding: 6px 11px; border-radius: 999px; border: 1px solid rgba(255, 106, 0, .45); background: #fff; cursor: pointer; transition: background-color .2s, color .2s; }
.upi-chips button:hover { background: var(--orange); color: #fff; border-color: var(--orange); }

.upi-form { display: flex; gap: 8px; margin: 0 12px; padding: 6px 6px 6px 14px; border-radius: 16px; background: #fff; box-shadow: 0 0 0 1px #d5deee; }
.upi-form:focus-within { box-shadow: 0 0 0 2px var(--sky); }
.upi-form input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: inherit; font-size: .9rem; color: var(--navy); }
.upi-send { flex: none; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 12px; background: var(--navy); color: #fff; cursor: pointer; }
.upi-send:hover { background: var(--orange); }
.upi-note { margin: 0; padding: 8px 14px 12px; font-size: .68rem; color: #8b96ad; text-align: center; }

@keyframes upi-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes upi-shadow { 0%, 100% { transform: scaleX(1); opacity: 1; } 50% { transform: scaleX(.75); opacity: .6; } }
@keyframes upi-pulse { 0% { transform: scale(.7); opacity: .9; } 100% { transform: scale(1.3); opacity: 0; } }
@keyframes upi-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes upi-badge { 0%, 60%, 100% { transform: scale(1) rotate(0); } 68% { transform: scale(1.15) rotate(-10deg); } 76% { transform: scale(1.1) rotate(8deg); } 84% { transform: scale(1) rotate(0); } }
@keyframes upi-wave { 0%, 55%, 100% { transform: rotate(0); } 62% { transform: rotate(-14deg); } 70% { transform: rotate(8deg); } 78% { transform: rotate(-12deg); } 86% { transform: rotate(6deg); } }
@keyframes upi-pop { from { opacity: 0; transform: translate(10px, 10px) scale(.6); } }
@keyframes upi-open { from { opacity: 0; transform: scale(.4) translateY(20px); } }
@keyframes upi-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes upi-dot { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 560px) {
  .upi { right: 12px; bottom: 10px; }
  .upi-launch { width: 78px; height: 86px; }
  .upi-ring { width: 70px; height: 70px; }
  .upi-halo { top: 38px; }
  .upi-panel { position: fixed; left: 8px; right: 8px; bottom: 96px; width: auto; height: min(560px, calc(100dvh - 116px)); }
  .upi-teaser { right: 80px; bottom: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .upi *, .upi-panel { animation: none !important; }
}
