/**
 * PWA — bandeau installation + shell app (chargé sur toutes les pages si PWA active).
 */

.p4g-pwa-appbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10050;
    background: #fd895a;
    color: #111827;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
    padding-top: env(safe-area-inset-top, 0);
}

.p4g-pwa-appbar__inner {
    min-height: 56px;
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.45rem;
}

.p4g-pwa-appbar__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.p4g-pwa-appbar__brand img {
    max-height: 42px;
    width: auto;
    max-width: min(220px, 72vw);
    object-fit: contain;
}

.p4g-pwa-appbar__brand-text {
    font-weight: 800;
    font-size: 1rem;
}

.p4g-pwa-appbar__back,
.p4g-pwa-appbar__refresh {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.28);
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.p4g-pwa-appbar__back[hidden] {
    visibility: hidden;
    pointer-events: none;
}

.p4g-pwa-appbar[hidden],
.p4g-pwa-bottom-nav[hidden] {
    display: none !important;
}

.p4g-pwa-appbar,
.p4g-pwa-bottom-nav {
    display: none;
}

.p4g-pwa-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10040;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.15rem;
    padding: 0.35rem 0.35rem calc(0.35rem + env(safe-area-inset-bottom, 0));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(20, 89, 130, 0.14);
    backdrop-filter: blur(10px);
}

body.p4g-pwa-standalone.p4g-pwa-has-shell .p4g-pwa-appbar:not([hidden]) {
    display: block;
}

body.p4g-pwa-standalone.p4g-pwa-has-shell .p4g-pwa-bottom-nav:not([hidden]) {
    display: grid;
}

.p4g-pwa-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 52px;
    border-radius: 12px;
    text-decoration: none;
    color: rgba(14, 32, 56, 0.68);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
}

.p4g-pwa-bottom-nav a i {
    font-size: 1.05rem;
}

.p4g-pwa-bottom-nav a.is-active {
    color: var(--bg-blue);
    background: rgba(30, 115, 190, 0.1);
}

.p4g-pwa-install-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10060;
    padding: 0.55rem 0.55rem calc(0.55rem + env(safe-area-inset-bottom, 0));
    pointer-events: none;
}

.p4g-pwa-install-banner[hidden],
.p4g-pwa-install-banner.is-dismissed {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.p4g-pwa-install-banner__inner {
    pointer-events: auto;
    max-width: 640px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.55rem;
    padding: 0.65rem 0.7rem;
    border-radius: 16px;
    background: linear-gradient(135deg, #102845 0%, #1e73be 100%);
    color: #f7f9fc;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.28);
}

.p4g-pwa-install-banner__icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.12);
}

.p4g-pwa-install-banner__icon--fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.82rem;
}

.p4g-pwa-install-banner__copy {
    display: grid;
    gap: 0.12rem;
    min-width: 0;
}

.p4g-pwa-install-banner__copy strong {
    font-size: 0.86rem;
    line-height: 1.2;
}

.p4g-pwa-install-banner__copy span {
    font-size: 0.74rem;
    line-height: 1.35;
    opacity: 0.88;
}

.p4g-pwa-install-banner__cta {
    border: 0;
    border-radius: 999px;
    padding: 0.45rem 0.85rem;
    background: #fd895a;
    color: #111827;
    font-weight: 800;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
}

.p4g-pwa-install-banner__close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    z-index: 2;
    touch-action: manipulation;
}

.p4g-pwa-ios-help,
.p4g-pwa-android-help,
.p4g-pwa-platform-help {
    position: fixed;
    inset: 0;
    z-index: 10070;
    display: none;
    place-items: end center;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0));
    background: rgba(7, 16, 28, 0.55);
    pointer-events: none;
}

.p4g-pwa-ios-help.is-open,
.p4g-pwa-android-help.is-open,
.p4g-pwa-platform-help.is-open {
    display: grid;
    pointer-events: auto;
}

.p4g-pwa-ios-help[hidden]:not(.is-open),
.p4g-pwa-android-help[hidden]:not(.is-open),
.p4g-pwa-platform-help[hidden]:not(.is-open) {
    display: none !important;
    pointer-events: none !important;
}

.p4g-pwa-ios-help__panel,
.p4g-pwa-android-help__panel,
.p4g-pwa-platform-help__panel {
    position: relative;
    width: min(100%, 420px);
    border-radius: 18px;
    background: #fff;
    color: #111827;
    padding: 1.1rem 1rem 1rem;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24);
}

