/* ZangaPro PWA — UX mobile/desktop, safe areas, standalone */

:root {
    --pwa-theme: #1e40af;
    --pwa-bg: #f3f4f6;
    --pwa-safe-top: env(safe-area-inset-top, 0px);
    --pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
    --pwa-safe-left: env(safe-area-inset-left, 0px);
    --pwa-safe-right: env(safe-area-inset-right, 0px);
}

.pwa-hidden {
    display: none !important;
}

/* Safe areas iPhone / encoches */
html.pwa-standalone body {
    padding-top: var(--pwa-safe-top);
    padding-left: var(--pwa-safe-left);
    padding-right: var(--pwa-safe-right);
}

html.pwa-standalone .thetop > main,
html.pwa-standalone #scrollable-container {
    padding-bottom: var(--pwa-safe-bottom);
}

/* Fluidité tactile */
html.pwa-touch-device a,
html.pwa-touch-device button,
html.pwa-touch-device [role="button"],
html.pwa-touch-device summary {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

html.pwa-touch-device .tw-overflow-y-auto,
html.pwa-touch-device #scrollable-container {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* Bannière mise à jour */
.pwa-update-banner {
    position: fixed;
    z-index: 10060;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    background: #111827;
    color: #fff;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    font-size: 0.875rem;
    line-height: 1.4;
    inset-inline: max(0.75rem, env(safe-area-inset-left, 0px)) max(0.75rem, env(safe-area-inset-right, 0px));
    bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
    max-width: none;
}

.pwa-update-banner__text {
    margin: 0;
}

.pwa-update-banner__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .pwa-update-banner {
        flex-direction: row;
        align-items: center;
        inset-inline: auto;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
        max-width: min(96vw, 28rem);
    }

    .pwa-update-banner__actions {
        margin-left: auto;
        flex-wrap: nowrap;
    }
}

.pwa-btn {
    border: none;
    border-radius: 0.5rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.pwa-btn--primary {
    background: var(--pwa-theme);
    color: #fff;
}

.pwa-btn--primary:hover {
    filter: brightness(1.08);
}

.pwa-btn--ghost {
    background: transparent;
    color: #d1d5db;
}

.pwa-btn--ghost:hover {
    color: #fff;
}

/* Bouton installer (header) */
.pwa-install-btn {
    cursor: pointer;
}

/* Modal iOS — instructions Ajouter à l'écran d'accueil */
.pwa-ios-modal {
    position: fixed;
    inset: 0;
    z-index: 10070;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 1rem;
    padding-bottom: calc(1.5rem + var(--pwa-safe-bottom));
    background: rgba(0, 0, 0, 0.55);
}

.pwa-ios-modal__panel {
    width: min(100%, 22rem);
    padding: 1.25rem;
    border-radius: 1rem;
    background: #fff;
    color: #111827;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.pwa-ios-modal__panel h3 {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
    font-weight: 700;
}

.pwa-ios-modal__panel ol {
    margin: 0 0 1rem;
    padding-left: 1.25rem;
    font-size: 0.875rem;
    line-height: 1.55;
}

.pwa-ios-modal__panel .pwa-btn {
    width: 100%;
}

@media (min-width: 768px) {
    .pwa-ios-modal {
        align-items: center;
    }
}

/* Page offline */
.pwa-offline-page {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
    padding-top: calc(2rem + var(--pwa-safe-top));
    padding-bottom: calc(2rem + var(--pwa-safe-bottom));
    background: var(--pwa-bg);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.pwa-offline-card {
    max-width: 24rem;
    text-align: center;
    padding: 2rem 1.5rem;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.pwa-offline-card img {
    width: 4.5rem;
    height: 4.5rem;
    margin: 0 auto 1rem;
    object-fit: contain;
}

.pwa-offline-card h1 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
    color: #111827;
}

.pwa-offline-card p {
    margin: 0 0 1.25rem;
    color: #6b7280;
    font-size: 0.9375rem;
    line-height: 1.5;
}

@media (display-mode: standalone) {
    .pwa-install-btn {
        display: none !important;
    }

    #pwa-home-install-banner {
        display: none !important;
    }
}

/* Bannière accueil /home — orange clair, visible uniquement si app non installée */
.pwa-home-banner {
    border-radius: 1rem;
    border: 1px solid rgba(254, 215, 170, 0.9);
    background: linear-gradient(135deg, rgba(254, 243, 199, 0.97) 0%, rgba(253, 186, 116, 0.92) 100%);
    box-shadow: 0 4px 18px rgba(251, 146, 60, 0.18);
}

.pwa-home-banner__title {
    color: #9a3412;
}

.pwa-home-banner__desc {
    color: #c2410c;
}

.pwa-home-banner .pwa-btn--primary {
    background: #ea580c;
}

.pwa-home-banner .pwa-btn--primary:hover {
    background: #c2410c;
}

.pwa-home-banner__ghost-btn {
    color: #9a3412 !important;
    border: 1px solid rgba(234, 88, 12, 0.35);
}

.pwa-home-banner__ghost-btn:hover {
    background: rgba(255, 255, 255, 0.45) !important;
    color: #7c2d12 !important;
}

.pwa-home-banner .pwa-btn--ghost {
    color: rgba(154, 52, 18, 0.85);
}

.pwa-home-banner .pwa-btn--ghost:hover {
    color: #7c2d12;
}

/* Bouton actions rapides — orange visible (hors Tailwind JIT) */
.quick-actions-fab-btn:hover,
.quick-actions-fab-btn:focus {
    background-color: #f97316 !important;
}

/* Remonter en haut : sous le FAB actions rapides */
.scrolltop {
    z-index: 9990;
}
