/* ===== PWA 样式 ===== */

/* 顶部栏 PWA 按钮 */
.topbar-btn#btnFullscreen,
.topbar-btn#btnInstall {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    transition: background-color .2s, transform .2s;
}

.topbar-btn#btnFullscreen:hover,
.topbar-btn#btnInstall:hover {
    background-color: rgba(0, 113, 227, 0.1);
    transform: scale(1.05);
}

.topbar-btn#btnInstall {
    animation: pwaInstallPulse 2s ease-in-out infinite;
}

@keyframes pwaInstallPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(0, 113, 227, 0); }
}

/* PWA 安装横幅 */
.pwa-install-banner {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    animation: pwaBannerSlideUp 0.3s ease-out;
}

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

.pwa-banner-content {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    border-radius: 14px;
    padding: 16px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.06);
    min-width: 320px;
    max-width: 420px;
}

.pwa-banner-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #0071e3, #0077ed);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-banner-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.pwa-banner-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

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

.pwa-banner-text strong {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 2px;
}

.pwa-banner-text span {
    display: block;
    font-size: 13px;
    color: #6e6e73;
    line-height: 1.4;
}

.pwa-banner-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.pwa-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}

.pwa-btn-cancel {
    background: #f2f2f7;
    color: #1d1d1f;
}

.pwa-btn-cancel:hover {
    background: #e5e5ea;
}

.pwa-btn-install {
    background: #0071e3;
    color: white;
}

.pwa-btn-install:hover {
    background: #0077ed;
    transform: scale(1.02);
}

.pwa-banner-close {
    position: absolute;
    top: 8px;
    right: 12px;
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: #86868b;
    font-size: 18px;
    cursor: pointer;
    border-radius: 50%;
    transition: all .2s;
}

.pwa-banner-close:hover {
    background: #f2f2f7;
    color: #1d1d1f;
}

.pwa-banner-content {
    position: relative;
}

/* 登录页浮动 PWA 按钮 */
.pwa-float-actions {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.pwa-float-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: all .2s;
}

.pwa-float-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

.pwa-float-btn svg {
    width: 22px;
    height: 22px;
    fill: #0071e3;
}

.pwa-float-btn.pwa-install-btn {
    animation: pwaFloatPulse 2s ease-in-out infinite;
}

@keyframes pwaFloatPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(0, 113, 227, 0.15); }
    50% { box-shadow: 0 4px 20px rgba(0, 113, 227, 0.35); }
}

/* PWA 已安装状态 */
body.pwa-installed .app-shell {
    background: var(--bg);
}

body.pwa-installed::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #0071e3, #34c759, #ff9500);
    z-index: 9999;
}

/* 全屏模式优化 */
:fullscreen {
    width: 100vw;
    height: 100vh;
}

:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
}

/* 响应式 - 小屏幕 */
@media (max-width: 480px) {
    .pwa-install-banner {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .pwa-banner-content {
        flex-wrap: wrap;
        gap: 10px;
        padding: 14px 16px;
        min-width: 0;
        max-width: none;
    }

    .pwa-banner-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .pwa-float-actions {
        bottom: 16px;
        right: 16px;
    }

    .pwa-float-btn {
        width: 44px;
        height: 44px;
    }
}

/* RTL 布局 */
html[dir="rtl"] .pwa-install-banner {
    left: 20px;
    right: auto;
}

html[dir="rtl"] .pwa-float-actions {
    left: 24px;
    right: auto;
}

html[dir="rtl"] .pwa-banner-close {
    left: 12px;
    right: auto;
}

/* 触控优化 */
@media (hover: none) {
    .pwa-float-btn {
        min-width: 48px;
        min-height: 48px;
    }

    .topbar-btn#btnFullscreen,
    .topbar-btn#btnInstall {
        min-width: 44px;
        min-height: 44px;
    }
}
