/* 树状层级搜索结果样式 */

/* 树状容器 */
.tree-container {
    display: flex;
    flex-direction: column;
    gap: 16px;  /* Spacing between non-parent-child nodes */
    padding: 20px;
}

/* 树状节点 */
.tree-node {
    position: relative;
    margin-left: 0;
    margin-bottom: 0;
}

/* Spacing for child nodes (parent-child relationship) */
/* Smaller gap than the container gap (16px) */
.tree-node[data-level="1"],
.tree-node[data-level="2"],
.tree-node[data-level="3"],
.tree-node[data-level="4"] {
    margin-top: 8px;  /* Smaller spacing for parent-child nodes */
}

/* 子节点缩进 */
/* 注意：由于 HTML 是嵌套结构，margin-left 会叠加 */
/* 一级节点：相对于容器 margin-left: 40px */
/* 二级节点：相对于一级节点 margin-left: 40px（不是 80px！）*/
.tree-node[data-level="1"] { margin-left: 40px; }
.tree-node[data-level="2"] { margin-left: 40px; }  /* 改为 40px，因为是在一级节点内部 */
.tree-node[data-level="3"] { margin-left: 40px; }  /* 改为 40px */
.tree-node[data-level="4"] { margin-left: 40px; }  /* 改为 40px */

/* 层级连接线 - 竖线（从父节点延伸下来的线） */
/* 只在非顶级节点显示 */
.tree-node:not([data-level="0"])::before {
    content: "";
    position: absolute;
    left: -20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 100%);
    z-index: 1;
}

/* 水平连接线 - 连接到卡片 */
/* 由于 .tree-node 包含子节点，高度不确定，所以水平线需要相对于 .tree-card 定位 */
/* 改用 .tree-card 的 ::before 来显示水平线 */
.tree-node:not([data-level="0"]) > .tree-card::before,
.tree-node:not([data-level="0"]) > .tree-card-placeholder::before {
    content: "";
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 2px;
    background: #cbd5e1;
    z-index: 2;
}

/* 注意：.tree-card 有 overflow:hidden，需要改为 overflow:visible */
/* 但这会影响 hover 效果，所以需要另外处理 */

/* 移除原来在 .tree-node 上的水平线 */
.tree-node:not([data-level="0"])::after {
    display: none;
}

/* 节点卡片 */
.tree-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: visible;  /* 改为 visible，允许水平线显示在卡片外部 */
}

