/* ============================================================
 * 角色 & 武器收集统计页
 * ------------------------------------------------------------
 * 只使用 css/base.css 里的设计令牌，因此深色 / 浅色主题自动一致。
 * 结构：收集总览（统计卡）→ 筛选 → 版本分组 → 一行一个角色 + 专武
 * ============================================================ */

/* 标题图标底色（与主页面的 .icon-resource / .icon-result 同一套写法） */
.icon-collection {
    background: var(--purple-bg);
}

/* ===== 收集总览 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 20px 16px 24px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition);
}

.stat-card:hover {
    border-color: var(--border-hover);
}

/* 左侧色条：角色用琥珀色，专武用紫色 */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 4px;
    background: var(--accent);
    opacity: 0.85;
}

.stat-card.stat-weapon::before {
    background: var(--purple);
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.stat-main {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-fraction {
    font-family: var(--font-mono);
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    line-height: 1.1;
}

.stat-fraction b {
    color: var(--accent);
}

.stat-weapon .stat-fraction b {
    color: var(--purple);
}

.stat-percent {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-weapon .stat-percent {
    color: var(--purple);
}

.stat-bar {
    height: 6px;
    margin-top: 4px;
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: 99px;
    overflow: hidden;
}

.stat-bar > i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent), var(--orange));
    transition: width 0.35s ease;
}

.stat-weapon .stat-bar > i {
    background: linear-gradient(90deg, var(--purple), var(--blue));
}

