/**
 * 图片列表页样式 - GitHub暗黑风格
 * 瀑布流布局
 */

/* ========================================
   筛选侧边栏 - GitHub风格
   ======================================== */
.filter-sidebar {
    background: var(--card-bg);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    padding: 16px;
    box-shadow: none;
    /* 移除高度限制，让所有分类默认全部显示 */
    /* position: sticky; */
    /* top: 80px; */
    /* max-height: calc(100vh - 100px); */
    /* overflow-y: auto; */
}

.filter-sidebar::-webkit-scrollbar {
    width: 8px;
}

.filter-sidebar::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.filter-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 4px;
}

.filter-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-primary);
}

.filter-header h5 {
    margin: 0;
    font-weight: var(--font-weight-semibold);
    font-size: 14px;
    color: var(--text-primary);
}

.selected-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* 极简风格的已选标签 - 只有边框 */
.selected-tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: var(--font-weight-medium);
    color: var(--accent-primary);
    background: transparent;
    border: 1px solid var(--accent-primary);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.selected-tag:hover {
    background: rgba(88, 166, 255, 0.1);
    border-color: var(--accent-hover);
    color: var(--accent-hover);
}

.tag-close {
    color: var(--accent-primary);
    text-decoration: none;
    margin-left: 8px;
    font-size: 18px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.tag-close:hover {
    color: var(--accent-hover);
    opacity: 1;
}

.filter-section {
    margin-bottom: 20px;
}

.filter-title {
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-toggle {
    cursor: pointer;
    transition: color 0.2s ease;
    user-select: none;
}

.filter-toggle:hover {
    color: var(--accent-primary) !important;
}

.toggle-chevron {
    font-size: 12px;
    color: var(--accent-primary);
    margin-right: 6px;
    transition: transform 0.2s ease;
}

.filter-content {
    transition: all 0.3s ease;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.filter-item {
    display: block;
    padding: 6px 10px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 14px;
}

.filter-item:hover {
    background: var(--btn-hover-bg);
    color: var(--accent-primary);
}

.filter-item.active {
    background: var(--accent-emphasis);
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
}

.filter-children {
    margin-left: 12px;
    border-left: 1px solid var(--border-primary);
    padding-left: 8px;
    margin-top: 2px;
}

.filter-children .filter-item {
    font-size: 13px;
    padding: 5px 8px;
}

/* ========================================
   工具栏 - GitHub风格
   ======================================== */
.toolbar {
    background: var(--card-bg);
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid var(--border-primary);
    box-shadow: none;
}

.toolbar-info {
    font-size: 14px;
    color: var(--text-secondary);
}

.toolbar-info strong {
    color: var(--accent-primary);
}

.btn-group .btn {
    background: var(--btn-bg);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    font-size: 13px;
}

.btn-group .btn:hover {
    background: var(--btn-hover-bg);
    color: var(--accent-primary);
}

.btn-group .btn.active {
    background: var(--accent-emphasis);
    border-color: var(--accent-emphasis);
    color: var(--text-primary);
}

.btn-outline-secondary {
    background: transparent;
    border-color: var(--border-primary);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: var(--btn-hover-bg);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-outline-secondary.active {
    background: var(--accent-emphasis);
    border-color: var(--accent-emphasis);
    color: var(--text-primary);
}

/* ========================================
   优雅的等高布局 - 改进版
   每行图片高度一致，宽度根据比例自适应，左右完美对齐
   核心原理：flex布局 + flex-grow实现自适应填充
   ======================================== */
.masonry-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px; /* 紧凑间距 */
    align-items: flex-start;
    justify-content: flex-start; /* 左对齐 */
}

/* 填充最后一行，避免最后一行拉伸 */
.masonry-grid::after {
    content: '';
    flex-grow: 999; /* 极大值确保填充但不拉伸 */
}

.masonry-item {
    position: relative;
    /* 宽度由JavaScript算法动态计算 */
    /* flex属性将在JS中设置 */
    display: block;
    /* 图片加载渐入动画 */
    animation: imageAppear 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
}

/* 图片加载渐入动画 */
@keyframes imageAppear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 等高布局：固定高度，宽度自适应 */
.masonry-item .minimal-image-thumb {
    height: 200px; /* 固定行高 */
    width: 100%; /* 填充容器宽度 */
    object-fit: cover; /* 裁剪并保持比例 */
    display: block;
    /* 优化图片渲染质量 */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    /* 添加过渡效果，用于悬停放大 */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

/* 图片描述在下方 */
.image-info-overlay {
    position: static;
    background: linear-gradient(180deg, rgba(13, 17, 23, 0.92) 0%, rgba(13, 17, 23, 0.98) 100%);
    backdrop-filter: blur(12px);
    padding: 10px 12px;
    border-top: 1px solid rgba(88, 166, 255, 0.12);
    width: 100%;
    box-sizing: border-box;
    min-height: 44px; /* 固定最小高度 */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 响应式：不同屏幕尺寸的高度调整（宽度由算法计算） */
@media (max-width: 1400px) {
    .masonry-item .minimal-image-thumb {
        height: 180px;
    }
    
    .masonry-grid {
        gap: 12px;
    }
}

@media (max-width: 992px) {
    .masonry-item .minimal-image-thumb {
        height: 160px;
    }
    
    .masonry-grid {
        gap: 10px;
    }
}

@media (max-width: 768px) {
    .filter-sidebar {
        position: static;
        max-height: none;
    }
    
    .masonry-item .minimal-image-thumb {
        height: 140px;
    }
    
    .masonry-grid {
        gap: 8px;
    }
}

@media (max-width: 576px) {
    .masonry-item .minimal-image-thumb {
        height: 120px;
    }
    
    .masonry-grid {
        gap: 6px;
    }
}

/* ========================================
   优雅的图片卡片 - 改进版
   ======================================== */
.minimal-image-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
    cursor: pointer;
    /* 优化过渡效果 - 使用流畅的缓动曲线 */
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    width: 100%; /* 填充父容器宽度 */
    height: 100%; /* 填充父容器高度 */
    /* 初始状态的微妙阴影 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    /* GPU 加速 */
    will-change: transform, box-shadow, border-color;
}

.minimal-image-card:hover {
    /* 边框高亮 */
    border-color: var(--accent-primary);
    /* 轻微上浮 */
    transform: translateY(-4px);
    /* 增强阴影 - 创造悬浮感 */
    box-shadow: 
        0 12px 24px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(88, 166, 255, 0.1),
        0 4px 12px rgba(88, 166, 255, 0.15);
}

.minimal-image-thumb {
    width: auto; /* 由 gallery.css 中的等高布局样式控制 */
    height: auto; /* 由 gallery.css 中的等高布局样式控制 */
    display: block;
    /* 过渡效果已在上面的 .masonry-item .minimal-image-thumb 中定义 */
}

/* 悬停时图片放大效果 */
.minimal-image-card:hover .minimal-image-thumb {
    transform: scale(1.05);
}

/* 悬停时信息栏微妙变化 */
.minimal-image-card:hover .image-info-overlay {
    background: linear-gradient(180deg, rgba(13, 17, 23, 0.95) 0%, rgba(13, 17, 23, 1) 100%);
    border-top-color: rgba(88, 166, 255, 0.25);
}

/* 单行显示：分类标签（左）+ 文件大小（右） */
.image-title-minimal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    width: 100%;
}

/* 分类标签（左侧，可省略） */
.image-category-tags {
    flex: 1;
    min-width: 0; /* 允许收缩 */
    color: var(--text-primary);
    font-size: 13px;
    font-weight: var(--font-weight-medium);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* 添加过渡效果 */
    transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.2px;
}

/* 悬停时分类标签高亮 */
.minimal-image-card:hover .image-category-tags {
    color: var(--accent-hover);
}

/* 文件大小（右侧，固定宽度） */
.image-file-size {
    flex-shrink: 0; /* 不收缩 */
    color: var(--accent-primary);
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    /* 添加微妙的背景 */
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(88, 166, 255, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 悬停时文件大小高亮 */
.minimal-image-card:hover .image-file-size {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent-hover);
}

/* 隐藏旧的 meta 区域 */
.image-meta-minimal {
    display: none;
}

/* 保留旧的图片卡片样式（兼容性） */
.gallery-page .image-card {
    background: var(--card-bg);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-primary);
    box-shadow: none;
    transition: all 0.2s ease;
}

.gallery-page .image-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.badge-recommend {
    background: var(--warning) !important;
    color: var(--bg-canvas) !important;
}

.image-meta {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.image-meta small {
    color: var(--text-secondary);
}

.image-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.image-tags .badge {
    font-size: 11px;
    padding: 3px 6px;
}

/* ========================================
   空状态 - GitHub风格
   ======================================== */
.empty-state {
    background: var(--card-bg);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    padding: 48px 20px;
    box-shadow: none;
}

.empty-state i {
    color: var(--text-muted) !important;
}

.empty-state h4 {
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary) !important;
}

/* ========================================
   加载更多 - GitHub风格
   ======================================== */
.load-more-btn {
    display: block;
    width: 200px;
    margin: 30px auto;
}

/* ========================================
   移动端优化
   ======================================== */
@media (max-width: 768px) {
    .toolbar {
        padding: 10px 15px;
    }
    
    .toolbar-actions .btn-group {
        width: 100%;
    }
    
    .toolbar-actions .btn {
        flex: 1;
        font-size: 12px;
    }
    
    .image-title {
        font-size: 13px;
    }
    
    .image-meta {
        font-size: 11px;
    }
}

/* ========================================
   模态框样式 - GitHub风格
   ======================================== */
.modal-xl {
    max-width: 1200px;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
}

.modal-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
}

.modal-header .modal-title {
    color: var(--text-primary);
    font-weight: 600;
}

.modal-header .btn-close {
    filter: invert(1);
}

.modal-body {
    background-color: var(--bg-secondary);
}

.modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid var(--border-primary);
}

.modal-footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
}

