/**
 * 菜单和布局样式
 * 电脑版：侧边栏显示，可收缩
 * 手机版：顶部汉堡菜单，展开后在头部下方
 */

/* ==================== 全局重置 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Microsoft YaHei", sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
}

/* ==================== 顶部导航栏 ==================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
}

/* 左侧 Logo */
.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 移动端菜单按钮（默认隐藏）*/
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    gap: 5px;
}

.mobile-menu-btn .bar {
    width: 22px;
    height: 2px;
    background: #374151;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-btn.active .bar:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-btn.active .bar:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active .bar:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.header-left .logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    height: 100%;
    padding: 8px 0;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

/* 右侧用户信息 */
.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-left: 20px;
    border-left: 1px solid #e5e7eb;
}

.user-info {
    display: flex;
    align-items: center;
}

.user-detail {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.4;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
}

.user-role {
    font-size: 12px;
    color: #6b7280;
}

/* ==================== 侧边栏（电脑版）==================== */
.sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    width: 240px;
    height: calc(100vh - 60px);
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    box-shadow: 1px 0 3px rgba(0, 0, 0, 0.05);
    transition: width 0.3s ease;
    z-index: 999;
    overflow-y: auto;
    overflow-x: hidden;
}

/* 收缩状态 */
.sidebar.collapsed {
    width: 70px;
}

/* 悬停展开（电脑版）*/
.sidebar.collapsed:hover {
    width: 240px;
}

/* 侧边栏头部 */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 15px 16px;
    border-bottom: 1px solid #f3f4f6;
}

/* 展开/收缩按钮（电脑版）*/
.sidebar-header .toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
    text-decoration: none;
}

.sidebar-header .toggle-btn:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.sidebar-header .toggle-btn svg {
    transition: transform 0.3s ease;
}

.sidebar.collapsed .toggle-btn svg {
    transform: rotate(180deg);
}

/* 移动端按钮（默认隐藏）*/
.sidebar-header .mobile-btn {
    display: none;
}

/* 侧边栏内容 */
.sidebar-inner {
    padding: 16px 0;
}

.sidebar-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu > ul {
    padding: 0 12px;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #4b5563;
    text-decoration: none;
    transition: all 0.2s ease;
    gap: 12px;
    border-radius: 8px;
    font-size: 14.5px;
    font-weight: 500;
}

.sidebar-menu a:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.sidebar-menu li.active > a {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.sidebar-menu li.active > a svg {
    color: #ffffff;
}

.sidebar-menu a svg {
    min-width: 20px;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-width: 2.2;
}

.sidebar-menu a span {
    white-space: nowrap;
    transition: all 0.3s ease;
}

.sidebar.collapsed a span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed:hover a span {
    opacity: 1;
    width: auto;
}

/* ==================== 主内容区 ==================== */
.main-wrapper {
    margin-left: 240px;
    margin-top: 60px;
    min-height: calc(100vh - 60px);
    transition: margin-left 0.3s ease;
}

body.mini-sidebar .main-wrapper {
    margin-left: 70px;
}

/* ==================== 内容容器 ==================== */
.container {
    padding: 30px;
    max-width: 1400px;
}

.page {
    padding: 30px;
    max-width: 1200px;
}

.page__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page__title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
}

/* ==================== 统计卡片 ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-left: 4px solid;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.stat-card.blue { border-left-color: #3b82f6; }
.stat-card.pink { border-left-color: #e211f1; }
.stat-card.orange { border-left-color: #f59e0b; }
.stat-card.green { border-left-color: #10b981; }
.stat-card.purple { border-left-color: #8b5cf6; }
.stat-card.red { border-left-color: #ef4444; }

.stat-card h3 {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 10px;
    font-weight: 500;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    color: #1f2937;
}

.stat-card .sub-value {
    font-size: 13px;
    color: #6b7280;
    margin-top: 8px;
}

/* ==================== 内容网格 ==================== */
.content-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.content-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 20px;
}

.content-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #1f2937;
    padding-bottom: 10px;
    border-bottom: 2px solid #e5e7eb;
}

.data-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.data-item {
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
}

.data-item:last-child {
    border-bottom: none;
}

.item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.item-name {
    font-weight: 600;
    color: #1f2937;
}

.item-details {
    font-size: 13px;
    color: #6b7280;
    margin-top: 5px;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #9ca3af;
}

/* ==================== 移动端适配 ==================== */
@media (max-width: 768px) {
    /* 显示移动端菜单按钮 */
    .mobile-menu-btn {
        display: flex;
    }
    
    /* 隐藏电脑版的展开/收缩按钮 */
    .sidebar-header .toggle-btn {
        display: none;
    }
    
    /* 隐藏sidebar中的mobile-btn */
    .sidebar-header .mobile-btn {
        display: none;
    }
    
    /* 侧边栏默认隐藏 */
    .sidebar {
        transform: translateX(-100%);
        top: 60px;
        width: 250px;
    }
    
    /* 展开状态 */
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* 取消悬停展开 */
    .sidebar.collapsed:hover {
        width: 250px;
        transform: translateX(-100%);
    }
    
    .sidebar.mobile-open.collapsed:hover {
        transform: translateX(0);
    }
    
    /* 主内容区不留边距 */
    .main-wrapper {
        margin-left: 0;
    }
    
    body.mini-sidebar .main-wrapper {
        margin-left: 0;
    }
    
    /* 网格改为单列 */
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* 容器内边距减小 */
    .container,
    .page {
        padding: 20px 15px;
    }
    
    /* 手机版用户信息调整 */
    .header-right {
        gap: 10px;
        padding-left: 10px;
    }
    
    .user-name {
        font-size: 13px;
    }
    
    .user-role {
        font-size: 11px;
    }
}

/* ==================== 滚动条样式 ==================== */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
