/* =========================================================
   PWA install UX — floating FAB, iOS instruction sheet,
   and the footer "Install App" card that replaces the old
   placeholder App Store / Google Play badges.
   Visual language intentionally mirrors .theme-toggle / .qr-modal
   already in main.css so this doesn't look bolted-on.
   ========================================================= */

/* ---- Floating install button (mobile, bottom-left) ---- */
.pwa-fab {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 999;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 18px 12px 14px;
    background: #000000;
    color: #ffffff;
    border: 2px solid #000000;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.pwa-fab.is-visible {
    display: inline-flex;
    animation: pwaFabIn 0.35s ease;
}

.pwa-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.pwa-fab:active {
    transform: translateY(0);
}

.pwa-fab-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.pwa-fab-dismiss {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    color: #000000;
    border: 2px solid #000000;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

@keyframes pwaFabIn {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

body.dark-theme .pwa-fab {
    background: #ffffff;
    color: #000000;
    border-color: #ffffff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

body.dark-theme .pwa-fab-dismiss {
    background: #000000;
    color: #ffffff;
    border-color: #ffffff;
}

/* ---- Footer "Install App" card (replaces store badges) ---- */
.pwa-footer-install {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    background: #fafafa;
    text-align: left;
}

.pwa-footer-install-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 9px;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-footer-install-icon svg {
    width: 20px;
    height: 20px;
    stroke: #ffffff;
}

.pwa-footer-install-text {
    flex: 1;
    min-width: 0;
}

.pwa-footer-install-text strong {
    display: block;
    font-size: 0.92rem;
    color: #000000;
    margin-bottom: 2px;
}

.pwa-footer-install-text span {
    display: block;
    font-size: 0.78rem;
    color: #666666;
}

.pwa-footer-install-btn {
    flex-shrink: 0;
    width: auto;
    padding: 9px 16px;
    font-size: 0.82rem;
    border-radius: 8px;
}

.pwa-footer-install.is-installed {
    background: #f0faf3;
    border-color: #b7e4c7;
}

.pwa-footer-install.is-installed .pwa-footer-install-icon {
    background: #1a9c4a;
}

body.dark-theme .pwa-footer-install {
    background: #232323;
    border-color: #404040;
}

body.dark-theme .pwa-footer-install-text strong {
    color: #ffffff;
}

body.dark-theme .pwa-footer-install-text span {
    color: #b0b0b0;
}

body.dark-theme .pwa-footer-install.is-installed {
    background: #0f2318;
    border-color: #1a9c4a;
}

/* ---- iOS "Add to Home Screen" instruction sheet ---- */
.pwa-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.pwa-modal.is-open {
    display: flex;
}

.pwa-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    animation: fadeIn 0.2s ease;
}

.pwa-modal-content {
    position: relative;
    background: #ffffff;
    border-radius: 18px 18px 0 0;
    padding: 24px 24px calc(24px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    max-width: 420px;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.25);
    animation: pwaSheetIn 0.25s ease;
}

@keyframes pwaSheetIn {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.pwa-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #666666;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-modal-close:hover {
    background: #f0f0f0;
    color: #000000;
}

.pwa-modal-content h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: #000000;
    padding-right: 24px;
}

.pwa-modal-content p.pwa-modal-sub {
    font-size: 0.82rem;
    color: #666666;
    margin-bottom: 18px;
}

.pwa-modal-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pwa-modal-steps li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.88rem;
    color: #000000;
}

.pwa-modal-step-num {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #000000;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-modal-outro {
    margin: 18px 0 0;
    padding-top: 16px;
    border-top: 1px solid #eeeeee;
    font-size: 0.84rem;
    font-weight: 600;
    color: #000000;
    text-align: center;
}

.pwa-modal-steps svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: #000000;
}

body.dark-theme .pwa-modal-content {
    background: #232323;
}

body.dark-theme .pwa-modal-content h3,
body.dark-theme .pwa-modal-steps li {
    color: #ffffff;
}

body.dark-theme .pwa-modal-outro {
    color: #ffffff;
    border-top-color: #3a3a3a;
}

body.dark-theme .pwa-modal-close {
    color: #b0b0b0;
}

body.dark-theme .pwa-modal-close:hover {
    background: #333333;
    color: #ffffff;
}

body.dark-theme .pwa-modal-steps svg {
    stroke: #ffffff;
}

/* ---- Standalone-mode polish: seamless status bar on iOS ---- */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top, 0px);
    }
    .pwa-fab {
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 768px) {
    .pwa-fab {
        bottom: 15px;
        left: 15px;
        padding: 10px 14px 10px 12px;
        font-size: 0.85rem;
    }
    @media (display-mode: standalone) {
        .pwa-fab {
            bottom: calc(15px + env(safe-area-inset-bottom, 0px));
        }
    }
    .pwa-footer-install {
        flex-wrap: wrap;
    }
    .pwa-footer-install-btn {
        width: 100%;
        margin-left: 54px;
        width: calc(100% - 54px);
    }
}
