/**
 * GenSpark预览区 v5.0 - 专业商用级重构版
 * 功能：完全重构预览区架构，解决滚动和布局问题
 * 重构日期：2025-06-26
 * 核心原则：简洁高效、零冲突、商用稳定
 */

/* ==================== CSS变量系统 ==================== */
:root {
    --genspark-primary: #007bff;
    --genspark-primary-hover: #0056b3;
    --genspark-success: #28a745;
    --genspark-success-hover: #218838;
    --genspark-background: #f8f9fa;
    --genspark-surface: #ffffff;
    --genspark-border: #e9ecef;
    --genspark-text: #333333;
    --genspark-text-muted: #6c757d;
    --genspark-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --genspark-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.15);
    --genspark-transition: all 0.3s ease;
    --genspark-border-radius: 8px;
}

/* ==================== GenSpark工作区 - 主架构 ==================== */
.genspark-workspace {
    display: flex;
    flex-direction: column;
    width: 1120px;
    max-width: 1120px;
    margin: 0 auto;
    flex: 1 1 auto;
    min-height: 0;                 /* 关键，允许子元素灵活伸缩！ */
    background: var(--genspark-surface);
    border-radius: var(--genspark-border-radius);
    overflow: visible;             /* 只管理外壳，不让外壳滚动！ */
    position: relative;
    box-shadow: var(--genspark-shadow);
}
/* ==================== 标签切换区域 ==================== */
.genspark-tabs {
    flex: 0 0 auto;        /* 替换 flex-shrink: 0; */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--genspark-surface);
    border-bottom: 1px solid var(--genspark-border);
    z-index: 100;
}

.genspark-tab-buttons {
    display: flex;
    gap: 0;
    background: var(--genspark-background);
    border-radius: 6px;
    padding: 3px;
    border: 1px solid var(--genspark-border);
}

.genspark-tab-button {
    background: transparent;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--genspark-text-muted);
    border-radius: 4px;
    transition: var(--genspark-transition);
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 90px;
    justify-content: center;
}

.genspark-tab-button:hover {
    background: #333333;
    color: #ffffff;
}

.genspark-tab-button.active {
    background: #000000;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* ==================== 页码显示 ==================== */
.slide-counter {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: var(--genspark-text-muted);
    font-weight: 500;
    background: var(--genspark-background);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--genspark-border);
}

.slide-counter #current-slide {
    color: var(--genspark-primary);
    font-weight: 600;
}

/* ==================== 状态显示区域 ==================== */
.generation-status {
    padding: 10px 20px;
    background: #e3f2fd;
    border-bottom: 1px solid #bbdefb;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1976d2;
    font-size: 14px;
    flex-shrink: 0;
}

.generation-status i {
    color: #1976d2;
}
/* ==================== 内容显示区域 - 核心架构 ==================== */
.content-area {
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(100vh - 70px);
    position: relative;
    display: flex;
    flex-direction: column;
}
/* ==================== PPT预览区域 ==================== */
.slides-container {
    width: 100%;
    height: auto;
    max-height: 80vh;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f5f5f5;
    padding: 20px;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0px;
    box-sizing: border-box;
}

.slides-container.active {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 0px;
}

/* ==================== 代码显示区域 ==================== */
.code-area {
    flex: none;          /* 改这行 */
    min-height: 0;
    overflow-y: visible; /* 改这行 */
    overflow-x: hidden;
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-sizing: border-box;
    display: none;
    flex-direction: column;
    height: auto;        /* 加这行 */
}

.code-area.active {
    display: flex !important;
    flex-direction: column;
}

.code-display {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.code-header {
    padding: 15px 20px;
    background: #2d2d2d;
    color: var(--genspark-surface);
    font-size: 14px;
    font-weight: 600;
    border-radius: 12px;
    border-bottom: 1px solid #404040;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-header i {
    color: #4CAF50;
}

.code-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 20px;
    background: #1e1e1e;
}

