/* 右侧边栏样式 */
.right-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh; /* 确保占满视口高度 */
    width: 250px;
    background: rgba(0, 0, 0, 0.9);
    border-left: 1px solid rgba(0, 219, 255, 0.3);
    z-index: 101;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 防止 right-sidebar 本身出现滚动条 */
}

/* 仅在桌面端应用自定义滚动条样式和更大宽度 */
@media (min-width: 769px) {
    .right-sidebar {
        width: 85vw; /* 设置为屏幕宽度的85% */
    }
    .file-tree {
        &::-webkit-scrollbar {
            width: 6px;
        }
        &::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.1);
            border-radius: 3px;
        }
        &::-webkit-scrollbar-thumb {
            background: rgba(0, 219, 255, 0.3);
            border-radius: 3px;
        }
        &::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 219, 255, 0.5);
        }
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 219, 255, 0.3) rgba(0, 0, 0, 0.1);
    }
}

/* 移动端宽度调整 */
@media (max-width: 768px) {
    .right-sidebar {
        width: 85%;
    }
    .file-tree {
        &::-webkit-scrollbar {
            width: 6px;
        }
        &::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.1);
            border-radius: 3px;
        }
        &::-webkit-scrollbar-thumb {
            background: rgba(0, 219, 255, 0.3);
            border-radius: 3px;
        }
        &::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 219, 255, 0.5);
        }
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 219, 255, 0.3) rgba(0, 0, 0, 0.1);
    }
}

/* 拖动条样式 (右侧边栏整体拖动) */
.resize-handle {
    position: absolute;
    top: 0;
    left: -5px;
    width: 10px;
    height: 100%;
    cursor: ew-resize;
    z-index: 102;
}

.right-sidebar-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.right-sidebar-header h2 {
    color: #00dbff;
    font-size: 20px;
    margin-right: auto;
}

/* 前进后退按钮 */
.nav-buttons button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    margin-left: 5px;
    opacity: 1;
    transition: opacity 0.3s;
}

.nav-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-buttons button svg {
    width: 18px;
    height: 18px;
}

/* 文件树样式 */
.file-tree {
    flex: 1;
    min-height: 0;
    overflow-y: auto; /* 确保 file-tree 触发滚动 */
    padding: 15px;
    box-sizing: border-box; /* 确保 padding 不影响高度计算 */
    max-height: calc(100vh - 150px); /* 显式设置最大高度，扣除头部和底部空间 */
}

.file-tree:not(.list-view):not(.search-results) {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    column-gap: 5px; /* 减少水平间距（默认15px改为5px，可根据需要调整） */
    row-gap: 15px; /* 保持垂直间距（可选调整） */
    align-content: start; /* 确保内容从顶部开始 */
    overflow-y: auto; /* 强制 Grid 模式触发滚动 */
    min-height: 0; /* 确保在内容不足时不会膨胀 */
}

.file-tree.list-view,
.file-tree.search-results {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto; /* 确保列表模式触发滚动 */
    min-height: 0; /* 确保在内容不足时不会膨胀 */
}

/* 文件树图标 */
.file-tree .icon {
    margin-right: 0px;
}

/* 文件名称 */
.file-tree .file-name {
    color: #fff;
}

/* 右侧边栏展开按钮 (独立) */
.right-sidebar-toggle {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 104;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.right-sidebar-toggle.hidden {
    display: none;
}

/* 右侧边栏遮罩层 */
.right-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: none;
}

/* 右键菜单 */
.context-menu {
    position: absolute;
    background-color: #333;
    border: 1px solid #555;
    border-radius: 5px;
    padding: 5px 0;
    z-index: 1002;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    min-width: 120px;
}

.context-menu .menu-item {
    padding: 8px 15px;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
}

.context-menu .menu-item:hover {
    background-color: #555;
}

/* 文件项布局 (图标视图) */
.file-item {
    width: 120px;
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    transition: background-color 0.2s, opacity 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: auto; /* 使用动态高度，确保自然高度 */
    max-height: fit-content;
    margin-bottom: 10px; /* 减少 margin-bottom，防止累积影响总高度 */
    box-sizing: border-box;
    flex-shrink: 0;
    user-select: none;
}

.file-item:hover {
    box-shadow: 0 6px 12px rgba(0, 219, 255, 0.3), 0 2px 6px rgba(0, 0, 0, 0.4);
    background-color: rgba(0, 219, 255, 0.2);
}

.file-item.cut {
    opacity: 0.5;
}

.file-item .icon {
    display: block;
    margin-bottom: 8px;
}

.file-item .file-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    margin: 0;
    max-width: 118px;
    width: 100%;
    padding: 0 2px;
    font-size: 14px;
    user-select: none;
}

/* 桌面端选中效果 */
@media (min-width: 769px) {
    .file-item.selected {
        background-color: rgba(0, 219, 255, 0.3);
    }
}

/* 搜索结果文件项样式（与列表项一致） */
.search-result-item,
.list-item {
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background-color 0.2s;
    height: 40px;
    user-select: none;
}

.search-result-item:hover,
.list-item:hover {
    background-color: rgba(0, 219, 255, 0.2);
}

