/**
 * Android APK 性能优化样式表
 * 根据设备性能等级调整动画和视觉效果
 *
 * 性能等级由 MainActivity.java 检测并设置:
 * - high: 高端设备 - 完整动画和效果
 * - medium: 中端设备 - 保留基本动画，禁用毛玻璃
 * - low: 低端设备 - 禁用所有非必要动画
 */

/* ============================================
   中端设备优化 (performance-medium)
   ============================================ */

/* 禁用毛玻璃效果（最大的性能杀手） */
html.performance-medium .glass-panel,
html.performance-medium .edit-mode-dock,
html.performance-medium .edit-mode-header,
html.performance-medium .popup-window,
html.performance-medium .popup-overlay,
html.performance-medium .beautify-panel,
html.performance-medium .icon-settings-panel,
html.performance-medium #extraBeautifyPanel,
html.performance-medium .phone-app-container,
html.performance-medium .dialogue-page,
html.performance-medium .app-slide-page {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* 使用纯色替代 */
html.performance-medium .edit-mode-dock,
html.performance-medium .edit-mode-header {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ============================================
   低端设备激进优化 (performance-low)
   ============================================ */

/* 全局禁用毛玻璃 */
html.performance-low *,
html.performance-low *::before,
html.performance-low *::after {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* 禁用复杂动画 - 保留必要过渡 */
html.performance-low * {
    animation: none !important;
    transition: transform 0.15s ease, opacity 0.15s ease !important;
}

/* 保留必要元素的过渡 */
html.performance-low .app-icon,
html.performance-low .grid-item,
html.performance-low .phone-app-container,
html.performance-low .popup-window,
html.performance-low .popup-overlay {
    transition: opacity 0.15s ease !important;
}

/* 编辑模式优化 */
html.performance-low .grid-editing .app-icon:not(.app-icon-dragging) .icon {
    animation: none !important;
}

/* 编辑模式容器不缩放 */
html.performance-low .phone-container.edit-mode-active .home-screen {
    transform: none !important;
    border-radius: 0 !important;
}

/* 简化编辑模式UI */
html.performance-low .edit-mode-dock,
html.performance-low .edit-mode-header {
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

/* 禁用复杂的幽灵元素效果 */
html.performance-low .app-icon-ghost {
    filter: none !important;
    transform: scale(1.05) !important;
}

/* 优化网格布局 */
html.performance-low .app-grid {
    will-change: auto !important;
    contain: layout style paint;
}

/* 禁用不必要的阴影 */
html.performance-low .app-icon,
html.performance-low .grid-item {
    box-shadow: none !important;
}

/* 禁用复杂的渐变 */
html.performance-low .phone-container {
    background-image: none !important;
}

/* 优化弹窗 */
html.performance-low .popup-window {
    max-height: calc(100vh - 20vh);
    transform: translateX(-50%) scale(1) !important;
}

html.performance-low .popup-window.active {
    transform: translateX(-50%) scale(1) !important;
}

/* 保留必要的交互反馈 */
html.performance-low .edit-mode-done-btn:active,
html.performance-low .edit-dock-item:active,
html.performance-low .ios-btn:active {
    opacity: 0.7 !important;
    transform: scale(0.95) !important;
}

/* 禁用布局选项弹窗的复杂动画 */
html.performance-low .layout-options-popup {
    animation: none !important;
    transform: translateX(-50%) scale(1) !important;
}

/* 简化dock显示/隐藏 */
html.performance-low .edit-mode-dock.hidden {
    transform: translateY(100%) !important;
    transition: transform 0.2s ease !important;
}

html.performance-low .edit-mode-header.hidden {
    transform: translateY(-20px) !important;
    transition: transform 0.2s ease !important;
}

/* 优化占位符 */
html.performance-low .app-icon-placeholder {
    background: rgba(0, 0, 0, 0.03) !important;
    border: 1px dashed rgba(0, 0, 0, 0.1) !important;
}

/* 禁用不必要的过渡 */
html.performance-low .app-icon-dragging {
    transition: none !important;
}

/* ============================================
   高端设备 (performance-high)
   ============================================ */

/* 高端设备启用所有效果，无需修改 */

/* ============================================
   老设备WebView特殊优化
   ============================================ */

/* 老版本Android WebView */
html[data-android-version][data-android-version_lt="60"] * {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ============================================
   GPU加速优化
   ============================================ */

/* 为需要动画的元素启用硬件加速（仅高端设备） */
html.performance-high .app-icon,
html.performance-high .grid-item,
html.performance-high .popup-window {
    will-change: transform, opacity;
}

/* 中低端设备禁用will-change以节省内存 */
html.performance-medium *,
html.performance-low * {
    will-change: auto !important;
}