.code-content pre {
    margin: 0;
    background: transparent;
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ==================== 代码卡片容器 ==================== */
.code-cards-container {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    background: transparent;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* ==================== 单个代码卡片 ==================== */
.code-card {
    background: transparent;  /* 改为透明 */
    border-radius: 8px;
    padding: 20px;
    border: 1px solid rgba(51, 51, 51, 0.3);  /* 边框也改为半透明 */
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    margin-bottom: 20px;
    box-shadow: none;  /* 去掉阴影 */
}
.code-card.active {
    opacity: 1;
    transform: translateY(0);
}

.code-card-header {
    color: #4CAF50;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.code-card pre {
    margin: 0;
    background: #2d2d2d;
    color: #e6e6e6;
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #404040;
}

/* ==================== PPT页面样式 - 标准16:9 ==================== */
.slide,
.preview-page,
.enterprise-slide,
.ppt-slide-frame {
    width: 98%;                      /* 或 99%、100% 看效果 */
    max-width: 1280px;               /* 跟你的PPT导出分辨率一致，比如1280px或1920px */
    aspect-ratio: 16/9;
    background: var(--genspark-surface);
    border-radius: 12px;
    box-shadow: var(--genspark-shadow);
    border: 1px solid var(--genspark-border);
    padding: 40px;
    box-sizing: border-box;
    overflow: visible;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: var(--genspark-transition);
    margin-bottom: 30px;
    position: relative;
    height: auto !important;
    min-height: 0;
}
.slide:hover,
.preview-page:hover,
.enterprise-slide:hover,
.ppt-slide-frame:hover {
    transform: translateY(-2px);
    box-shadow: var(--genspark-shadow-hover);
}

/* 🎯 竖版PPT样式支持 (9:16) */
[data-orientation="9:16"],
.slide[data-orientation="9:16"] {
    aspect-ratio: 9/16 !important;
    max-width: 720px !important;
}

/* 🎯 A4纸张样式支持 */
[data-orientation="A4"],
.slide[data-orientation="A4"] {
    aspect-ratio: 1/1.414 !important;
    max-width: 1080px !important;
}

/* 注释重复的下载按钮样式 - 统一使用ID选择器
.download-button {
    background: var(--genspark-success);
    color: var(--genspark-surface);
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--genspark-transition);
}

.download-button:hover {
    background: var(--genspark-success-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}
*/

/* 下载按钮ID选择器 - 高优先级样式 */
#download-btn {
    background: #000000 !important;
    color: white !important;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    font-weight: 500;
    height: 36px;
}

#download-btn:hover {
    background: #333333 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* 响应式样式 - 移动端适配但保持按钮原始宽度 */
@media (max-width: 992px) {
    #download-btn {
        padding: 12px 20px;
        font-size: 16px;
        min-width: 120px;
        /* 不设置 width: 100% 和 justify-content: center */
    }
}
/* ==================== 滚动条美化 ==================== */
.slides-container::-webkit-scrollbar,
.code-content::-webkit-scrollbar {
    width: 8px;
}

.slides-container::-webkit-scrollbar-track,
.code-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.slides-container::-webkit-scrollbar-thumb,
.code-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.slides-container::-webkit-scrollbar-thumb:hover,
.code-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ==================== 代码区深色滚动条 ==================== */
.code-cards-container::-webkit-scrollbar {
    width: 8px;
}

.code-cards-container::-webkit-scrollbar-track {
    background: #1e1e1e;
    border-radius: 4px;
}  

.code-cards-container::-webkit-scrollbar-thumb {
    background: #404040;
    border-radius: 4px;
}

.code-cards-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ==================== 兼容性支持 ==================== */
@supports not (aspect-ratio: 16 / 9) {
    .slide,
    .preview-page,
    .enterprise-slide,
    .ppt-slide-frame {
        height: 0;
        padding-bottom: 56.25%;
        position: relative;
    }
    
    .slide > *,
    .preview-page > *,
    .enterprise-slide > *,
    .ppt-slide-frame > * {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        padding: 20px;
        box-sizing: border-box;
    }
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 1200px) {
    .slide,
    .preview-page,
    .enterprise-slide,
    .ppt-slide-frame {
        width: 95%;
        max-width: 900px;
        padding: 30px;
    }
}

@media (max-width: 900px) {
    .slide,
    .preview-page,
    .enterprise-slide,
    .ppt-slide-frame {
        width: 100%;
        padding: 25px;
    }
    
    .slides-container {
        gap: 25px;
        padding: 15px;
    }
}

