/* navbar.css - 导航栏样式 */

.navbar {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

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

.navbar-brand a {
    font-size: 1.5rem;
    font-weight: bold;
    color: #07C160;
    text-decoration: none;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.navbar-menu a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.2s;
    position: relative;
}

.navbar-menu a:hover {
    color: #07C160;
}

.navbar-menu a.active {
    color: #07C160;
    font-weight: 600;
}

.navbar-menu a.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 2px;
    background-color: #07C160;
}

/* 用户导航区域 */
.navbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.navbar-login,
.navbar-register {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.navbar-login {
    color: #07C160;
    border: 1px solid #07C160;
}

.navbar-login:hover {
    background: #07C160;
    color: white;
}

.navbar-register {
    background: #07C160;
    color: white;
    border: 1px solid #07C160;
}

.navbar-register:hover {
    background: #06a852;
    border-color: #06a852;
}

/* 已登录用户菜单 */
.navbar-user-menu {
    position: relative;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.navbar-user-menu:hover {
    background: #f5f5f5;
}

.navbar-user-menu span {
    color: #333;
    font-weight: 500;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 160px;
    display: none;
    z-index: 1001;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #333;
    transition: background 0.2s;
}

.dropdown-menu a:hover {
    background: #f5f5f5;
    color: #07C160;
}

/* 汉堡菜单按钮 */
.navbar-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 21px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1002;
}

.navbar-toggle span {
    display: block;
    height: 3px;
    width: 100%;
    background: #333;
    border-radius: 10px;
    transition: all 0.3s ease-in-out;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .navbar .container {
        padding: 1rem;
    }
    
    .navbar-brand a {
        font-size: 1.25rem;
    }
    
    /* 显示汉堡菜单，隐藏常规菜单 */
    .navbar-toggle {
        display: flex;
    }
    
    .navbar-menu {
        position: fixed;
        top: 60px;
        right: 0;
        background: white;
        width: 50%; /* 只占屏幕右半部分 */
        max-width: 300px; /* 限制最大宽度，避免在大屏幕上过宽 */
        padding: 20px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        z-index: 1000;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        /* 垂直排列菜单项 */
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0; /* 移除gap，使用margin控制间距 */
    }
    
    .navbar-menu.active {
        transform: translateX(0);
    }
    
    .navbar-menu a,
    .navbar-login,
    .navbar-register,
    .mobile-menu-item {
        display: block;
        margin: 10px 0;
        text-align: center;
        padding: 10px;
        min-height: 44px; /* 确保最小触摸目标大小 */
        width: 100%;
        box-sizing: border-box;
    }
    
    .navbar-user {
        margin-top: 20px;
        border-top: 1px solid #eee;
        padding-top: 20px;
        width: 100%;
    }
    
    /* 汉堡菜单动画 */
    .navbar-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }
    
    .navbar-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .navbar-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }
    
    /* 防止页面滚动 */
    body.menu-open {
        overflow: hidden;
    }
    
    /* 移动端下拉菜单 */
    .dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        margin-top: 10px;
        width: 100%;
    }
    
    .dropdown-menu.show {
        display: block;
    }
}