/* PWA 相關樣式 */

/* ========== PWA 更新通知 ========== */
.pwa-update-notification {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 35, 50, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    padding: 20px 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(74, 158, 255, 0.3);
    z-index: 10000;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    min-width: 350px;
    max-width: 90%;
}

.pwa-update-notification.show {
    top: 20px;
}

.pwa-update-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.pwa-update-icon {
    font-size: 32px;
    animation: rotate 2s linear infinite;
}

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

.pwa-update-text {
    flex: 1;
}

.pwa-update-text strong {
    display: block;
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: 4px;
}

.pwa-update-text p {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 0;
}

.pwa-update-button {
    padding: 8px 20px;
    background: linear-gradient(135deg, #4a9eff 0%, #6bb6ff 100%);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.pwa-update-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(74, 158, 255, 0.4);
}

.pwa-update-close {
    padding: 8px 15px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
}

.pwa-update-close:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-primary);
}

/* ========== PWA 安裝橫幅 ========== */
.pwa-install-banner {
    position: fixed;
    bottom: -200px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 35, 50, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 15px;
    padding: 20px 25px;
    box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(74, 158, 255, 0.3);
    z-index: 10000;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    min-width: 350px;
    max-width: 90%;
}

.pwa-install-banner.show {
    bottom: 20px;
}

.pwa-install-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.pwa-install-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-install-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pwa-install-text {
    flex: 1;
}

.pwa-install-text strong {
    display: block;
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: 4px;
}

.pwa-install-text p {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 0;
}

.pwa-install-button {
    padding: 10px 25px;
    background: linear-gradient(135deg, #4a9eff 0%, #6bb6ff 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.pwa-install-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(74, 158, 255, 0.4);
}

.pwa-install-close {
    width: 30px;
    height: 30px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pwa-install-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ========== PWA 獨立模式樣式調整 ========== */
.pwa-standalone .navbar {
    padding-top: calc(20px + env(safe-area-inset-top));
}

.pwa-standalone body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* iOS Safari 瀏海屏適配 */
@supports (padding: max(0px)) {
    .pwa-standalone .navbar {
        padding-top: max(20px, env(safe-area-inset-top));
    }
}

/* ========== 離線指示器 ========== */
.offline-indicator {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 152, 0, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.offline-indicator::before {
    content: "📡";
    font-size: 16px;
}

/* ========== PWA 分享按鈕 ========== */
.pwa-share-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 25px;
    color: var(--accent-color);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.pwa-share-button:hover {
    background: rgba(74, 158, 255, 0.2);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.pwa-share-button::before {
    content: "🔗";
    font-size: 16px;
}

/* ========== 響應式設計 ========== */
@media (max-width: 768px) {
    .pwa-update-notification,
    .pwa-install-banner {
        min-width: auto;
        width: calc(100% - 40px);
        left: 20px;
        transform: none;
    }

    .pwa-update-notification.show {
        left: 20px;
    }

    .pwa-install-banner.show {
        left: 20px;
    }

    .pwa-update-content,
    .pwa-install-content {
        flex-wrap: wrap;
    }

    .pwa-update-button,
    .pwa-install-button {
        padding: 8px 15px;
        font-size: 13px;
    }

    .pwa-update-close {
        padding: 8px 12px;
        font-size: 12px;
    }

    .offline-indicator {
        top: 70px;
        padding: 8px 15px;
        font-size: 12px;
        left: 20px;
        transform: none;
        right: 20px;
        width: auto;
    }
}

/* ========== iOS 特定樣式 ========== */
@supports (-webkit-touch-callout: none) {
    .pwa-install-banner {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
    
    .pwa-standalone .main-content {
        padding-bottom: calc(50px + env(safe-area-inset-bottom));
    }
}

/* ========== 載入動畫（PWA 啟動時）========== */
.pwa-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    animation: fadeOut 0.5s ease 1s forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

.pwa-loading-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
    animation: pulse 2s ease-in-out infinite;
}

.pwa-loading-text {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* ========== 快取狀態指示器 ========== */
.cache-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(76, 175, 80, 0.9);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: slideUp 0.3s ease;
}

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

.cache-status::before {
    content: "✓";
    font-size: 14px;
}

.cache-status.caching {
    background: rgba(255, 193, 7, 0.9);
}

.cache-status.caching::before {
    content: "⏳";
    animation: rotate 1s linear infinite;
}
