/* ==================== 全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 明亮主题 */
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --bg-color: #f5f7fa;
    --panel-bg: #ffffff;
    --text-color: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e1e8ed;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
}

body.dark-theme {
    /* 暗黑主题 */
    --bg-color: #1a1a2e;
    --panel-bg: #16213e;
    --text-color: #eaeaea;
    --text-secondary: #a0a0a0;
    --border-color: #2a2a3e;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* ==================== 顶部标题栏 ==================== */
.header {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
}

.header-title {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 600;
}

.header-stats {
    display: flex;
    gap: 2rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.stat-value {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.125rem;
}

/* ==================== 工具栏 ==================== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    gap: 1rem;
    border-top: 1px solid var(--border-color);
}

.search-box {
    display: flex;
    flex: 1;
    max-width: 400px;
}

.search-input {
    flex: 1;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px 0 0 4px;
    font-size: 0.875rem;
    background: var(--bg-color);
    color: var(--text-color);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-btn {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transition: var(--transition);
}

.search-btn:hover {
    background: #2980b9;
}

.filter-box {
    display: flex;
    gap: 0.5rem;
}

.filter-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--panel-bg);
    color: var(--text-color);
    cursor: pointer;
}

.theme-toggle {
    padding: 0.5rem 1rem;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--bg-color);
}

/* ==================== 主容器布局 ==================== */
.main-container {
    display: flex;
    height: calc(100vh - 180px);
    gap: 1rem;
    padding: 1rem;
}

/* ==================== 左侧树形列表 ==================== */
.sidebar {
    width: 30%;
    min-width: 300px;
    background: var(--panel-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.collapse-all-btn {
    padding: 0.25rem 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.collapse-all-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.tree-container {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

/* 树节点样式 */
.tree-node {
    margin-bottom: 0.25rem;
}

.tree-node-content {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.tree-node-content:hover {
    background: var(--bg-color);
}

.tree-node-content.active {
    background: var(--primary-color);
    color: white;
}

.tree-node-icon {
    margin-right: 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    width: 20px;
    display: inline-block;
}

.tree-node-icon.expanded::before {
    content: '▼';
}

.tree-node-icon.collapsed::before {
    content: '▶';
}

.tree-node-icon.no-children::before {
    content: '•';
    font-size: 0.75rem;
}

.tree-node-label {
    flex: 1;
    font-size: 0.875rem;
}

.tree-node-badge {
    padding: 0.125rem 0.5rem;
    background: var(--secondary-color);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.tree-node-badge.status-failed {
    background: var(--danger-color);
}

.tree-node-badge.status-pending {
    background: var(--warning-color);
}

.tree-node-children {
    margin-left: 1.5rem;
    display: none;
}

.tree-node-children.expanded {
    display: block;
}

/* 不同层级的样式 */
.tree-node.level-1 .tree-node-label {
    font-weight: 600;
    font-size: 1rem;
}

.tree-node.level-2 .tree-node-label {
    font-weight: 500;
}

.tree-node.level-3 .tree-node-label {
    font-size: 0.875rem;
}

.tree-node.level-4 .tree-node-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* ==================== 右侧内容面板 ==================== */
.content-panel {
    flex: 1;
    background: var(--panel-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.panel-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.cards-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* 空状态 */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-text {
    font-size: 1rem;
}

/* ==================== 帖子卡片 ==================== */
.note-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.note-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

/* 卡片头部 */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.card-user-info {
    display: flex;
    flex-direction: column;
}

.card-username {
    font-weight: 600;
    font-size: 0.875rem;
}

.card-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* 图片轮播 */
.card-carousel {
    position: relative;
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    margin-left: auto;
    margin-right: auto;
    max-width: 600px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-color);
}

.carousel-images {
    display: flex;
    transition: transform 0.3s ease;
}

.carousel-image {
    min-width: 100%;
    width: 100%;
    height: auto;
    flex-shrink: 0;
    object-fit: contain;
    max-height: 500px;
    cursor: pointer;
}

.carousel-controls {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 0.5rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.card-carousel:hover .carousel-controls {
    opacity: 1;
}

.carousel-btn {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.carousel-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.carousel-indicators {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
}

.carousel-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: var(--transition);
}

.carousel-indicator.active {
    background: white;
    width: 24px;
    border-radius: 4px;
}

/* 卡片内容 */
.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.card-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
    max-height: 100px;
    overflow: hidden;
    position: relative;
}

.card-desc.expanded {
    max-height: none;
}

.card-desc-toggle {
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: inline-block;
}

/* 卡片底部交互数据 */
.card-stats {
    display: flex;
    gap: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.card-stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.card-stat-icon {
    font-size: 1rem;
}

/* ==================== 图片查看器模态框 ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.modal.active {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.modal-prev,
.modal-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 2rem;
    cursor: pointer;
    transition: var(--transition);
}

.modal-prev {
    left: 2rem;
}

.modal-next {
    right: 2rem;
}

.modal-prev:hover,
.modal-next:hover,
.modal-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.modal-caption {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

/* ==================== 加载和滚动条 ==================== */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 40%;
        min-width: 250px;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        max-width: none;
    }

    .main-container {
        flex-direction: column;
        height: auto;
    }

    .sidebar {
        width: 100%;
        max-height: 300px;
    }
}
