/* css/header.css - 修复移动菜单点击问题 */

:root {
    --primary-color: #4361ee;
    --secondary-color: #3a56d4;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --gray-color: #6c757d;
    --border-color: #e9ecef;
}

/* ============ 重置和基础样式 ============ */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

/* ============ 桌面端导航 ============ */
.desktop-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.desktop-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.desktop-nav a:hover {
    background-color: #f5f5f5;
    color: var(--primary-color);
}

.desktop-nav a.active {
    background-color: var(--primary-color);
    color: white;
}

/* ============ 移动端菜单按钮 - 修复点击问题 ============ */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #333;
    width: 50px; /* 更大的点击区域 */
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    padding: 0;
    transition: background-color 0.2s ease;
    position: relative; /* 确保在正确层级 */
    z-index: 1002; /* 确保按钮在最上层 */
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
    touch-action: manipulation; /* 优化触摸响应 */
}

.mobile-menu-btn:hover {
    background-color: #f5f5f5;
}

/* 移动端按钮的点击反馈 */
.mobile-menu-btn:active {
    background-color: #e0e0e0;
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* ============ 移动端菜单 ============ */
.mobile-nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background-color: white;
    box-shadow: -2px 0 15px rgba(0,0,0,0.1);
    z-index: 1003; /* 高于按钮 */
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    will-change: right; /* 优化动画性能 */
}

.mobile-nav.active {
    right: 0;
}

/* 移动端菜单头部 */
.mobile-nav-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
}

.mobile-nav-title {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 18px;
}

.mobile-nav-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #666;
    width: 44px; /* 更大的点击区域 */
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 0;
    transition: background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
    touch-action: manipulation; /* 优化触摸响应 */
}

.mobile-nav-close:hover {
    background-color: #f5f5f5;
}

.mobile-nav-close:active {
    background-color: #e0e0e0;
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* 移动端菜单内容区域 */
.mobile-nav-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 0;
    width: 100%;
}

/* 移动端菜单列表 */
.mobile-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

/* 移动端菜单项 */
.mobile-nav li {
    width: 100%;
}

.mobile-nav a {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    text-decoration: none;
    color: #333;
    font-size: 15px;
    font-weight: 500;
    width: 100%;
    background-color: white;
    transition: background-color 0.2s ease;
    border-left: 4px solid transparent;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
    touch-action: manipulation; /* 优化触摸响应 */
}

/* 激活状态 */
.mobile-nav a.active {
    background-color: #f8f9fa;
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.mobile-nav a:hover {
    background-color: #f5f5f5;
}

/* 移动端触摸反馈 */
.mobile-nav a:active {
    background-color: #e0e0e0;
    transition: background-color 0.1s ease;
}

/* 图标样式 */
.mobile-nav a i {
    width: 22px;
    font-size: 16px;
    text-align: center;
    margin-right: 12px;
    color: #666;
}

.mobile-nav a.active i {
    color: var(--primary-color);
}

/* 徽章样式 */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    border-radius: 10px;
    margin-left: 8px;
    min-width: 18px;
    height: 18px;
}

.badge-danger {
    background-color: var(--danger-color);
    color: white;
}

/* ============ 头部样式 ============ */
header {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 70px;
    display: flex;
    align-items: center;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.logo i {
    font-size: 1.6rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
}

main {
    min-height: calc(100vh - 70px - 70px);
    padding: 25px 0;
}

/* ============ 响应式设计 ============ */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex; /* 确保移动端按钮可见 */
        z-index: 1002; /* 确保按钮在最上层 */
    }
    
    .desktop-nav {
        display: none;
    }
    
    .mobile-nav {
        display: flex;
        z-index: 1003; /* 确保菜单在按钮上层 */
    }
    
    /* 确保没有其他元素覆盖按钮 */
    header {
        position: relative;
        z-index: 1001;
    }
    
    /* 移动端调整头部高度 */
    header {
        height: 65px;
    }
    
    .logo {
        font-size: 1.3rem;
    }
    
    .logo i {
        font-size: 1.5rem;
    }
    
    /* 调整主内容区域 */
    main {
        min-height: calc(100vh - 65px - 60px);
        padding: 20px 0;
        padding-bottom: 80px;
    }
    
    /* 在移动端增加按钮的点击区域 */
    .mobile-menu-btn {
        width: 48px;
        height: 48px;
    }
    
    .mobile-nav-close {
        width: 42px;
        height: 42px;
    }
}

/* 小屏幕手机优化 */
@media (max-width: 480px) {
    header {
        height: 60px;
    }
    
    .logo {
        font-size: 1.2rem;
        gap: 8px;
    }
    
    .logo i {
        font-size: 1.4rem;
    }
    
    .container {
        padding: 0 15px;
    }
    
    .mobile-nav {
        width: 260px;
    }
    
    .mobile-nav a {
        padding: 12px 18px;
        font-size: 14px;
    }
    
    /* 进一步增加按钮点击区域 */
    .mobile-menu-btn {
        width: 46px;
        height: 46px;
        font-size: 1.3rem;
    }
    
    .mobile-nav-close {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .mobile-menu-btn,
    .mobile-nav-close,
    .mobile-nav a {
        cursor: default; /* 移除桌面端的指针样式 */
    }
    
    /* 确保触摸目标足够大 */
    .mobile-menu-btn,
    .mobile-nav-close {
        min-height: 48px;
        min-width: 48px;
    }
    
    .mobile-nav a {
        min-height: 50px;
    }
    
    /* 优化触摸反馈 */
    .mobile-menu-btn:active,
    .mobile-nav-close:active,
    .mobile-nav a:active {
        background-color: #e8e8e8;
        transition: background-color 0.1s;
    }
}