/* PWA Install Prompt — mobile iOS & Android */
#pwaInstallBanner {
    display: none;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0));
    z-index: 10100;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(11, 20, 26, 0.18);
    padding: 14px 36px 14px 16px;
    align-items: center;
    gap: 12px;
    animation: pwaSlideUp 0.35s ease;
    border: 1px solid #e9edef;
}

#pwaInstallBanner.visible {
    display: flex;
}

@keyframes pwaSlideUp {
    from { transform: translateY(110%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

#pwaInstallBanner .pwa-install-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f0f2f5;
}

#pwaInstallBanner .pwa-install-body {
    flex: 1;
    min-width: 0;
}

#pwaInstallBanner .pwa-install-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #111b21;
    margin: 0 0 2px;
    line-height: 1.25;
}

#pwaInstallBanner .pwa-install-desc {
    font-size: 0.8125rem;
    color: #667781;
    margin: 0;
    line-height: 1.35;
}

#pwaInstallBanner .pwa-install-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    flex-shrink: 0;
}

#pwaInstallBanner .pwa-btn-install {
    background: #008069;
    color: #ffffff;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

#pwaInstallBanner .pwa-btn-dismiss {
    background: transparent;
    color: #667781;
    border: none;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 0;
}

#pwaInstallBanner .pwa-btn-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: #8696a0;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

/* Bottom nav offset saat banner tampil */
body.pwa-banner-visible.page-dashboard .sidebar {
    bottom: 0;
}

body.pwa-banner-visible #pwaInstallBanner {
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
}

/* Modal iOS — Add to Home Screen */
#pwaIosModal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10150;
    background: rgba(11, 20, 26, 0.55);
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

#pwaIosModal.open {
    display: flex;
}

#pwaIosModal .pwa-ios-panel {
    background: #ffffff;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 480px;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0));
    animation: pwaSlideUp 0.3s ease;
}

#pwaIosModal .pwa-ios-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

#pwaIosModal .pwa-ios-header img {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    object-fit: cover;
}

#pwaIosModal .pwa-ios-header h3 {
    margin: 0;
    font-size: 1.05rem;
    color: #111b21;
}

#pwaIosModal .pwa-ios-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
}

#pwaIosModal .pwa-ios-steps li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    font-size: 0.9rem;
    color: #111b21;
    border-bottom: 1px solid #f0f2f5;
}

#pwaIosModal .pwa-ios-steps li:last-child {
    border-bottom: none;
}

#pwaIosModal .pwa-ios-steps .step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e7f5f2;
    color: #008069;
    font-weight: 700;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#pwaIosModal .pwa-btn-gotit {
    width: 100%;
    background: #008069;
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
}

@media (min-width: 769px) {
    #pwaInstallBanner,
    #pwaIosModal,
    #pwaPushBanner {
        display: none !important;
    }
}

/* Web Push permission banner */
#pwaPushBanner {
    display: none;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
    z-index: 10090;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(11, 20, 26, 0.18);
    padding: 14px 36px 14px 16px;
    align-items: center;
    gap: 12px;
    animation: pwaSlideUp 0.35s ease;
    border: 1px solid #e9edef;
}

#pwaPushBanner.visible {
    display: flex;
}

body.pwa-banner-visible #pwaPushBanner.visible {
    bottom: calc(140px + env(safe-area-inset-bottom, 0));
}

/* Full-screen push sheet — PWA standalone (prioritas tinggi) */
.pwa-push-sheet {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10250;
    align-items: flex-end;
    justify-content: center;
}

.pwa-push-sheet.open {
    display: flex;
}

.pwa-push-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(11, 20, 26, 0.55);
}

.pwa-push-sheet-panel {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: #ffffff;
    border-radius: 20px 20px 0 0;
    padding: 24px 20px calc(20px + env(safe-area-inset-bottom, 0));
    text-align: center;
    animation: pwaSlideUp 0.35s ease;
}

.pwa-push-sheet-title {
    margin: 14px 0 8px;
    font-size: 1.125rem;
    font-weight: 700;
    color: #111b21;
}

.pwa-push-sheet-desc {
    margin: 0 0 14px;
    font-size: 0.875rem;
    color: #667781;
    line-height: 1.45;
}

.pwa-push-sheet-list {
    list-style: none;
    margin: 0 0 18px;
    padding: 0;
    text-align: left;
    font-size: 0.8125rem;
    color: #54656f;
}

.pwa-push-sheet-list li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.pwa-push-sheet-list i {
    color: #008069;
    margin-top: 2px;
}

.pwa-btn-sheet-primary {
    width: 100%;
    padding: 14px 16px !important;
    font-size: 0.9375rem !important;
    border-radius: 24px !important;
    margin-bottom: 8px;
}

.pwa-btn-sheet-secondary {
    width: 100%;
    padding: 10px !important;
}

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

#waPushStatusDot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: auto;
    flex-shrink: 0;
    background: #ef4444;
}

#waPushStatusDot.active {
    background: #22c55e;
}

/* Konfirmasi keluar aplikasi (tombol back PWA) */
#pwaExitModal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: none;
}

#pwaExitModal.open {
    display: flex !important;
    pointer-events: auto;
}

body.pwa-exit-open {
    overflow: hidden;
}

#pwaExitModal .pwa-exit-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(11, 20, 26, 0.55);
    backdrop-filter: blur(2px);
}

#pwaExitModal .pwa-exit-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 340px;
    background: #ffffff;
    border-radius: 16px;
    padding: 24px 20px 18px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(11, 20, 26, 0.22);
    animation: pwaSlideUp 0.28s ease;
}

#pwaExitModal .pwa-exit-title {
    margin: 12px 0 8px;
    font-size: 1.125rem;
    font-weight: 600;
    color: #111b21;
}

#pwaExitModal .pwa-exit-desc {
    margin: 0 0 18px;
    font-size: 0.875rem;
    line-height: 1.45;
    color: #667781;
}

#pwaExitModal .pwa-exit-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#pwaExitModal .pwa-exit-leave {
    color: #dc2626 !important;
}

html[data-theme="dark"] #pwaExitModal .pwa-exit-panel {
    background: #202c33;
    border: 1px solid #2a3942;
}

html[data-theme="dark"] #pwaExitModal .pwa-exit-title {
    color: #e9edef;
}

html[data-theme="dark"] #pwaExitModal .pwa-exit-desc {
    color: #8696a0;
}
