/**
 * 子比网盘预览 —— 前台样式
 *
 * 适配子比主题的浅色 / 深色两种模式：
 *   · 浅色为默认；
 *   · 深色同时支持 `prefers-color-scheme: dark`（系统级）与
 *     `.dark-theme` 祖先类（主题的手动切换开关）。
 *
 * Copyright (C) 2026 依岸归
 * Licensed under GNU GPL v2 or later
 * https://nav.hoarfall.cn/
 * fp:7d69ff42a93b47ce
 */

/* ═══════════════════════════════════════ 变量 ═══════════════════════════════════════ */

/* ⚠️ 0.8.0：这里原来只覆盖旧短代码（`[hoarfall_pan_search]` / `[hoarfall_pan_tree]`）
   用到的那几个类。现在**与 catalog.css 的口径对齐**（同一套浅蓝主色、同一批表面色），
   这样新旧两个前台的观感一致，深浅色切换也一致。
   深色值对齐子比 `css/main.css` 的 `.dark-theme` 变量表。 */

.hfpan-box,
.hfpan-viewer,
.hfpan-confirm {
    --hfpan-radius: 10px;
    --hfpan-line: #dcdfe6;
    --hfpan-bg: #fff;
    --hfpan-bg-soft: #fbfcfd;
    --hfpan-text: #1a1d21;
    --hfpan-text-dim: #5b6470;
    --hfpan-brand: #3199f8;         /* ★ 0.8.0：与 catalog.css 同一支浅蓝 */
    --hfpan-brand-soft: #eaf4fe;
    --hfpan-brand-ink: #0b5ca8;     /* 浅底上的深蓝文字 */
    --hfpan-on-brand: #fff;
}

/* 深色：`body.dark-theme`（子比切换）/ `html.dark`（防闪烁）/ `[data-theme]`（兜底） */
html.dark-theme .hfpan-box,
html.dark-theme .hfpan-viewer,
html.dark-theme .hfpan-confirm,
body.dark-theme .hfpan-box,
body.dark-theme .hfpan-viewer,
body.dark-theme .hfpan-confirm,
[data-theme="dark"] .hfpan-box,
[data-theme="dark"] .hfpan-viewer,
[data-theme="dark"] .hfpan-confirm {
    --hfpan-line: #43454a;
    --hfpan-bg: #323335;
    --hfpan-bg-soft: #2d2e31;
    --hfpan-text: #e5eef7;
    --hfpan-text-dim: #b4b6bb;
    --hfpan-brand: #4aa8f5;
    --hfpan-brand-soft: #16304a;
    --hfpan-brand-ink: #9ed0fd;
    --hfpan-on-brand: #0b1a26;
}

@media (prefers-color-scheme: dark) {
    body:not(.dark-theme) .hfpan-box,
    body:not(.dark-theme) .hfpan-viewer,
    body:not(.dark-theme) .hfpan-confirm {
        --hfpan-line: #43454a;
        --hfpan-bg: #323335;
        --hfpan-bg-soft: #2d2e31;
        --hfpan-text: #e5eef7;
        --hfpan-text-dim: #b4b6bb;
        --hfpan-brand: #4aa8f5;
        --hfpan-brand-soft: #16304a;
        --hfpan-brand-ink: #9ed0fd;
        --hfpan-on-brand: #0b1a26;
    }
}

/* ═══════════════════════════════════════ 外壳 ═══════════════════════════════════════ */

.hfpan-box {
    margin: 20px 0;
    padding: 18px;
    border: 1px solid var(--hfpan-line);
    border-radius: var(--hfpan-radius);
    background: var(--hfpan-bg);
    color: var(--hfpan-text);
}

.hfpan-box__title {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 600;
    color: var(--hfpan-text);
}

.hfpan-box__hint {
    margin: -8px 0 12px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--hfpan-text-dim);
}

.hfpan-note {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 16px;
    border-radius: 8px;
    background: var(--hfpan-bg-soft);
    color: var(--hfpan-text-dim);
    font-size: 14px;
}

.hfpan-note--lock > i {
    font-size: 16px;
}

.hfpan-quota {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--hfpan-brand-soft);
    color: var(--hfpan-brand);
    font-size: 13px;
}