@media (max-width: 768px) {
    /* 保持slide原始尺寸，允许横向滚动 */
    [data-slide-index] {
        width: 1080px !important;
        height: 608px !important;
        flex-shrink: 0 !important;
        min-width: 1080px !important;
    }
    
    .genspark-workspace {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    .content-area {
        width: 100% !important;
        max-width: 100vw !important;
        overflow: hidden;
    }
    
    .slides-container {
        padding: 15px;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .slide,
    .preview-page,
    .enterprise-slide,
    .ppt-slide-frame {
        width: 100%;
        padding: 20px;
        font-size: 14px;
    }
    
    .slides-container {
        gap: 20px;
        padding: 10px;
    }
    
    .genspark-tab-button {
        padding: 6px 12px;
        font-size: 12px;
        min-width: 70px;
    }
    
    .genspark-tabs {
        padding: 8px 15px;
    }
}

@media (max-width: 480px) {
    /* 保持slide原始尺寸，允许横向滚动 */
    [data-slide-index] {
        width: 1080px !important;
        height: 608px !important;
        flex-shrink: 0;
        min-width: 1080px;
    }
    
    .slide,
    .preview-page,
    .enterprise-slide,
    .ppt-slide-frame {
        padding: 15px;
        font-size: 12px;
    }
    
    .slides-container {
        gap: 15px;
        width: 100%;
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}
/* ==================== 系统兼容性保障 ==================== */
/* 隐藏所有AI提示元素，避免遮挡 */
.ai-thinking-display,
.ai-thinking-text,
.thinking-bubble,
[class*="thinking"] {
    display: none !important;
}

/* 确保页面结构稳定 */
.process-status,
.process-visualization {
    display: none;
}

    display: block !important;
    margin: 15px 0;
}

/* 兼容旧版选择器 */
.preview-area,
.preview-content-area,
.content-display-container {
    /* 保持空定义以避免JS错误 */
}

/* CSS重构标记 - v5.0 专业商用版 */
/* ==================== 分屏布局优化 - v3.1 ==================== */
.split-screen {
    display: flex;
    height: calc(100vh - 80px);
    width: 100vw;
    max-width: 100vw;
    gap: 0;
}

/* 左侧输入区域 - 固定宽度 */
.input-panel {
    flex: 0 0 520px;
    max-width: 650px;
    min-width: 280px;
    padding: 50px 20px 20px 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    background: #fff;
    box-sizing: border-box;
}

/* 右侧预览区域 - 自适应填充 */
.preview-panel {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
    box-sizing: border-box;
    padding-right: 20px;        /* 新增：右侧留20px白边 */
}

/* GenSpark主工作区 - 容器管理 */
.genspark-workspace {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    background: var(--genspark-surface);
    border-radius: var(--genspark-border-radius);
    box-shadow: var(--genspark-shadow);
    overflow: visible;
    position: relative;
}

/* 标签栏 - 粘性固定顶部 */
.genspark-tabs {
    flex: 0 0 auto;
    z-index: 10;
    position: sticky;
    top: 0;
    background: var(--genspark-surface);
    border-bottom: 1px solid var(--genspark-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
}

/* 内容区 - 统一滚动管理 */
.content-area {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
}


.slide:hover,
.preview-page:hover,
.enterprise-slide:hover,
.ppt-slide-frame:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

/* 代码内容 */
.code-content {
    flex: 1 1 auto;
    min-height: 0;
    background: #1e1e1e;
    color: #fff;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
    overflow-y: auto;
    padding: 20px;
    border-radius: 8px;
}

/* 响应式优化 */
@media (max-width: 768px) {
    .split-screen {
        flex-direction: column;
        height: auto;
    }
    
    .input-panel {
        flex: 0 0 auto;
        max-width: none;
        min-width: auto;
        padding: 20px;
    }
    
    .preview-panel {
        flex: 1 1 auto;
        min-height: 400px;
    }
    
    .slide,
    .preview-page,
    .enterprise-slide,
    .ppt-slide-frame {
        width: 95%;
        max-width: none;
        padding: 20px;
        font-size: 14px;
    }
}
/* ========================================
   全新进度条系统 - 2024.06.30
   ======================================== */

.progress-container {
    width: 100%;
    margin: 20px 0;
    display: none; /* 默认隐藏 */
}

/* 进度条轨道 */
.progress-bar-wrapper {
    width: 100% !important;
    height: 12px;
    background-color: #e9ecef;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    display: block !important;
}
/* 进度条主体 */
#progressBar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #007bff 0%, #0056b3 100%);
    border-radius: 6px;
    transition: width 0.4s ease;
    position: relative;
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.3);
}

/* 进度百分比文字 */
.progress-percentage {
    text-align: center;
    font-size: 14px;
    margin-top: 8px;
    color: #333;
    font-weight: 500;
}
/* ==================== AI生成动画 - 商用简洁风格 ==================== */
.ai-animation {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    z-index: 100;
}

.animation-wrapper {
    text-align: center;
}

.ai-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.ai-text {
    color: #333;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* ==================== AI动态状态样式 ==================== */
.ai-status-container {
    margin-top: 10px;
}

.ai-subtext {
    color: #666;
    font-size: 14px;
    margin-top: 8px;
    opacity: 0.8;
}

/* 进度点动画 */
.ai-progress-dots {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.ai-progress-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ddd;
    transition: all 0.3s ease;
}

.ai-progress-dots .dot.active {
    background: #3498db;
    transform: scale(1.2);
}

/* 文字切换动画 */
.ai-text, .ai-subtext {
    transition: opacity 0.3s ease;
}