/*
 * GASLAH REPORT — PWA UI styles
 * -----------------------------------------------------------------------------
 * Purely additive, namespaced under .pwa-* / [data-pwa-*] so nothing in the
 * existing app UI is affected. Covers:
 *   - Smooth page transition (fade/slide-in on load, fade-out on navigate)
 *   - Pull-to-refresh indicator (standalone only)
 *   - Snackbar (online/offline/update)
 *   - Install button
 */

/* ----------------------------------------------------- page transitions ---- */
@media (prefers-reduced-motion: no-preference) {
    html.pwa-enabled body {
        animation: pwaPageIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
    }
    html.pwa-enabled.pwa-leaving body {
        animation: pwaPageOut 0.18s ease-in forwards;
    }
}

@keyframes pwaPageIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pwaPageOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-6px); }
}

/* ---------------------------------------------------- pull to refresh ------ */
.pwa-ptr {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translate(-50%, -64px);
    z-index: 2147483200;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 6px 20px rgba(2, 44, 34, 0.22);
    pointer-events: none;
    will-change: transform, opacity;
    transition: transform 0.18s ease, opacity 0.18s ease;
    opacity: 0;
}

.pwa-ptr .pwa-ptr-spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2.5px solid rgba(5, 150, 105, 0.2);
    border-top-color: #059669;
    transition: transform 0.1s linear;
}

.pwa-ptr.pwa-ptr-refreshing {
    opacity: 1;
    transform: translate(-50%, 20px) !important;
}

.pwa-ptr.pwa-ptr-refreshing .pwa-ptr-spinner {
    animation: pwaSpin 0.7s linear infinite;
}

@keyframes pwaSpin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ snackbar ----- */
.pwa-snackbar {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(24px);
    z-index: 2147483000;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100% - 32px);
    min-width: 240px;
    padding: 12px 16px;
    border-radius: 14px;
    color: #fff;
    font-family: 'Inter', system-ui, 'Segoe UI', Arial, sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.35;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.pwa-snackbar.pwa-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.pwa-snackbar-success { background: #059669; }
.pwa-snackbar-error   { background: #ef4444; }
.pwa-snackbar-info    { background: #0f766e; }

.pwa-snackbar .pwa-snackbar-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: inline-flex;
}

.pwa-snackbar .pwa-snackbar-action {
    border: none;
    cursor: pointer;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 7px 14px;
    border-radius: 10px;
    margin-left: 4px;
}

.pwa-snackbar .pwa-snackbar-action:hover { background: rgba(255, 255, 255, 0.32); }

.pwa-snackbar .pwa-snackbar-close {
    border: none;
    cursor: pointer;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.15rem;
    line-height: 1;
    padding: 2px 4px;
}

/* ------------------------------------------------------- install button ---- */
#pwa-install-btn {
    position: fixed;
    right: 20px;
    bottom: 88px;
    z-index: 2147482000;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-family: 'Inter', system-ui, 'Segoe UI', Arial, sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 10px 26px rgba(16, 185, 129, 0.42);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

#pwa-install-btn.pwa-visible { display: inline-flex; }
#pwa-install-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(16, 185, 129, 0.5); }
#pwa-install-btn:active { transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
    .pwa-snackbar,
    .pwa-ptr,
    #pwa-install-btn { transition: none !important; }
    .pwa-ptr.pwa-ptr-refreshing .pwa-ptr-spinner { animation-duration: 1.2s; }
}