/* ═══════════════════════════════════════ 搜索框 ═══════════════════════════════════════ */

.hfpan-search__field {
    position: relative;
    display: flex;
    gap: 10px;
}

.hfpan-search__icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--hfpan-text-dim);
    pointer-events: none;
}

.hfpan-input {
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0 14px 0 38px;
    border: 1px solid var(--hfpan-line);
    border-radius: 8px;
    background: var(--hfpan-bg-soft);
    color: var(--hfpan-text);
    font-size: 14px;
    outline: none;
    transition: border-color .15s, background-color .15s;
}

.hfpan-input:focus {
    border-color: var(--hfpan-brand);
    background: var(--hfpan-bg);
}

.hfpan-submit {
    flex: 0 0 auto;
    height: 44px;
    padding: 0 22px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.hfpan-search__filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

/* ★ 0.13.82：`.hfpan-exts` 与 `.hfpan-chip*` 四条规则**整段删掉** ——
   它们是旧搜索短代码里那排「按扩展名筛」的按钮（MP4 12 / PDF 5 …）。
   老板要求「筛选的也删掉」，前台已经没有这个容器了（见 class-frontend.php）。
   ⚠️ 别把 `.hfpan-chip` 跟新前台的 `.hfpan-cat__chip` 搞混 —— 后者是
      搜索结果里那个格式小方块，0.13.82 也删了（但那条规则先留着，
      等确认没有别的短代码在用再清）。 */

.hfpan-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--hfpan-text-dim);
}

/* ═══════════════════════════════════════ 结果列表 ═══════════════════════════════════════ */

.hfpan-results {
    margin-top: 14px;
}

.hfpan-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--hfpan-line);
}

.hfpan-item:last-child {
    border-bottom: 0;
}

.hfpan-item__main {
    flex: 1;
    min-width: 0;
}

.hfpan-item__name {
    font-size: 14px;
    line-height: 1.5;
    color: var(--hfpan-text);
    word-break: break-all;
}

.hfpan-item__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 5px;
    font-size: 12px;
    color: var(--hfpan-text-dim);
}

.hfpan-tag {
    padding: 1px 7px;
    border-radius: 4px;
    background: var(--hfpan-bg-soft);
    font-size: 11px;
    letter-spacing: .3px;
}

.hfpan-item__path {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hfpan-item__path > i {
    margin-right: 4px;
}

.hfpan-item__act {
    flex: 0 0 auto;
}

.hfpan-btn {
    display: inline-block;
    padding: 7px 18px;
    border: 1px solid var(--hfpan-brand);
    border-radius: 6px;
    background: transparent;
    color: var(--hfpan-brand);
    font-size: 13px;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.hfpan-btn:hover {
    background: var(--hfpan-brand-soft);
}

.hfpan-btn.is-disabled {
    border-color: var(--hfpan-line);
    color: var(--hfpan-text-dim);
    cursor: not-allowed;
}

.hfpan-btn--small {
    padding: 4px 12px;
    font-size: 12px;
}

.hfpan-status {
    margin-top: 14px;
    text-align: center;
    font-size: 13px;
    color: var(--hfpan-text-dim);
}

.hfpan-more {
    padding: 8px 24px;
    border: 1px solid var(--hfpan-line);
    border-radius: 8px;
    background: var(--hfpan-bg-soft);
    color: var(--hfpan-text);
    cursor: pointer;
}

.hfpan-empty {
    padding: 36px 16px;
    text-align: center;
    color: var(--hfpan-text-dim);
}

.hfpan-empty > i {
    font-size: 34px;
    opacity: .35;
}

.hfpan-empty p {
    margin: 10px 0 0;
    font-size: 14px;
}

.hfpan-empty__hint {
    font-size: 12px;
    opacity: .75;
}

/* ═══════════════════════════════════════ 目录树 ═══════════════════════════════════════ */

.hfpan-tree__root,
.hfpan-tree__children {
    margin: 0;
    padding: 0;
    list-style: none;
}

.hfpan-tree__children {
    margin-left: 18px;
    border-left: 1px dashed var(--hfpan-line);
    padding-left: 6px;
}

.hfpan-tree__label {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--hfpan-text);
    transition: background-color .12s;
}

.hfpan-tree__label:hover {
    background: var(--hfpan-bg-soft);
}

.hfpan-tree__caret {
    width: 12px;
    font-size: 12px;
    color: var(--hfpan-text-dim);
    transition: transform .15s;
}

.hfpan-tree__label.is-open .hfpan-tree__caret {
    transform: rotate(90deg);
}

.hfpan-tree__icon {
    color: var(--hfpan-brand);
}

.hfpan-tree__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hfpan-tree__badge {
    flex: 0 0 auto;
    padding: 1px 8px;
    border-radius: 20px;
    background: var(--hfpan-bg-soft);
    color: var(--hfpan-text-dim);
    font-size: 11px;
}

.hfpan-tree__badge.is-empty {
    opacity: .6;
}

/* ── 目录树里的文件行 ───────────────────────────────────────── */

.hfpan-tree__file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--hfpan-text);
}

