/* =====================================================================
   APPLICATION INSTALLABLE (PWA) : bannière, guide d'installation, boutons
   Autonome : utilisé aussi par la page de connexion (sans app.css).
   ===================================================================== */
:root {
    --pwa-ink: #191919; --pwa-ink-2: #2a2a2e; --pwa-gold: #C6A22A; --pwa-gold-l: #E2C35A; --pwa-gold-d: #A8861A;
    --pwa-line: #ececf0; --pwa-muted: #8a8a95; --pwa-ease: cubic-bezier(0.4, 0, 0.2, 1);
}
[data-pwa-install][hidden] { display: none !important; }

.pwa-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
    padding: 0.62rem 1rem; border: 0; border-radius: 11px; cursor: pointer;
    font: inherit; font-size: 0.86rem; font-weight: 700; line-height: 1; white-space: nowrap; text-decoration: none;
    transition: transform .15s var(--pwa-ease), box-shadow .2s var(--pwa-ease), background .2s;
}
.pwa-btn:active { transform: scale(0.97); }
.pwa-btn.is-gold { background: linear-gradient(135deg, var(--pwa-gold-l), var(--pwa-gold-d)); color: var(--pwa-ink); box-shadow: 0 8px 18px rgba(198, 162, 42, 0.32); }
.pwa-btn.is-ghost { background: rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.82); }
.pwa-btn.is-ghost:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.pwa-btn.is-dark { background: var(--pwa-ink); color: #fff; }

/* Bannière flottante */
.pwa-banner {
    position: fixed; z-index: 1035; left: 50%; bottom: 1.25rem; width: min(560px, calc(100vw - 2rem));
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.9rem;
    padding: 0.95rem 2.6rem 0.95rem 0.95rem; border-radius: 20px; color: #fff;
    background:
        radial-gradient(80% 140% at 100% 0%, rgba(198, 162, 42, 0.32) 0%, transparent 60%),
        linear-gradient(135deg, var(--pwa-ink) 0%, var(--pwa-ink-2) 100%);
    border: 1px solid rgba(226, 195, 90, 0.25); box-shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
    transform: translate(-50%, 140%); opacity: 0; transition: transform .35s var(--pwa-ease), opacity .35s var(--pwa-ease);
}
.pwa-banner.is-open { transform: translate(-50%, 0); opacity: 1; }
.pwa-banner-icon { width: 54px; height: 54px; border-radius: 14px; background: #fff; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); }
.pwa-banner-text { min-width: 0; }
.pwa-banner-text strong { display: block; font-size: 0.95rem; }
.pwa-banner-text span { display: block; margin-top: 0.15rem; font-size: 0.76rem; line-height: 1.4; color: rgba(255, 255, 255, 0.62); }
.pwa-banner-actions { display: flex; gap: 0.4rem; }
.pwa-banner-close { position: absolute; top: 0.55rem; right: 0.55rem; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: rgba(255, 255, 255, 0.5); cursor: pointer; }
.pwa-banner-close:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
@media (max-width: 640px) {
    .pwa-banner { grid-template-columns: auto 1fr; bottom: calc(var(--bn-h, 0px) + 0.75rem); padding-right: 2.4rem; }
    .pwa-banner-actions { grid-column: 1 / -1; }
    .pwa-banner-actions .pwa-btn { flex: 1; }
}

/* Guide d'installation (feuille du bas sur mobile, fenêtre centrée sur ordinateur) */
.pwa-guide-fond { position: fixed; inset: 0; z-index: 1060; background: rgba(10, 10, 12, 0.55); backdrop-filter: blur(3px); animation: pwaFade .2s ease both; }
.pwa-guide {
    position: fixed; z-index: 1061; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(440px, calc(100vw - 2rem)); padding: 1.15rem; border-radius: 22px; background: #fff; color: var(--pwa-ink);
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35); animation: pwaPop .25s var(--pwa-ease) both;
}
.pwa-guide[hidden], .pwa-guide-fond[hidden], .pwa-banner[hidden] { display: none; }
.pwa-guide-grip { display: none; }
.pwa-guide-head { display: flex; align-items: center; gap: 0.8rem; }
.pwa-guide-icon { width: 58px; height: 58px; border-radius: 15px; box-shadow: 0 0 0 1px var(--pwa-line), 0 8px 18px rgba(0, 0, 0, 0.12); }
.pwa-guide-head strong { display: block; font-size: 1.05rem; }
.pwa-guide-head span { display: block; font-size: 0.78rem; color: var(--pwa-muted); }
.pwa-guide-head .min-w-0 { flex: 1; min-width: 0; }
.pwa-guide-close { margin-left: auto; width: 34px; height: 34px; border: 0; border-radius: 10px; background: #f3f3f6; color: var(--pwa-ink); cursor: pointer; }
.pwa-guide-benefits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; margin: 1rem 0; }
.pwa-guide-benefits span {
    display: flex; flex-direction: column; align-items: center; gap: 0.3rem; padding: 0.6rem 0.3rem; border-radius: 12px;
    background: #faf6e8; color: #6b5a1d; font-size: 0.7rem; font-weight: 600; text-align: center;
}
.pwa-guide-benefits .bi { font-size: 1.1rem; color: var(--pwa-gold-d); }
.pwa-steps { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.pwa-steps[hidden] { display: none; }
.pwa-steps li { display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.7rem; border-radius: 13px; border: 1px solid var(--pwa-line); font-size: 0.86rem; line-height: 1.45; }
.pwa-step-num { width: 26px; height: 26px; flex-shrink: 0; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--pwa-ink); color: var(--pwa-gold-l); font-weight: 800; font-size: 0.8rem; }
.pwa-ios-ico { color: #2563eb; font-size: 1rem; vertical-align: -2px; }
.pwa-guide-ok { width: 100%; padding: 0.85rem; }
@media (max-width: 640px) {
    .pwa-guide { top: auto; bottom: 0; transform: none; left: 0; width: 100%; border-radius: 22px 22px 0 0; padding-bottom: calc(1.15rem + env(safe-area-inset-bottom, 0px)); animation: pwaUp .28s var(--pwa-ease) both; }
    .pwa-guide-grip { display: block; width: 40px; height: 4px; margin: -0.3rem auto 0.9rem; border-radius: 4px; background: #dcdce3; }
}

/* Bouton d'installation dans le menu latéral */
.sb-install {
    display: flex; align-items: center; gap: 0.65rem; width: calc(100% - 1.7rem); flex-shrink: 0; margin: 0 0.85rem 0.6rem; padding: 0.65rem 0.75rem;
    border: 1px solid rgba(226, 195, 90, 0.35); border-radius: 13px; cursor: pointer; text-align: left;
    background: linear-gradient(135deg, rgba(198, 162, 42, 0.2), rgba(198, 162, 42, 0.06)); color: #fff; font: inherit;
    transition: background .2s, border-color .2s;
}
.sb-install:hover { border-color: var(--pwa-gold-l); background: linear-gradient(135deg, rgba(198, 162, 42, 0.3), rgba(198, 162, 42, 0.1)); }
.sb-install img { width: 32px; height: 32px; border-radius: 9px; background: #fff; flex-shrink: 0; }
.sb-install span { flex: 1; min-width: 0; line-height: 1.2; }
.sb-install strong { display: block; font-size: 0.82rem; }
.sb-install small { display: block; font-size: 0.7rem; color: rgba(255, 255, 255, 0.55); }
.sb-install .bi { color: var(--pwa-gold-l); }

/* Ligne « Installer » dans le panneau Profil (mobile) */
.bn-install { color: var(--pwa-ink) !important; }
.bn-install > .bi:first-child { background: linear-gradient(135deg, var(--pwa-gold-l), var(--pwa-gold-d)) !important; color: var(--pwa-ink) !important; }

/* Bouton « Actualiser » des notifications */
.pwa-toast-btn { margin-left: auto; align-self: center; padding: 0.35rem 0.7rem; border: 0; border-radius: 8px; background: var(--pwa-ink); color: #fff; font-size: 0.78rem; font-weight: 700; cursor: pointer; }

/* Mode application installée : pas de bannière, marge haute pour la barre d'état iOS */
html.is-pwa .pwa-banner { display: none !important; }
@supports (padding: env(safe-area-inset-top)) {
    html.is-pwa body { padding-top: env(safe-area-inset-top); }
}

@keyframes pwaFade { from { opacity: 0; } }
@keyframes pwaPop { from { opacity: 0; transform: translate(-50%, -46%) scale(0.97); } }
@keyframes pwaUp { from { transform: translateY(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pwa-banner, .pwa-guide, .pwa-guide-fond { transition: none; animation: none; } }

/* Notifications minimales (pages sans app.css, ex. connexion) */
.ui-toasts { position: fixed; top: 1rem; right: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: 0.6rem; width: min(380px, calc(100vw - 2rem)); }
.ui-toast { display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.85rem 0.95rem; border-radius: 13px; background: #fff; border: 1px solid var(--pwa-line); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14); font-size: 0.87rem; color: var(--pwa-ink); }
.ui-toast-icon { width: 28px; height: 28px; flex-shrink: 0; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: rgba(22, 163, 74, 0.1); color: #16a34a; }
.ui-toast-text { flex: 1; }