.image-detail-info {
    padding: 16px 0;
}

.info-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-primary);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    width: 120px;
    color: var(--text-secondary);
    font-size: 14px;
}

.info-value {
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
}

/* ========================================
   VR 场景卡片样式
   ======================================== */
.gallery-card--vr {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(6px);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.gallery-card--vr:hover {
    border-color: rgba(88, 166, 255, 0.5);
    transform: translateY(-2px);
}

.gallery-card--vr .vr-meta {
    font-size: 13px;
    color: #8b949e;
}

.gallery-card--vr .badge {
    font-size: 11px;
}

.gallery-card--vr .btn {
    box-shadow: 0 8px 20px rgba(88, 166, 255, 0.25);
}

/* ========================================
   图片卡片悬停按钮组
   ======================================== */
/* 按钮组容器 */
.image-hover-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 桌面端悬停显示按钮 */
@media (min-width: 768px) {
    .minimal-image-card:hover .image-hover-actions {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }
}

/* 移动端始终显示按钮 */
@media (max-width: 767px) {
    .image-hover-actions {
        opacity: 1 !important;
        pointer-events: auto !important;
        transform: translateY(0) !important;
    }
}

/* 按钮基础样式 - 极简线框设计 */
.image-action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
}

.image-action-btn:hover {
    background: rgba(88, 166, 255, 0.9);
    border-color: rgba(88, 166, 255, 1);
    color: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.4);
}

