/* PWA install UI — desktop navbar + mobile bar */

.pwa-install-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(37, 99, 235, 0.25);
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #1d4ed8;
    font-family: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    white-space: nowrap;
}

.pwa-install-trigger[hidden] { display: none !important; }

.pwa-install-trigger:hover {
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.2);
}

.pwa-install-trigger:active { transform: scale(0.97); }

.pwa-install-trigger--desktop {
    margin-right: 8px;
}

.pwa-install-trigger--mobile {
    width: 100%;
    justify-content: center;
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #fff;
    border: none;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
}

.pwa-install-trigger--compact {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    border-radius: 10px;
}

.pwa-install-trigger--compact span { display: none; }

:root {
    --pwa-bar-h: 52px;
    --pwa-bar-gap: 10px;
    --pwa-bar-stack: 0px;
}

body.pwa-bar-visible {
    --pwa-bar-stack: calc(var(--pwa-bar-h) + var(--pwa-bar-gap));
}

/* Mobile floating bar */
.pwa-install-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--n-tabbar-h, 72px) + var(--n-safe-b, 0px) + 8px);
    z-index: 45;
    padding: 0;
}

.pwa-install-bar[hidden] { display: none !important; }

.native-shell-layout .pwa-install-bar {
    bottom: calc(var(--n-tabbar-h, 72px) + var(--n-safe-b, 0px) + 8px);
}

/* Botões flutuantes acima da barra PWA */
body.pwa-bar-visible .mf-fab-dock {
    bottom: calc(var(--n-tabbar-h, 72px) + var(--n-safe-b, 0px) + var(--pwa-bar-stack) + 8px);
}

body.pwa-bar-visible .native-shell-layout .native-fab,
body.pwa-bar-visible .native-shell-layout .mf-fab {
    bottom: calc(var(--n-tabbar-h, 72px) + var(--n-safe-b, 0px) + var(--pwa-bar-stack) + 12px) !important;
}

body.pwa-bar-visible .native-detail-page .md-dock {
    bottom: calc(var(--n-tabbar-h, 72px) + var(--n-safe-b, 0px) + var(--pwa-bar-stack));
}

/* Install guide sheet */
.pwa-install-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.pwa-install-overlay.is-open { opacity: 1; }

.pwa-sheet-open { overflow: hidden; }

.pwa-install-sheet {
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 12px 20px calc(env(safe-area-inset-bottom, 16px) + 20px);
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.28s ease;
}

.pwa-install-overlay.is-open .pwa-install-sheet {
    transform: translateY(0);
}

.pwa-install-sheet-handle {
    width: 36px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 99px;
    margin: 0 auto 14px;
}

.pwa-install-sheet h2 {
    margin: 0 0 14px;
    font-size: 1.125rem;
    font-weight: 800;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pwa-install-steps {
    margin: 0 0 14px;
    padding-left: 20px;
    color: #475569;
    font-size: 14px;
    line-height: 1.55;
}

.pwa-install-steps li { margin-bottom: 10px; }

.pwa-install-note {
    font-size: 12px;
    color: #64748b;
    background: #f8fafc;
    border-radius: 10px;
    padding: 10px 12px;
    margin: 0 0 14px;
}

.pwa-install-sheet-close {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
}

@media (min-width: 769px) {
    .pwa-install-overlay {
        align-items: center;
    }

    .pwa-install-sheet {
        border-radius: 20px;
        transform: translateY(20px) scale(0.96);
    }

    .pwa-install-overlay.is-open .pwa-install-sheet {
        transform: translateY(0) scale(1);
    }
}

.lg-panel-card .pwa-install-trigger--mobile {
    margin-top: 14px;
}

.lg-hero-top-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.lg-hero-top-actions .pwa-install-trigger--desktop {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.28);
    color: #fff;
    backdrop-filter: blur(8px);
}

@media (max-width: 768px) {
    .lg-hero-top .pwa-install-trigger--desktop {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .lg-panel-card .pwa-install-trigger--mobile {
        display: none !important;
    }
}

/* Toast de feedback (desktop e fallback) */
.pwa-notify-toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%) translateY(16px);
    z-index: 4000;
    max-width: min(92vw, 420px);
    padding: 12px 18px;
    border-radius: 12px;
    background: #0f172a;
    color: #f8fafc;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.pwa-notify-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.pwa-notify-toast--success { background: #166534; }
.pwa-notify-toast--error { background: #b91c1c; }
.pwa-notify-toast--info { background: #1d4ed8; }