.search-result-item .icon,
.list-item .icon {
    margin-right: 10px;
    margin-left: 12px;
    flex-shrink: 0;
}

.search-result-item .file-name,
.list-item .file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #fff;
    width: 50%;
    user-select: none;
}

.search-result-item .modified-time,
.list-item .modified-time {
    color: #aaa;
    white-space: nowrap;
    padding-left: 10px;
    flex-shrink: 0;
    margin-left: auto;
    user-select: none;
}

/* 桌面端选中效果 */
@media (min-width: 769px) {
    .search-result-item.selected,
    .list-item.selected {
        background-color: rgba(0, 219, 255, 0.3);
    }
}

/* 拖动条样式（仅内容区域和搜索结果保持） */
.drag-handle {
    display: none;
}

/* 空状态和错误信息 */
.empty-message, .error-message {
    text-align: center;
    padding: 20px;
    color: #aaa;
    width: 100%;
}

/* 路径栏容器 */
.path-bar-container {
    flex-shrink: 0;
    background-color: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
}

/* 路径栏样式 */
.path-bar {
    padding: 10px 15px;
    flex-grow: 1;
    display: flex;
    align-items: center;
}

.path-bar a {
    color: #00dbff;
    text-decoration: none;
    margin-right: 5px;
}

.path-bar a:hover {
    text-decoration: underline;
}

/* 搜索模式下路径栏样式 */
.path-bar.search-mode {
    justify-content: center;
}

.path-bar.search-mode span {
    color: #00dbff;
    font-size: 16px;
}

/* 底部提示文字 */
.bottom-tip {
    text-align: center;
    font-size: 12px;
    color: #999;
    padding: 10px;
    margin-top: auto;
    margin-bottom: 10px;
}

/* 自定义模态框样式（通用样式，保持原有宽度 300px） */
.custom-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #333;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 20px;
    z-index: 1003;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    color: #fff;
    width: 400px;
    max-width: 90%;
    font-family: Arial, sans-serif;
}

/* 特定于上传提示窗口的样式（宽度调整为 500px，内容居中） */
#uploadTipModal {
    width: 500px;
    text-align: center;
}

/* 上传提示窗口的段落样式 */
#uploadTipModal p {
    text-align: center;
    margin: 10px 0 15px;
    line-height: 1.5;
    color: #ddd;
}

/* 上传提示窗口的列表项 */
#uploadTipModal ul {
    list-style-type: none;
    padding-left: 0;
    margin: 10px 0 15px;
    text-align: left;
    color: #ddd;
}

#uploadTipModal ul li {
    margin: 5px 0;
    padding-left: 15px;
    position: relative;
}

#uploadTipModal ul li::before {
    content: "•";
    color: #00dbff;
    position: absolute;
    left: 0;
    font-size: 12px;
}

/* 模态框标题 */
.custom-modal h3 {
    margin: 0 0 15px;
    color: #00dbff;
    font-size: 20px;
    text-align: center;
    font-weight: bold;
}

/* 模态框输入框 */
.custom-modal input {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #fff;
    font-size: 14px;
}

/* 模态框按钮容器 */
.custom-modal .modal-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

/* 模态框按钮 */
.custom-modal button {
    padding: 10px 25px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: rgba(0, 219, 255, 0.3);
    color: #fff;
    font-size: 14px;
    transition: background 0.3s, transform 0.1s;
    min-width: 80px;
}

.custom-modal button:hover {
    background: rgba(0, 219, 255, 0.5);
    transform: translateY(-2px);
}

.custom-modal button.cancel {
    background: rgba(255, 255, 255, 0.1);
}

.custom-modal button.cancel:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 模态框遮罩层 */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1002;
}

/* 新增：列表视图表头 */
.list-header {
    display: flex;
    align-items: center;
    background-color: rgba(0, 219, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: bold;
    color: #00dbff;
    cursor: pointer;
    height: 40px;
}

.list-header span {
    padding-right: 5px;
}

.list-header .file-name {
    width: 50%;
    padding-left: 12px;
}

.list-header .modified-time {
    color: #00dbff;
    white-space: nowrap;
    padding-left: 10px;
    margin-left: auto;
    flex-shrink: 0;
}

/* 取消表头中的拖动条 */
.list-header .drag-handle {
    display: none;
}

/* 新增：显示模式切换按钮 / 退出搜索按钮 */
#display-mode-button,
#exit-search-button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 5px;
    margin-left: 10px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#display-mode-button svg,
#exit-search-button svg {
    width: 20px;
    height: 20px;
}

/* 新增：右侧边栏的关闭按钮 */
.close-right-sidebar-button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 5px;
    margin-right: 5px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 搜索输入区域样式 */
.search-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background-color: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#search-input {
    flex-grow: 1;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    color: #fff;
    outline: none;
}

#search-input:-webkit-autofill,
#search-input:-webkit-autofill:hover,
#search-input:-webkit-autofill:focus,
#search-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px rgba(0, 0, 0, 0.9) inset !important;
    -webkit-text-fill-color: #fff !important;
    background-color: transparent !important;
    background-image: none !important;
    color: #fff !important;
}

#search-button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    margin-left: 10px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#search-button svg {
    width: 16px;
    height: 16px;
}
