/* 文件夹面板（从 style.css 拆分） */
/* --- Main Content & Folders --- */
#main-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.folders-panel-wrapper {
    flex: 0 0 400px; /* 固定宽度，不拉伸不收缩 */
    position: sticky; /* 让面板“吸附” */
    top: 20px; /* 顶部留白 */
    align-self: stretch; /* 让外层撑满 flex 容器的高度 */
    max-height: calc(100vh - 40px); /* 限制面板高度并添加留白 */
    display: flex; /* 添加 flex 让子元素可撑满 100% */
}

.folders-panel {
    background-color: var(--card-background);
    border-radius: var(--global-border-radius);
    border: 1px solid var(--border-color);
    padding: 12px; /* 恢复对称留白 */
    overflow: hidden; /* 去掉面板本身的滚动，改由内部区块滚动 */
    display: flex; /* 用 flexbox 进行内部布局 */
    flex-direction: column; /* 元素纵向排列 */
    /* Firefox 滚动条样式 */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    height: 100%; /* 让面板撑满外层父级的高度 */
}

.folders-header {
    font-size: 18px;
    font-weight: 700;
    padding-left: 16px; 
    margin-bottom: 16px;
    padding-bottom: 16px; /* 仅保留到分隔线的留白 */
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

/* 文件夹面板中的提示 */
.folders-hint {
    display: flex;
    flex-direction: column;
    gap: 4px; /* 缩小提示行间距 */
    font-size: 14px;
    color: var(--secondary-text-color);
    text-align: center;
    padding: 0 16px 16px; 
    margin-bottom: 16px; /* 到文件夹列表的留白 */
    border-bottom: 1px solid var(--border-color); 
    line-height: 1.4;
    font-weight: 500;
}

/* 提示中“按键”的样式 */
.folders-hint kbd {
    display: inline-block;
    font-family: inherit;
    font-weight: 600;
    background-color: var(--border-color);
    border: 1px solid var(--secondary-text-color);
    border-radius: 4px;
    padding: 2px 6px;
    color: var(--text-color);
    box-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

/* Webkit 浏览器滚动条样式 (Chrome, Safari, Edge) */
.folders-panel::-webkit-scrollbar {
    width: 8px; /* 缩小滚动条宽度 */
}

.folders-panel::-webkit-scrollbar-track {
    background: transparent; /* 让轨道背景透明 */
    margin: 16px 0; /* 添加垂直留白，使滚动条不贴顶底 */
}

.folders-panel::-webkit-scrollbar-thumb {
    background-color: var(--border-color); /* 滑块颜色 */
    border-radius: 4px; /* 圆角化 */
    border: 2px solid transparent; /* 营造距边缘的留白效果 */
    background-clip: padding-box;
}

.folders-panel::-webkit-scrollbar-thumb:hover {
    background-color: var(--accent-color); /* 悬停时改变颜色 */
}

.folders-list-container {
    display: grid; /* 改为 grid */
    grid-template-columns: repeat(2, 1fr); /* 2 列 */
    grid-auto-rows: min-content; /* 指定行高随内容变化 */
    gap: 10px;
    overflow-y: auto; /* 滚动现在由此处控制 */
    padding-right: 4px; /* 小幅留白，使滚动条不贴卡片 */
    margin-right: -4px; /* 补偿留白以不破坏居中 */
}

.folder-item {
    display: flex;
    flex-direction: column;
    padding: 0;
    border-radius: var(--global-border-radius);
    background-color: var(--card-background);
    cursor: pointer;
    transition: box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);

    /* --- [关键渲染修复] 请勿删除此块 --- */
    /* 以下属性修复 WebKit/Blink (Chrome/Safari) 的一个 bug， */
    /* 即滚动和懒加载时 border-radius 失效（圆角变直角）的问题。 */
    
    /* 1. 强制遮罩，按圆角裁剪内容 */
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    mask-image: radial-gradient(white, black);

    /* 2. 提升到独立的 GPU 合成层，与画廊重绘隔离 */
    transform: translateZ(0);
    will-change: transform;
    /* -------------------------------------------------- */
}
/* 激活文件夹的样式 */
.folder-item.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(10, 132, 255, 0.4);
}

/* 删除文件夹按钮 */
.folder-delete-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 24px;
    height: 24px;
    background-color: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3; /* 层级高于渐变和缩略图 */
    opacity: 0; /* 默认隐藏 */
    transform: scale(0.8);
    transition: opacity 0.2s, transform 0.2s, background-color 0.2s;
}
.folder-item:hover .folder-delete-btn {
    opacity: 1;
    transform: scale(1);
}
.folder-delete-btn:hover {
    background-color: #e53935; /* 删除操作用红色 */
    transform: scale(1.1);
}
/* “未分类”文件夹的附加样式 */
.folder-item--unsorted {
    /* 去掉常驻高亮，现仅在带 .active 类时应用 */
}

/* 为提升文字可读性的渐变，移到卡片自身 */
.folder-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    transition: background-color 0.2s ease-in-out; /* 高亮的平滑过渡 */
    z-index: 1;
}

/* 文件夹重命名模式的样式 */
.folder-item.is-renaming .folder-name {
    opacity: 0; /* 隐藏旧名称 */
}

.folder-item.is-renaming::after {
    /* 加强渐变以与输入框形成更好对比 */
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent 80%);
}


.folder-item:hover {
    /* 放大效果现通过缩放子元素实现 */
}

/* 最稳妥的方式：动画化背景尺寸而非元素几何 */
.folder-item:hover .folder-item-thumbnail-container,
.folder-item.drag-over .folder-item-thumbnail-container {
    background-size: 105% 105%;
}

.folder-item.drag-over {
    border-color: var(--accent-color);
}

.folder-item.drag-over {
    /* 去掉卡片自身的背景变化 */
}

.folder-name {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    text-shadow: 0 1px 4px rgba(0,0,0,0.7);
    z-index: 2;
}

.folder-count {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    background-color: var(--accent-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    user-select: none;
    z-index: 2;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.folder-item-thumbnail-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 146.1538%;
    background-color: var(--border-color);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    
    border-radius: inherit;
    transition: background-size 0.2s ease-in-out;

    /* --- [子像素缝隙修复] 请勿删除 --- */
    /* scale(1.005) 用于遮盖卡片底部的“缝隙”(1px 线)，该缝隙源于 */
    /* 悬停时的子像素渲染误差。视觉上不可察觉，但能消除该 bug。 */
    transform: scale(1.005);
    
    transition: background-size 0.2s ease-in-out;
    border-radius: inherit; /* 继承圆角 */
}

.folder-item-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 改为 cover 以更好填充 */
    position: absolute; /* 在容器内绝对定位 */
    top: 0;
    left: 0;
    /* transition: transform 0.2s ease-in-out; */ /* 从此处去掉 transition */
    z-index: 1; /* 确保主图层级高于伪元素 */
    opacity: 0; /* 让主图不可见，因为背景已移到父级 */
}

.add-folder-button {
    /* 把按钮样式设为占位卡片 */
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 832 / 1216; /* 为占位元素保留，避免“跳动” */
    background-color: transparent;
    border: 2px dashed var(--border-color);
    border-radius: var(--global-border-radius);
    color: var(--secondary-text-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 0; /* 防止在 grid 容器中被拉伸 */
}

.add-folder-button:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background-color: rgba(10, 132, 255, 0.05);
}