.hfpan-tree__file:hover {
    background: var(--hfpan-bg-soft);
}

.hfpan-tree__fileicon {
    flex: 0 0 auto;
    color: var(--hfpan-text-dim);
}

.hfpan-tree__filename {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hfpan-tree__more {
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--hfpan-text-dim);
}

.hfpan-btn--tiny {
    flex: 0 0 auto;
    padding: 2px 10px;
    font-size: 11px;
}

.hfpan-tree__empty {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--hfpan-text-dim);
}

/* ═══════════════════════════════════════ 预览层 ═══════════════════════════════════════ */

body.hfpan-lock {
    overflow: hidden;
}

.hfpan-viewer {
    position: fixed;
    inset: 0;
    z-index: 99998;
}

.hfpan-viewer__mask {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .72);
}

.hfpan-viewer__panel {
    position: absolute;
    inset: 3vh 3vw;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    background: var(--hfpan-bg);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

.hfpan-viewer__bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--hfpan-line);
    background: var(--hfpan-bg-soft);
}

.hfpan-viewer__title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    color: var(--hfpan-text);
}

.hfpan-viewer__tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hfpan-viewer__pager {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--hfpan-text-dim);
}

.hfpan-iconbtn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--hfpan-line);
    border-radius: 6px;
    background: var(--hfpan-bg);
    color: var(--hfpan-text);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.hfpan-iconbtn:hover {
    border-color: var(--hfpan-brand);
    color: var(--hfpan-brand);
}

.hfpan-iconbtn--close {
    font-size: 20px;
}

.hfpan-viewer__body {
    flex: 1;
    overflow: auto;
    padding: 16px;
    text-align: center;
    background: var(--hfpan-bg-soft);
}

.hfpan-canvas-wrap canvas {
    max-width: 100%;
    box-shadow: 0 2px 14px rgba(0, 0, 0, .14);
    background: #fff;
}

.hfpan-image img {
    max-width: 100%;
    height: auto;
}

.hfpan-viewer__hint {
    padding: 8px 14px;
    border-top: 1px solid var(--hfpan-line);
    background: var(--hfpan-bg-soft);
    font-size: 12px;
    color: var(--hfpan-text-dim);
    text-align: center;
}

.hfpan-loading {
    padding: 60px 16px;
    color: var(--hfpan-text-dim);
    font-size: 14px;
}

.hfpan-loading--err {
    color: #c0392b;
}

@media screen and (max-width: 782px) {
    .hfpan-item {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .hfpan-item__act {
        align-self: flex-end;
    }

    .hfpan-viewer__panel {
        inset: 0;
        border-radius: 0;
    }

    .hfpan-search__field {
        flex-wrap: wrap;
    }

    .hfpan-submit {
        width: 100%;
    }
}

/* ═══════════════════════════════════════ 确认框 ═══════════════════════════════════════ */

.hfpan-confirm {
    position: fixed;
    inset: 0;
    z-index: 99999;
}

.hfpan-confirm__mask {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .5);
}

.hfpan-confirm__box {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, 88vw);
    padding: 22px;
    border-radius: 12px;
    background: var(--hfpan-bg);
    color: var(--hfpan-text);
    box-shadow: 0 16px 44px rgba(0, 0, 0, .3);
}

.hfpan-confirm__msg {
    font-size: 14px;
    line-height: 1.7;
    color: var(--hfpan-text);
}

.hfpan-confirm__act {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}