.tree-card:hover {
    transform: translateX(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    border-color: #f97316;  /* 橙色边框，视觉冲击更强 */
    border-left: 4px solid #f97316;  /* 橙色左边框 */
    padding-left: 7px;  /* 减少左内边距以补偿边框宽度 */
}

/* 移除原来的 hover 伪元素效果 */
.tree-card:hover::after {
    display: none;
}

/* 缩略图 */
.tree-thumbnail {
    width: 128px;
    height: 96px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.tree-card:hover .tree-thumbnail {
    transform: scale(1.05);
}

/* 文件夹图标占位符（当相册没有封面图时） */
.tree-thumbnail-icon {
    width: 128px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-radius: 6px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.tree-thumbnail-icon svg {
    width: 48px;
    height: 48px;
    color: #58b307;
}

.tree-card:hover .tree-thumbnail-icon {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
}

.tree-card:hover .tree-thumbnail-icon svg {
    color: #64748b;
}

/* 内容区域 */
.tree-content {
    flex: 1;
    min-width: 0;
}

/* 层级徽章 */
.tree-level-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
}

.tree-level-badge.level-0 {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

.tree-level-badge.level-1 {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

.tree-level-badge.level-2 {
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
    color: #5b21b6;
}

.tree-level-badge.level-3 {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
    color: #9d174d;
}

/* 卡片头部：层级徽章 + 元信息 并排显示 */
.tree-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

/* 元信息行内样式 */
.tree-meta-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tree-meta-item-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #64748b;
}

.tree-meta-item-inline svg {
    width: 12px;
    height: 12px;
    color: #94a3b8;
}

.tree-meta-item-inline.tree-stats {
    color: #475569;
    font-weight: 500;
}

/* 层级信息行分隔符 */
.tree-header-separator {
    border: none;
    border-top: 1px solid #c5c5c5;
    margin: 6px 0;
}

/* 标题 */
.tree-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a202c;
    margin: 0 0 4px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 路径面包屑 */
.tree-breadcrumb {
    font-size: 12px;
    color: #718096;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.tree-breadcrumb-item {
    color: #4a5568;
}

.tree-breadcrumb-separator {
    color: #4A5568;
    margin: 0 2px;
}

/* 描述 */
.tree-description {
    font-size: 13px;
    color: #4a5568;
    line-height: 1.4;
    margin: 4px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 子节点计数 */
.tree-children-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #edf2f7;
    color: #4a5568;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
}

/* 空状态 */
.tree-empty {
    text-align: center;
    padding: 60px 20px;
    color: #a0aec0;
}

.tree-empty svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    color: #cbd5e1;
}

/* Placeholder nodes (missing parent albums) */
/* .tree-node-placeholder styling is applied via .tree-card-placeholder */
/* 占位符相册卡片配色 */
.tree-card-placeholder {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%) !important;
    border: 1px dashed #64748b !important;
    border-radius: 10px;
    padding: 10px;
    cursor: default;
}

.tree-card-placeholder:hover {
    transform: none;
    box-shadow: none;
    border-color: #64748b;
}

.tree-thumbnail-placeholder {
    width: 128px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
    border-radius: 6px;
    flex-shrink: 0;
}

.tree-thumbnail-placeholder svg {
    width: 40px;
    height: 40px;
    color: #64748b;
}

.tree-title-placeholder {
    color: #475569;
    font-style: italic;
}

/* Children of placeholder nodes that are NOT placeholders themselves should have normal styling */
.tree-node-placeholder > .tree-node:not(.tree-node-placeholder) .tree-card {
    /* Reset to normal card styling */
    background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    border: 1px solid #e2e8f0;
}

.tree-node-placeholder > .tree-node:not(.tree-node-placeholder) .tree-card:hover {
    transform: translateX(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    border-color: #f97316;  /* 橙色边框 */
    border-left: 4px solid #f97316;  /* 橙色左边框 */
    padding-left: 7px;
}

/* 展开/收起按钮 */
.tree-toggle {
    position: absolute;
    left: -30px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.tree-toggle:hover {
    background: #60a5fa;
    border-color: #3b82f6;
    color: #fff;
}

.tree-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
}

.tree-toggle.collapsed svg {
    transform: rotate(-90deg);
}

/* 响应式 */
@media (max-width: 768px) {
    .tree-card {
        flex-direction: column;
        padding: 12px;
    }
    
    .tree-thumbnail {
        width: 100%;
        height: 180px;
    }
    
    .tree-node[data-level="1"] { margin-left: 20px; }
    .tree-node[data-level="2"] { margin-left: 40px; }
    .tree-node[data-level="3"] { margin-left: 60px; }
    .tree-node[data-level="4"] { margin-left: 80px; }
}

/* ========================================
   图片搜索 - 按相册分组显示样式
   ======================================== */

/* 分组容器 */
.photo-grouped-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 20px;
}

/* 相册分组 */
.photo-album-group {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    transition: box-shadow 0.3s ease;
}

.photo-album-group:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* 相册标题栏 */
.photo-album-header {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.photo-album-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #1e40af;
    font-weight: 600;
    transition: color 0.2s ease;
}

.photo-album-link:hover {
    color: #3b82f6;
}

.photo-album-icon {
    width: 20px;
    height: 20px;
    color: #64748b;
}

.photo-album-title {
    font-size: 16px;
}

.photo-album-count {
    font-size: 13px;
    color: #64748b;
    font-weight: 400;
}

/* 图片网格 */
.photo-album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

/* 单个图片项 */
.photo-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.photo-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.photo-item a {
    display: block;
    text-decoration: none;
}

.photo-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

/* 图片标题叠加层 - 默认显示 */
.photo-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    padding: 8px;
    opacity: 1;  /* 默认显示 */
}

.photo-item-title {
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 面包屑路径样式 */
.photo-album-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.photo-breadcrumb-item {
    color: #291c04;
    text-decoration: none;
    font-size: 16px;
    transition: color 0.2s ease;
}

.photo-breadcrumb-item:hover {
    color: #1e40af;
    text-decoration: underline;
}

.photo-breadcrumb-current {
    font-weight: 600;
}

.photo-breadcrumb-separator {
    color: #94a3b8;
    font-size: 14px;
}

/* 图片描述提示框 */
.photo-tooltip {
    position: absolute;
    max-width: 300px;
    padding: 10px 14px;
    background: rgba(30, 41, 59, 0.95);
    color: #fff;
    font-size: 13px;
    line-height: 1.5;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    pointer-events: none;
    word-wrap: break-word;
}

/* 响应式 - 图片搜索 */
@media (max-width: 768px) {
    .photo-album-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
    }
    
    .photo-item img {
        height: 100px;
    }
    
    .photo-tooltip {
        max-width: 200px;
        font-size: 12px;
    }
}
