/* ============================================================
   文件下载 / 文件库模块样式（前台）
   挂接：index.html 的 #files 卡片 + #filesModalOverlay 弹窗
   ============================================================ */

/* ===== 文件下载卡片（与项目/帖子卡片同款透明风格） ===== */
.materials-card,
.materials-card:hover {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 28px 0 0;
    margin-bottom: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.materials-entry {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    margin-top: 14px;
    padding: 22px 20px;
    /* 与左侧文件下载等高：并排后宽度变窄，用更高的高度撑起来 */
    min-height: 108px;
    text-align: left;
    font: inherit;
    color: var(--text);
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(120%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(120%);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}
.materials-entry:hover {
    background: var(--card-bg-hover);
    border-color: var(--card-border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}
.materials-entry:active { transform: translateY(0); }

.materials-entry-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(var(--accent-rgb), 0.08);
    color: var(--accent);
}
.materials-entry-icon svg { width: 40px; height: 40px; }

.materials-entry-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.materials-entry-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}
.materials-entry-sub {
    font-size: 13.5px;
    color: var(--text-muted);
    line-height: 1.55;
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.materials-entry-count {
    flex: 0 0 auto;
    min-width: 30px;
    padding: 4px 11px;
    border-radius: 999px;
    background: rgba(var(--accent-rgb), 0.1);
    border: 1px solid rgba(var(--accent-rgb), 0.16);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.materials-entry-arrow {
    flex: 0 0 auto;
    display: flex;
    color: var(--text-muted);
    transition: transform 0.25s ease, color 0.25s ease;
}
.materials-entry-arrow svg { width: 22px; height: 22px; }
.materials-entry:hover .materials-entry-arrow {
    transform: translateX(3px);
    color: var(--text);
}

/* ===== 文件库弹窗（与商铺弹窗同款质感） ===== */
.materials-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10002;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.materials-modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.materials-modal-dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    background: rgba(30, 30, 40, 0.92);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 640px;
    width: 100%;
    max-height: min(86vh, 780px);
    overflow: hidden;
    transform: scale(0.92) translateY(16px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.25s ease;
}
.materials-modal-overlay.show .materials-modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.materials-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 18px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}
.materials-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
}
.materials-modal-subtitle {
    margin: 5px 0 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
}

.materials-modal-close {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    padding: 7px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s;
}
.materials-modal-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: rotate(90deg);
}
.materials-modal-close svg { width: 100%; height: 100%; }

.materials-modal-toolbar {
    padding: 12px 18px 4px;
    flex-shrink: 0;
}

.materials-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.materials-search-icon {
    position: absolute;
    left: 12px;
    width: 15px;
    height: 15px;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}
.materials-search-input {
    width: 100%;
    height: 38px;
    padding: 0 36px 0 34px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}
.materials-search-input::placeholder { color: rgba(255, 255, 255, 0.35); }
.materials-search-input:focus {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
}
.materials-search-clear {
    position: absolute;
    right: 8px;
    width: 22px;
    height: 22px;
    padding: 5px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.15s;
}
.materials-search-clear:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.materials-search-clear svg { width: 100%; height: 100%; }

.materials-modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 12px 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.materials-modal-body::-webkit-scrollbar { width: 6px; }
.materials-modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 3px;
}

/* ===== 文件列表 ===== */
.materials-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.materials-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease;
}
.materials-row:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.18);
}