.image-action-btn:active {
    transform: scale(0.95);
}

.image-action-btn i {
    font-size: 16px;
}

/* 移除卡片的点击光标 */
.minimal-image-card {
    cursor: default;
}

/* ========================================
   高级搜索面板样式
   ======================================== */
.advanced-search-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.advanced-search-panel .card {
    background: var(--card-bg);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
}

.advanced-search-panel .card-body {
    padding: 16px;
}

.advanced-search-panel .form-label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: var(--font-weight-medium);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.advanced-search-panel .form-control-sm {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.advanced-search-panel .form-control-sm:focus {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
    outline: none;
}

.advanced-search-panel .form-control-sm::placeholder {
    color: var(--text-muted);
}

.advanced-search-panel .d-flex.gap-2 {
    gap: 8px;
}

.advanced-search-panel .text-muted {
    color: var(--text-muted);
    font-size: 12px;
}

/* ========================================
   搜索包装器和下拉框样式
   ======================================== */
.search-wrapper {
    position: relative;
    display: inline-block;
}

.search-suggestions,
.search-history {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--card-bg);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    min-width: 300px;
}

.search-suggestions-list,
.search-history-list {
    padding: 4px;
}

/* 搜索建议样式 */
.suggestion-group {
    margin-bottom: 8px;
}