.p4g-pwa-ios-help__panel h2,
.p4g-pwa-android-help__panel h2,
.p4g-pwa-platform-help__panel h2 {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
}

.p4g-pwa-ios-help__steps,
.p4g-pwa-android-help__steps,
.p4g-pwa-platform-help__steps {
    margin: 0;
    padding-left: 1.15rem;
    display: grid;
    gap: 0.55rem;
    line-height: 1.45;
}

.p4g-pwa-ios-help__steps i,
.p4g-pwa-android-help__steps i,
.p4g-pwa-platform-help__steps i {
    color: var(--bg-blue);
    margin-left: 0.25rem;
}

.p4g-pwa-ios-help__close,
.p4g-pwa-android-help__close,
.p4g-pwa-platform-help__close {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
    cursor: pointer;
    z-index: 2;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.p4g-pwa-ios-help__close i,
.p4g-pwa-android-help__close i,
.p4g-pwa-platform-help__close i {
    pointer-events: none;
}

body.p4g-pwa-has-shell {
    padding-top: calc(56px + env(safe-area-inset-top, 0));
}

body.p4g-pwa-has-bottom-nav {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0));
}

body.p4g-pwa-has-shell .p4g-cookie-fab:not(.is-hidden) {
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
    right: 0.75rem;
}

body.p4g-pwa-install-visible {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0));
}

/* Shell PWA : header site remplacé par l’appbar (toutes largeurs). */
body.p4g-pwa-shell-enabled.p4g-pwa-standalone .site-header,
body.p4g-pwa-shell-enabled.p4g-pwa-standalone .header-drawer,
body.p4g-pwa-standalone.p4g-pwa-has-shell .site-header,
body.p4g-pwa-standalone.p4g-pwa-has-shell .header-drawer {
    display: none !important;
}

body.p4g-pwa-shell-enabled.p4g-pwa-standalone .header-right .social-links,
body.p4g-pwa-shell-enabled.p4g-pwa-standalone .drawer-socials,
body.p4g-pwa-standalone.p4g-pwa-has-shell .header-right .social-links,
body.p4g-pwa-standalone.p4g-pwa-has-shell .drawer-socials {
    display: none !important;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
    body.p4g-pwa-shell-enabled .site-header,
    body.p4g-pwa-shell-enabled .header-drawer {
        display: none !important;
    }

    body.p4g-pwa-shell-enabled .header-right .social-links,
    body.p4g-pwa-shell-enabled .drawer-socials {
        display: none !important;
    }

    body.p4g-pwa-shell-enabled .p4g-pwa-appbar {
        display: block !important;
    }
}

@media (display-mode: standalone) and (max-width: 980px), (display-mode: fullscreen) and (max-width: 980px) {
    body.p4g-pwa-shell-enabled .p4g-pwa-bottom-nav {
        display: grid !important;
    }
}

html.p4g-pwa-standalone body.p4g-pwa-shell-enabled {
    padding-top: calc(56px + env(safe-area-inset-top, 0));
}

html.p4g-pwa-standalone body.p4g-pwa-shell-enabled.p4g-pwa-has-bottom-nav {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0));
}

@media (max-width: 680px) {
    .p4g-pwa-install-banner__inner {
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas:
            "icon copy close"
            "cta cta cta";
    }

    .p4g-pwa-install-banner__icon {
        grid-area: icon;
    }

    .p4g-pwa-install-banner__copy {
        grid-area: copy;
    }

    .p4g-pwa-install-banner__close {
        grid-area: close;
    }

    .p4g-pwa-install-banner__cta {
        grid-area: cta;
        width: 100%;
        margin-top: 0.15rem;
    }
}

body.theme-dark .p4g-pwa-appbar {
    background: var(--surface-panel, #1a2332);
    color: var(--text-light, #e8f0ff);
}

body.theme-dark .p4g-pwa-bottom-nav {
    background: rgba(15, 23, 42, 0.96);
    border-top-color: rgba(148, 163, 184, 0.18);
}

body.theme-dark .p4g-pwa-bottom-nav a {
    color: rgba(232, 240, 255, 0.72);
}

body.theme-dark .p4g-pwa-bottom-nav a.is-active {
    color: #8fc7ff;
    background: rgba(59, 130, 246, 0.16);
}

body.theme-dark .p4g-pwa-ios-help__panel,
body.theme-dark .p4g-pwa-android-help__panel,
body.theme-dark .p4g-pwa-platform-help__panel {
    background: var(--surface-panel, #1a2332);
    color: var(--text-light, #e8f0ff);
}
