/* 浏览器兼容性修复 CSS */

/* 1. CSS变量兼容性 - 为不支持CSS变量的浏览器提供回退 */
:root {
    --primary-bg: #0a0a0a;
    --secondary-bg: #1a1a1a;
    --card-bg: #1e1e1e;
    --accent-bg: #2a2a2a;
    --primary-text: #ffffff;
    --secondary-text: #b0b0b0;
    --accent-text: #888888;
    --primary-color: #00d4ff;
    --secondary-color: #ff6b6b;
    --success-color: #4ecdc4;
    --warning-color: #ffe66d;
    --danger-color: #ff6b6b;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-success: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-danger: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --gradient-dark: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    --shadow-light: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 8px 25px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 15px 35px rgba(0, 0, 0, 0.2);
    --shadow-neon: 0 0 20px rgba(0, 212, 255, 0.3);
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. backdrop-filter 兼容性修复 */
.backdrop-blur-fallback {
    background: rgba(30, 30, 30, 0.95) !important;
    /* 为不支持backdrop-filter的浏览器提供纯色背景 */
}

/* 检测是否支持backdrop-filter */
@supports not (backdrop-filter: blur(20px)) {
    header,
    .media-library,
    .preview-area,
    .timeline-area,
    .video-ad-section {
        background: rgba(30, 30, 30, 0.98) !important;
        backdrop-filter: none !important;
    }
}

/* 3. CSS Grid 兼容性修复 */
@supports not (display: grid) {
    .workspace {
        display: flex !important;
        flex-direction: row !important;
    }
    
    .media-library {
        width: 300px !important;
        flex-shrink: 0 !important;
    }
    
    .preview-area {
        flex: 1 !important;
    }
    
    .media-grid,
    .text-grid {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 16px !important;
    }
    
    .media-item,
    .text-item {
        width: calc(50% - 8px) !important;
        min-width: 120px !important;
    }
}

/* 4. Flexbox 兼容性修复 */
.flex-fallback {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
}

.flex-center {
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
}

/* 5. transform 兼容性修复 */
.transform-hover:hover {
    -webkit-transform: translateY(-2px);
    -moz-transform: translateY(-2px);
    -ms-transform: translateY(-2px);
    -o-transform: translateY(-2px);
    transform: translateY(-2px);
}

/* 6. transition 兼容性修复 */
.transition-all {
    -webkit-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -moz-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -ms-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -o-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 7. 渐变背景兼容性修复 */
.gradient-primary-fallback {
    background: #667eea; /* 回退颜色 */
    background: -webkit-linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background: -moz-linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background: -ms-linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background: -o-linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* 8. 动画兼容性修复 */
@-webkit-keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@-moz-keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@-webkit-keyframes spin {
    0% { -webkit-transform: rotate(0deg); }
    100% { -webkit-transform: rotate(360deg); }
}

@-moz-keyframes spin {
    0% { -moz-transform: rotate(0deg); }
    100% { -moz-transform: rotate(360deg); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 9. 滚动条兼容性修复 */
.custom-scrollbar {
    /* WebKit浏览器 */
    scrollbar-width: thin;
    scrollbar-color: rgba(102, 126, 234, 0.8) rgba(255, 255, 255, 0.1);
}

.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.8);
    border-radius: 4px;
}

/* 10. 字体回退 */
.font-fallback {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

/* 11. 老版本浏览器的按钮样式修复 */
.btn-fallback {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    vertical-align: middle;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.btn-fallback:hover {
    background: #5a67d8;
    opacity: 0.9;
}

/* 12. 媒体查询兼容性 */
@media screen and (max-width: 768px) {
    .workspace {
        flex-direction: column !important;
    }
    
    .media-library {
        width: 100% !important;
        height: 300px !important;
        order: 1;
    }
    
    .preview-area {
        order: 2;
        height: 400px !important;
    }
}

/* 13. 不支持某些CSS特性的浏览器的回退样式 */
.no-css-variables {
    /* 当不支持CSS变量时的回退样式 */
    background: #0a0a0a;
    color: #ffffff;
}

.no-css-variables .btn {
    background: #667eea;
    color: white;
}

.no-css-variables .media-library,
.no-css-variables .preview-area,
.no-css-variables .timeline-area {
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 14. 特定浏览器修复 */
/* Internet Explorer 修复 */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .workspace {
        display: -ms-flexbox !important;
        -ms-flex-direction: row !important;
    }
    
    .media-library {
        -ms-flex: 0 0 300px !important;
    }
    
    .preview-area {
        -ms-flex: 1 !important;
    }
}

/* Safari 修复 */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .btn::before {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Firefox 修复 */
@-moz-document url-prefix() {
    .media-item,
    .timeline-item {
        -moz-user-select: none;
    }
}

/* 15. 降级样式 - 当所有现代特性都不支持时 */
.legacy-browser {
    background: #1a1a1a !important;
    color: #ffffff !important;
    font-family: Arial, sans-serif !important;
}

.legacy-browser .container {
    max-width: 1200px !important;
    margin: 0 auto !important;
    padding: 20px !important;
}

.legacy-browser .workspace {
    display: block !important;
}

.legacy-browser .media-library,
.legacy-browser .preview-area {
    width: 100% !important;
    margin-bottom: 20px !important;
    background: #2a2a2a !important;
    padding: 20px !important;
    border: 1px solid #444 !important;
}

.legacy-browser .btn {
    background: #0066cc !important;
    color: white !important;
    padding: 10px 20px !important;
    border: none !important;
    margin: 5px !important;
    cursor: pointer !important;
}

.legacy-browser .btn:hover {
    background: #0052a3 !important;
}