.stat-note {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.stat-meta {
    margin-top: 14px;
    font-size: 0.78rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

/* ===== 标题栏里的筛选 + 添加版本 ===== */
.collection-toolbar {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.collection-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* 「添加版本」与发布按钮保持同一尺寸，避免工具栏高低不齐 */
.collection-actions .btn {
    padding: 6px 14px;
    border-radius: 18px;
    font-size: 0.8rem;
}

.filter-group {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: 20px;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid transparent;
    border-radius: 16px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.filter-btn:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.filter-btn[aria-pressed='true'] {
    color: var(--accent);
    font-weight: 600;
    background: var(--accent-bg-mid);
    border-color: var(--accent-border);
}

.filter-count {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    opacity: 0.75;
}

/* ===== 版本分组 ===== */
.version-collection {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.version-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px 16px;
    background: var(--bg-soft);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition);
}

.version-group:hover {
    border-color: var(--border-hover);
}

.version-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.version-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.version-stat {
    padding: 4px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    white-space: nowrap;
}

.version-stat b {
    color: var(--accent);
}

.version-stat.stat-weapon b {
    color: var(--purple);
}

.version-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-add-char {
    padding: 6px 14px;
    background: var(--blue-bg);
    border: 1.5px solid var(--blue-border);
    border-radius: 18px;
    color: var(--blue);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.btn-add-char:hover {
    background: var(--blue-bg-hover);
    border-color: var(--blue);
    box-shadow: 0 0 14px var(--blue-glow);
}

.btn-edit-version {
    padding: 6px 14px;
    background: var(--purple-bg);
    border: 1.5px solid var(--purple-border);
    border-radius: 18px;
    color: var(--purple);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.btn-edit-version:hover {
    border-color: var(--purple);
    box-shadow: 0 0 14px var(--purple-focus-ring);
}

/* 编辑模式下的发布相关小按钮（与工具栏其他控件同一尺寸） */
.btn-compact {
    padding: 6px 14px;
    border: 1.5px solid var(--border);
    border-radius: 18px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.btn-publish {
    color: var(--accent);
    border-color: var(--accent-border);
    background: var(--accent-bg-soft);
}

.btn-publish:hover {
    border-color: var(--accent);
    box-shadow: 0 0 14px var(--accent-glow);
}

.btn-import {
    color: var(--text-muted);
}

.btn-import:hover {
    color: var(--blue);
    border-color: var(--blue-border);
    background: var(--blue-bg);
}

/* ===== 清单：一个角色 + 一把专武占一行 ===== */
.roster-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.roster-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.roster-row:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-hover);
}

/* 只读模式没有行内操作列，少一列避免留下一段空白 */
.roster-row.is-readonly {
    grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
}

/* 已拥有角色：琥珀色描边；已拥有专武：紫色内描边 */
.roster-row.is-owned {
    border-color: var(--accent-border);
}

.roster-row.is-weapon-owned {
    box-shadow: inset 0 0 0 1px var(--purple-border);
}

.roster-unit {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.roster-thumb {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 2rem;
    line-height: 1;
}

/* 缩略图放大到便于辨认的尺寸：头像沿用 456:564 比例，专武保持正方形 */
.roster-thumb-avatar {
    width: 114px;
    height: 141px;
}

.roster-thumb-weapon {
    width: 114px;
    height: 114px;
}

.roster-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.roster-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.roster-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.roster-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.roster-divider {
    width: 1px;
    height: 84px;
    background: var(--border);
}

/* 拥有勾选：行内芯片 */
.own-check {
    flex-shrink: 0;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 6px;
    border: 1.5px solid transparent;
    border-radius: 14px;
    color: var(--text-secondary);
    font-size: 0.76rem;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: all var(--transition);
}

.own-check:hover {
    background: var(--bg-hover);
}

.own-check input[type='checkbox'] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.own-check.weapon-check input[type='checkbox'] {
    accent-color: var(--purple);
}

.roster-row.is-owned .own-check:not(.weapon-check) {
    color: var(--accent);
    background: var(--accent-bg-soft);
    border-color: var(--accent-border);
}

.roster-row.is-weapon-owned .weapon-check {
    color: var(--purple);
    background: var(--purple-bg);
    border-color: var(--purple-border);
}

/* 行内操作 */
.roster-row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.row-icon-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 0.72rem;
    line-height: 1;
    cursor: pointer;
    transition: all var(--transition);
}

.row-icon-btn:hover {
    color: var(--blue);
    border-color: var(--blue-border);
    background: var(--blue-bg);
}

.row-icon-btn.row-delete:hover {
    color: var(--red);
    border-color: var(--red-border);
    background: var(--red-bg-soft);
}

/* ===== 空状态 / 筛选空提示 ===== */
.collection-empty {
    padding: 40px 20px;
    text-align: center;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
}

.collection-empty .empty-icon {
    display: block;
    margin-bottom: 8px;
    font-size: 2.2rem;
    filter: drop-shadow(0 0 16px var(--accent-glow));
}

.collection-empty .empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.collection-empty .empty-desc {
    font-size: 0.8rem;
    line-height: 1.7;
    margin-bottom: 16px;
}

.filter-empty {
    padding: 18px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}

/* ============================================================
 * 添加 / 编辑版本弹窗
 * ============================================================ */
.editor-modal.plan-modal {
    width: min(900px, 100%);
    padding-bottom: 16px;
}

.editor-modal .field-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.editor-version-field {
    margin-bottom: 16px;
}

.editor-input,
.editor-version-field input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: all var(--transition);
}

.editor-input:focus,
.editor-version-field input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--blue-focus-ring-soft);
}

.editor-chars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.editor-char {
    padding: 12px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.editor-char-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.editor-char-index {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.04em;
}

.editor-char-grid {
    display: grid;
    grid-template-columns: 222px minmax(0, 1fr) 222px;
    gap: 18px;
    align-items: start;
}

.editor-media {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.media-caption {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--text-muted);
}

.editor-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.editor-fields .field-label {
    margin: 4px 0 0;
}

.editor-add-char {
    margin-right: auto;
}

.editor-empty {
    padding: 22px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ===== 弹窗里的图片槽位 ===== */
.media-shell {
    position: relative;
}

.media-slot {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
    background: var(--bg-input);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.media-slot:hover {
    border-color: var(--accent-border);
    background: var(--accent-bg-soft);
}

.media-slot:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

.media-slot img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-avatar {
    aspect-ratio: 456 / 564;
}

.media-weapon {
    aspect-ratio: 1 / 1;
}

.media-slot.is-filled {
    border-style: solid;
    border-color: var(--border);
}

.media-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px;
    text-align: center;
    font-size: 0.66rem;
    line-height: 1.35;
    color: var(--text-muted);
}

.media-plus {
    font-size: 1.05rem;
    line-height: 1;
    color: var(--accent);
}

.media-size {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    opacity: 0.75;
}

/* 移除图片：悬停显示，触屏设备常显 */
.image-clear {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 2;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 0.62rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition);
}

.media-shell:hover .image-clear,
.image-clear:focus-visible {
    opacity: 1;
}

.image-clear:hover {
    color: var(--red);
    border-color: var(--red-border);
    background: var(--red-bg-soft);
}

/* 弹窗底部的取消 / 保存 */
.editor-modal .modal-foot {
    justify-content: flex-end;
}

.editor-modal .modal-foot .btn {
    padding: 8px 20px;
    font-size: 0.85rem;
    border-radius: 20px;
}

/* ===== 只读提示 / 发布提示 ===== */
.collection-notice,
.collection-publish-hint {
    margin: 0 0 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.65;
}

.collection-notice {
    border-color: var(--accent-border);
    background: var(--accent-bg-soft);
}

.collection-publish-hint code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* ===== 页面底部提示 ===== */
.collection-hint {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    font-size: 0.75rem;
    line-height: 1.7;
    color: var(--text-muted);
}

.collection-hint b {
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: 600;
}

/* ===== 响应式 ===== */
@media (max-width: 820px) {
    /* 窄屏：角色与专武上下两行，仍是一个角色占一块 */
    .roster-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 10px;
    }

    .roster-character {
        grid-column: 1;
        grid-row: 1;
    }

    .roster-divider {
        display: none;
    }

    .roster-weapon {
        grid-column: 1;
        grid-row: 2;
    }

    .roster-row-actions {
        grid-column: 2;
        grid-row: 1 / span 2;
        flex-direction: column;
    }

    /* 只读模式窄屏：角色与专武上下排列，不需要操作列 */
    .roster-row.is-readonly {
        grid-template-columns: minmax(0, 1fr);
    }

    .editor-char-grid {
        grid-template-columns: 186px minmax(0, 1fr);
    }

    .editor-char-grid .editor-media:last-child {
        grid-column: 1;
    }
}

@media (max-width: 720px) {
    .collection-toolbar {
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
    }

    .version-actions {
        margin-left: 0;
    }
}

@media (max-width: 560px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .filter-group {
        width: 100%;
        justify-content: space-between;
    }

    .filter-btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .roster-thumb-avatar {
        width: 93px;
        height: 115px;
    }

    .roster-thumb-weapon {
        width: 93px;
        height: 93px;
    }

    .own-check {
        padding: 4px 7px;
        font-size: 0.72rem;
    }

    .editor-char-grid {
        grid-template-columns: 156px minmax(0, 1fr);
        gap: 14px;
    }

    .editor-char {
        padding: 10px;
    }
}

@media (hover: none) {
    .image-clear {
        opacity: 1;
    }
}
