:root {
    --primary: #2563eb;
    --primary-light: #dbeafe;
    --primary-dark: #1e40af;
    --bg-white: #ffffff;
    --bg-light: #f9fafb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #d1d5db;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-white: #1f2937;
    --bg-light: #111827;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    --border-color: #374151;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

/* ============ 顶部栏 ============ */
.top-bar {
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    box-shadow: var(--shadow-sm);
}

.header-left h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -1px;
}

/* ============ 主容器 ============ */
.container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ============ 左侧栏 ============ */
.sidebar {
    width: 270px;
    background-color: var(--bg-white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 14px;
    color: var(--text-primary);
}

#search-input::placeholder {
    color: var(--text-secondary);
}

.search-icon {
    font-size: 14px;
    margin-left: 8px;
    color: var(--text-secondary);
}

/* 分类列表 */
.categories {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.categories::-webkit-scrollbar {
    width: 6px;
}

.categories::-webkit-scrollbar-track {
    background: var(--bg-light);
}

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

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

.category {
    border-bottom: 1px solid var(--border-color);
}

.category-header {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
}

.category-header:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.category-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    font-size: 12px;
    transition: var(--transition);
}

.category-toggle.expanded {
    transform: rotate(180deg);
}

.category-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-secondary);
    background-color: rgba(37, 99, 235, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.category-links {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.category-links.collapsed {
    max-height: 0;
}

.link-item {
    display: flex;
    align-items: center;
    padding: 8px 12px 8px 32px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    color: var(--text-primary);
    text-decoration: none;
    gap: 8px;
    overflow: hidden;
}

.link-item:hover {
    background-color: var(--primary-light);
    color: var(--primary);
    padding-left: 36px;
}

.link-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.link-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    gap: 2px;
}

.link-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-url {
    font-size: 12px;
    color: var(--primary);
    font-weight: 500;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.8;
}

.link-item:hover .link-url {
    color: var(--primary-dark);
    opacity: 1;
}

/* ============ 右侧主内容区 ============ */
.main-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-light);
    padding: 20px;
}

.content-placeholder {
    text-align: center;
    color: var(--text-secondary);
    font-size: 16px;
}

/* ============ 加载动画 ============ */
.loading-spinner {
    display: none;
    width: 30px;
    height: 30px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ 空状态 ============ */
.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============ 页脚 ============ */
.footer {
    background-color: var(--bg-white);
    border-top: 1px solid var(--border-color);
    padding: 10px 20px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

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

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 50%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .main-content {
        height: 50%;
    }

    .header-left h1 {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .top-bar {
        padding: 12px 16px;
    }

    .header-left h1 {
        font-size: 18px;
    }

    .sidebar-header {
        padding: 8px 12px;
    }

    .category-header {
        padding: 8px 10px;
        font-size: 13px;
    }

    .link-item {
        padding: 6px 10px 6px 28px;
        font-size: 12px;
    }
}