.suggestion-group:last-child {
    margin-bottom: 0;
}

.suggestion-type {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
}

.suggestion-item {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
    margin: 2px 4px;
}

.suggestion-item:hover {
    background: var(--btn-hover-bg);
    color: var(--accent-primary);
}

.suggestion-item:active {
    background: var(--accent-emphasis);
}

/* 搜索历史样式 */
.search-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
    margin: 2px 4px;
}

.search-history-item:hover {
    background: var(--btn-hover-bg);
    color: var(--accent-primary);
}

.search-history-item:active {
    background: var(--accent-emphasis);
}

.search-history-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-history-item .btn-close {
    opacity: 0.6;
    transition: opacity 0.2s ease;
    margin-left: 8px;
    padding: 4px;
    width: 20px;
    height: 20px;
}

.search-history-item:hover .btn-close {
    opacity: 1;
}

.search-history-item .btn-close:hover {
    opacity: 1;
    background: rgba(220, 53, 69, 0.2);
}

/* 下拉框滚动条样式 */
.search-suggestions::-webkit-scrollbar,
.search-history::-webkit-scrollbar {
    width: 6px;
}

.search-suggestions::-webkit-scrollbar-track,
.search-history::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.search-suggestions::-webkit-scrollbar-thumb,
.search-history::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 3px;
}

.search-suggestions::-webkit-scrollbar-thumb:hover,
.search-history::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========================================
   搜索相关按钮样式
   ======================================== */
.btn-filter-minimal {
    background: transparent;
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.btn-filter-minimal:hover {
    background: var(--btn-hover-bg);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-filter-minimal:active {
    background: var(--accent-emphasis);
    border-color: var(--accent-emphasis);
    color: var(--text-primary);
}

.btn-filter-minimal i {
    font-size: 14px;
}

.filter-separator {
    width: 1px;
    height: 24px;
    background: var(--border-primary);
    margin: 0 8px;
}

/* ========================================
   响应式设计
   ======================================== */
@media (max-width: 768px) {
    .advanced-search-panel {
        padding: 16px;
    }
    
    .advanced-search-panel .row {
        margin: 0;
    }
    
    .advanced-search-panel .col-md-6 {
        padding: 0 8px;
        margin-bottom: 12px;
    }
    
    .search-suggestions,
    .search-history {
        min-width: 100%;
        max-width: 100%;
    }
    
    .btn-filter-minimal {
        font-size: 12px;
        padding: 5px 10px;
    }
    
    .filter-separator {
        display: none;
    }
}

@media (max-width: 576px) {
    .advanced-search-panel {
        padding: 12px;
    }
    
    .advanced-search-panel .form-control-sm {
        font-size: 12px;
        padding: 5px 8px;
    }
    
    .suggestion-item,
    .search-history-item {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .suggestion-type {
        padding: 6px 10px;
        font-size: 10px;
    }
}

