/* ========================================
   模块化重构：侧边栏布局样式
   ======================================== */

/* CSS 变量：配色方案 */
:root {
    --primary-purple: #6366f1;
    --primary-purple-dark: #4f46e5;
    --primary-purple-light: #818cf8;
    --accent-orange: #f97316;
    --accent-orange-light: #fb923c;
    --bg-gray: #f8fafc;
    --bg-white: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

/* 主布局容器 */
.admin-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-gray);
}

/* ==================== 侧边栏 ==================== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-purple) 0%, var(--primary-purple-dark) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

/* 侧边栏头部 */
.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar .logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.sidebar .logo svg {
    flex-shrink: 0;
}

/* 侧边栏导航 */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    padding: 8px 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.5);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-orange);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.nav-item.active::before {
    opacity: 1;
}

.nav-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
    flex-shrink: 0;
}

/* 侧边栏底部 */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-settings {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-settings:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.sidebar-settings svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ==================== 主内容包装器 ==================== */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==================== 顶部栏 ==================== */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 90;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: var(--bg-gray);
    color: var(--text-primary);
}

.sidebar-toggle svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.search-box {
    position: relative;
    max-width: 480px;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    fill: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 42px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-gray);
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-purple-light);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-icon-btn:hover {
    background: var(--bg-gray);
    color: var(--text-primary);
}

.topbar-icon-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.topbar-icon-btn .badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--accent-orange);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    border-radius: 9px;
    text-align: center;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.topbar-user:hover {
    background: var(--bg-gray);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-purple), var(--primary-purple-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.user-avatar svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.user-info-dropdown {
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.dropdown-arrow {
    width: 18px;
    height: 18px;
    fill: var(--text-muted);
}

/* ==================== 主内容区 ==================== */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.content-wrapper {
    max-width: 1400px;
    margin: 0 auto;
}

/* Tab 内容容器适配 */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

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

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 200;
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .search-box {
        max-width: 300px;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 240px;
        --topbar-height: 56px;
    }

    .topbar {
        padding: 0 16px;
    }

    .main-content {
        padding: 16px;
    }

    .search-box {
        display: none;
    }

    .user-name {
        display: none;
    }
}

/* ==================== 隐藏旧导航样式 ==================== */
.top-nav,
.nav-tabs {
    display: none !important;
}
