/* PWA Performance Optimization Styles */
/* 优化PWA启动性能和用户体验 */

/* 应用壳样式 - 确保快速渲染 */
.app-shell {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.app-shell.loaded {
    opacity: 1;
}

/* 骨架屏样式 */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-title {
    height: 24px;
    margin-bottom: 16px;
    border-radius: 4px;
}

.skeleton-button {
    height: 40px;
    width: 120px;
    border-radius: 6px;
}

/* PWA模式特定样式 */
.pwa-mode {
    /* 移除浏览器UI的间距 */
    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);
}

.pwa-mode .mobile-safe-area {
    /* 移动设备安全区域适配 */
    padding-top: max(20px, env(safe-area-inset-top));
}

/* 离线模式样式 */
.offline-mode {
    /* 离线时的视觉提示 */
    position: relative;
}

.offline-mode::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ef4444, #f59e0b);
    z-index: 9999;
    animation: offline-pulse 2s ease-in-out infinite;
}

@keyframes offline-pulse {
    0%, 100% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
}

/* 安装按钮样式 */
.pwa-install-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #3B82F6, #1d4ed8);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pwa-install-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.pwa-install-btn:active {
    transform: translateY(0);
}

/* 通知样式 */
.pwa-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-width: 300px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.pwa-notification.show {
    transform: translateX(0);
}

.pwa-notification.success {
    border-left: 4px solid #10b981;
}

.pwa-notification.error {
    border-left: 4px solid #ef4444;
}

.pwa-notification.warning {
    border-left: 4px solid #f59e0b;
}

.pwa-notification.info {
    border-left: 4px solid #3B82F6;
}

/* 加载状态样式 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3B82F6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 性能优化：减少重绘和重排 */
.performance-optimized {
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* 触摸优化 */
.touch-optimized {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* 滚动优化 */
.smooth-scroll {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* 字体加载优化 */
.font-loading {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.font-loaded {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* 响应式优化 */
@media (max-width: 768px) {
    .pwa-install-btn {
        bottom: 10px;
        right: 10px;
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .pwa-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .skeleton {
        background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
        background-size: 200% 100%;
    }
    
    .pwa-notification {
        background: #1f2937;
        color: white;
    }
}

/* 减少动画支持 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .skeleton {
        animation: none;
        background: #e5e7eb;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .pwa-install-btn {
        border: 2px solid currentColor;
    }
    
    .pwa-notification {
        border: 2px solid currentColor;
    }
}