.materials-row-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 34px;
    padding: 0 6px;
    border-radius: 9px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #fff;
}
.materials-row-icon.fi-generic { background: rgba(255, 255, 255, 0.14); color: rgba(255, 255, 255, 0.8); }
.materials-row-icon.materials-archive { background: rgba(255, 159, 67, 0.22); color: #ffbe82; }
.materials-row-icon.fi-pdf     { background: rgba(255, 82, 82, 0.2);  color: #ff8a8a; }
.materials-row-icon.fi-image   { background: rgba(83, 190, 133, 0.2); color: #8fe0b0; }
.materials-row-icon.fi-audio   { background: rgba(155, 111, 236, 0.24); color: #c0a5ff; }
.materials-row-icon.fi-video   { background: rgba(79, 172, 254, 0.2); color: #9bceff; }
.materials-row-icon.fi-doc     { background: rgba(64, 156, 255, 0.2); color: #a5cdff; }
.materials-row-icon.fi-code    { background: rgba(120, 200, 90, 0.18); color: #b3e39b; }

.materials-row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.materials-row-name {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.92);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.materials-row-meta {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.45);
}

.materials-row-dl {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.75);
    transition: all 0.2s;
}
.materials-row-dl svg { width: 16px; height: 16px; }
.materials-row:hover .materials-row-dl {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

/* 加载 / 空状态 */
.materials-loading,
.materials-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 42px 20px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
}
.files-spinner {
    width: 22px;
    height: 22px;
    animation: materialsSpin 1s linear infinite;
}
@keyframes materialsSpin { to { transform: rotate(360deg); } }

.materials-modal-footer {
    flex-shrink: 0;
    padding: 10px 18px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.45);
    text-align: center;
}

/* ===== 移动端适配 ===== */
@media (max-width: 560px) {
    .materials-modal-overlay { padding: 0; align-items: flex-end; }
    .materials-modal-dialog {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 20px 20px 0 0;
    }
    .materials-entry { padding: 16px; gap: 12px; min-height: 0; }
    .materials-entry-icon { width: 42px; height: 42px; }
    .materials-entry-icon svg { width: 22px; height: 22px; }
    .materials-entry-sub { white-space: normal; font-size: 13px; }
    .materials-entry-title { font-size: 16.5px; }
    .materials-row { padding: 10px; gap: 9px; }
    .materials-row-icon { min-width: 38px; height: 30px; }
}

@media (max-width: 860px) and (min-width: 561px) {
    .materials-entry { padding: 18px 16px; min-height: 96px; }
    .materials-entry-title { font-size: 16.5px; }
    .materials-entry-sub { font-size: 12.5px; }
}

/* ===== 番剧素材库：分类列表（第一级） =====
   像文件管理器：先列番剧分类，点进去再开第二层窗口看该分类的素材。 */
.materials-cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.materials-cat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 13px 14px;
    text-align: left;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    font: inherit;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.materials-cat-card:hover,
.materials-cat-card:focus-visible {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    outline: none;
}

.materials-cat-card-ico {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    color: rgba(130, 180, 255, 0.95);
    background: rgba(130, 180, 255, 0.16);
}
/* 未分类：中性色，和真实分类区分 */
.materials-cat-card.is-uncat .materials-cat-card-ico {
    color: rgba(255, 255, 255, 0.62);
    background: rgba(255, 255, 255, 0.09);
}

.materials-cat-card-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.materials-cat-card-name {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.4;
    overflow-wrap: anywhere;
}
.materials-cat-card-count {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.5);
}

.materials-cat-card-go {
    flex: 0 0 auto;
    opacity: 0.45;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.materials-cat-card:hover .materials-cat-card-go {
    opacity: 0.9;
    transform: translateX(2px);
}

/* ===== 第二级：分类内容窗口 ===== */
/* 叠在番剧素材库弹窗之上，所以 z-index 要更高 */
.materials-cat-overlay {
    z-index: 10012;
    background: rgba(0, 0, 0, 0.72);
}
.materials-cat-dialog {
    max-width: 700px;
}

.materials-cat-back {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 8px;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.78);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}
.materials-cat-back:hover {
    background: rgba(255, 255, 255, 0.13);
    border-color: rgba(255, 255, 255, 0.24);
}

@media (max-width: 768px) {
    .materials-cat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
    .materials-cat-card { padding: 11px 12px; gap: 10px; }
    .materials-cat-card-ico { width: 32px; height: 32px; }
    .materials-cat-card-name { font-size: 12.5px; }
}
