/* 文件浏览器样式 */

/* 折叠按钮 - 强制悬浮在屏幕左上角 */
.file-browser-toggle {
    position: fixed !important;
    top: 20px !important;
    left: 20px !important;
    z-index: 99999 !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 16px;
    padding: 14px 18px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.5), 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 140px;
    backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    user-select: none;
    /* 强制确保按钮始终悬浮在最上层 */
    isolation: isolate;
    /* 防止被其他元素覆盖 */
    pointer-events: auto;
    /* 确保在所有容器之外 */
    margin: 0 !important;
    transform: none !important;
}

/* 确保按钮在所有情况下都悬浮 */
#fileBrowserToggle {
    position: fixed !important;
    top: 20px !important;
    left: 20px !important;
    z-index: 999999 !important;
}

.file-browser-toggle:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.6), 0 4px 15px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #7c8ef0 0%, #8a5bb8 100%);
    border-color: rgba(255, 255, 255, 0.5);
}

.file-browser-toggle:active {
    transform: translateY(-1px) scale(1.02);
    transition: all 0.1s ease;
}

.file-browser-toggle .toggle-icon {
    font-size: 18px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* 默认显示桌面图标，隐藏移动图标 */
.file-browser-toggle .mobile-icon {
    display: none;
}

.file-browser-toggle .toggle-text {
    font-size: 14px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.3px;
}

/* 确保按钮在所有设备上都能正确悬浮 */
@media (max-width: 768px) {
    .file-browser-toggle {
        top: 15px;
        left: 15px;
        padding: 8px;
        min-width: auto;
        width: 40px;
        height: 40px;
        font-size: 13px;
        border-radius: 8px;
        justify-content: center;
    }

    .file-browser-toggle .toggle-icon {
        font-size: 18px;
    }

    .file-browser-toggle .toggle-text {
        display: none;
    }

    /* 移动端显示汉堡图标，隐藏桌面图标 */
    .file-browser-toggle .desktop-icon {
        display: none;
    }

    .file-browser-toggle .mobile-icon {
        display: inline;
    }
}

/* 侧边栏 */
.file-browser-sidebar {
    position: fixed;
    top: 0;
    left: -350px;
    width: 350px;
    height: 100vh;
    background: #ffffff;
    border-right: 1px solid #e1e5e9;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: left 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.file-browser-sidebar.open {
    left: 0;
}

/* 主内容区域调整 */
.main-content {
    transition: margin-left 0.3s ease;
}

.main-content.shifted {
    margin-left: 350px;
}

/* 文件浏览器头部 */
.file-browser-header {
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-browser-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
}

.refresh-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.refresh-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* 文件浏览器内容 */
.file-browser-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* 加载状态 */
.loading-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #666;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #e1e5e9;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

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

/* 空状态 */
.empty-message {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-message p {
    margin: 0 0 8px 0;
    font-weight: 500;
}

.empty-message small {
    color: #999;
    line-height: 1.4;
}

/* 文件树 */
.file-browser-tree {
    padding: 0;
}

/* 会话项 */
.session-item {
    border-bottom: 1px solid #f0f0f0;
}

.session-header {
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    transition: background-color 0.2s ease;
}

.session-header:hover {
    background-color: #f8f9fa;
}

.session-header.expanded {
    background-color: #f0f4ff;
    border-left: 3px solid #667eea;
}

.session-info {
    flex: 1;
    min-width: 0;
}

.session-title {
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 4px 0;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-meta {
    font-size: 12px;
    color: #666;
    display: flex;
    gap: 12px;
}

.session-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.expand-icon {
    font-size: 12px;
    color: #666;
    transition: transform 0.2s ease;
}

.expand-icon.expanded {
    transform: rotate(90deg);
}

.session-action {
    background: none;
    border: none;
    font-size: 12px;
    cursor: pointer;
    padding: 3px;
    border-radius: 3px;
    transition: all 0.2s ease;
    opacity: 0.7;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.session-action:hover {
    background-color: rgba(0, 0, 0, 0.08);
    opacity: 1;
    transform: scale(1.1);
}

/* 版本列表 */
.version-list {
    background-color: #fafbfc;
    border-top: 1px solid #e1e5e9;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.version-list.expanded {
    max-height: 400px;
}

.version-item {
    padding: 12px 20px 12px 40px;
    border-bottom: 1px solid #e8eaed;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s ease;
}

.version-item:hover {
    background-color: #f0f4ff;
}

.version-item.current {
    background-color: #e8f4fd;
    border-left: 3px solid #1976d2;
}

.version-info {
    flex: 1;
    min-width: 0;
}

.version-title {
    font-weight: 500;
    color: #2c3e50;
    margin: 0 0 4px 0;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.version-badge {
    background: #667eea;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
}

.version-badge.current {
    background: #4caf50;
}

.version-description {
    font-size: 12px;
    color: #666;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.version-meta {
    font-size: 11px;
    color: #999;
    display: flex;
    gap: 8px;
}

.version-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.version-item:hover .version-actions {
    opacity: 1;
}

.version-action {
    background: none;
    border: none;
    font-size: 11px;
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    transition: all 0.2s ease;
    color: #666;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.version-action:hover {
    background-color: rgba(0, 0, 0, 0.08);
    color: #333;
    transform: scale(1.1);
}

.version-action.download {
    color: #1976d2;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .file-browser-sidebar {
        width: 100%;
        left: -100%;
    }
    
    .file-browser-sidebar.open {
        left: 0;
    }
    
    .main-content.shifted {
        margin-left: 0;
    }

    .session-meta {
        flex-direction: column;
        gap: 4px;
    }
    
    .version-meta {
        flex-direction: column;
        gap: 2px;
    }
}

/* 滚动条样式 */
.file-browser-content::-webkit-scrollbar {
    width: 6px;
}

.file-browser-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.file-browser-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.file-browser-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
