/* Header */
header {
    background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0) 100%);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    transition: all 0.3s ease;
    color: #fff;
    /* border-bottom: 1px solid rgb(146 208 255 / 80%)  */
}

/* 鼠标移入或滚动后的导航栏 */
header:hover, header.scrolled {
    background: #ffffff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    color: #333;
    border-bottom: 1px solid #eee;
}

.top-bar {
    background: transparent;
    font-size: 12px;
    padding: 10px 0;
    border-bottom: none;
}

header:hover .top-bar, header.scrolled .top-bar {
    color: #666;
}

.top-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.right-info {
    display: flex;
    gap: 20px;
    align-items: center;
}

.icon-img {
    height: 16px;
    width: 16px;
    vertical-align: middle;
    margin-right: 5px;
    display: inline-block;
    background-color: currentColor;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}

.icon-phone {
    -webkit-mask-image: url('/images/home/电话.svg');
    mask-image: url('/images/home/电话.svg');
}

.icon-message {
    -webkit-mask-image: url('/images/home/留言.svg');
    mask-image: url('/images/home/留言.svg');
}

/* header:hover .icon-img, header.scrolled .icon-img {
    filter: none;
} */

/* 如果原图是彩色的，需要确认是否需要反转。这里假设原图在深色背景下需要变白 */
/* 修正：如果原图是蓝色/黑色，invert(1)会变成白色/黄色。 */
/* 如果原图是适合白底的颜色，那么在黑底（header默认）下需要变白。 */

.btn-login {
    background: #ffffff; /* 白色背景 */
    color: var(--primary-color); /* 蓝色文字 */
    padding: 4px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

header:hover .btn-login, header.scrolled .btn-login {
    background: var(--primary-color);
    color: #fff;
}

header:hover .logo-default, header.scrolled .logo-default {
    display: none;
}

header:hover .logo-scrolled, header.scrolled .logo-scrolled {
    display: block;
}
.logo-scrolled{
     display: none;
}

.main-nav {
    display: flex;
    /* justify-content: space-between; Removed to allow centering */
    align-items: center;
    height: 80px;
    position: relative; /* For potential absolute positioning if needed */

    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 70px;
}

.nav-links {
    display: flex;
    gap: 50px;
    /* margin: 0 auto; */
}

.nav-links a {
    font-size: 16px;
    font-weight: 500;
    padding: 10px 0;
    position: relative;
    color: inherit;
    text-decoration: none;
}

.nav-links a:hover, .nav-links a.active {
    color: #fff;
    font-weight: bold;
}

/* Dropdown Menu */
.nav-item-container {
    position: relative;
    display: flex;
    align-items: center;
}

.nav-item-container > a.has-dropdown {
    padding-right: 5px;
}

.nav-item-container > a.has-dropdown::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 8px;
    vertical-align: middle;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.3s ease;
    margin-top: -4px;
}

.nav-item-container:hover > a.has-dropdown::after {
    transform: rotate(225deg);
    margin-top: 0;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    min-width: 140px;
    padding: 0; /* Remove padding to keep it clean */
    display: none;
    z-index: 1100;
    border-radius: 0 0 4px 4px;
    overflow: hidden;
    margin-top: 0px; /* Connect to the header */
}

.nav-item-container:hover .dropdown-menu {
    display: block;
    animation: fadeIn 0.3s ease;
}

.dropdown-menu a {
    display: block;
    padding: 12px 20px;
    color: #666 !important;
    font-size: 14px;
    font-weight: normal;
    text-align: center;
    border-bottom: 1px solid #f5f5f5;
    background: #fff;
}

.dropdown-menu a:last-child {
    border-bottom: none;
}

.dropdown-menu a:hover {
    background-color: var(--primary-color);
    color: #fff !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

header:hover .nav-links a:hover, 
header:hover .nav-links a.active,
header.scrolled .nav-links a:hover,
header.scrolled .nav-links a.active {
    color: var(--primary-color);
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    font-size: 24px;
    cursor: pointer;
    color: #fff;
    margin-left: auto; /* Push to right */
}

header:hover .menu-toggle, header.scrolled .menu-toggle {
    color: #333;
}

/* Hamburger Menu Icon */
.hamburger {
    width: 24px;
    height: 18px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: #333;
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

/* Animation to X */
.menu-toggle.active .hamburger span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.menu-toggle.active .hamburger span:nth-child(2) {
    opacity: 0;
    transform: translateX(10px);
}

.menu-toggle.active .hamburger span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Mobile Menu Footer - Hidden on Desktop */
.mobile-menu-footer {
    display: none;
}

/* Responsive Design */
@media (max-width: 992px) {
    header {
        background: #ffffff !important; /* Force white background */
        border-bottom: 1px solid #eee;
        height: 60px;
    }

    .container {
        width: 100% !important;
        padding: 0 20px;
    }
    
    .top-bar {
        display: none; /* Hide top bar on mobile/tablet to save space */
    }

    .menu-toggle {
        display: block;
        color: #333;
    }

    .nav-links {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 60px;
        left: 0;
        width: 100%;
        height: calc(100vh - 60px); /* Full height */
        background: #fff;
        transform: translateX(100%); /* Slide out to right */
        transition: transform 0.3s ease-in-out;
        overflow-y: auto; /* Enable vertical scrolling */
        box-shadow: none;
        gap: 0;
        padding: 0;
        border-top: 1px solid #f5f5f5;
        max-height: none; /* Reset max-height */
        padding-bottom: 40px; /* Space for bottom content */
    }

    .nav-links.active {
        transform: translateX(0); /* Slide in */
        box-shadow: none;
    }

    .nav-links a, .nav-item-container {
        width: 100%;
        text-align: center;
        color: #333 !important; /* Force black text on white bg */
        padding: 0;
        border-bottom: 1px solid #f5f5f5;
    }
    
    .nav-links > a, .nav-item-container > a {
        display: block;
        padding: 15px 0;
    }
    
    .nav-item-container {
        flex-direction: column;
    }

    .dropdown-menu {
        position: static;
        transform: none;
        box-shadow: none;
        background: #f9f9f9;
        display: none; /* Default hidden on mobile */
        width: 100%;
        margin-top: 0;
    }

    .dropdown-menu a {
        display: block;
        padding: 12px 20px;
        color: #666 !important;
        font-size: 14px;
        font-weight: normal;
        text-align: center;
        border-bottom: 1px solid #f5f5f5;
        background: #fff;
    }
    
    /* Submenu visibility controlled by JS class */
    .nav-item-container.dropdown-open .dropdown-menu {
        display: block;
        animation: none; /* Remove fade animation for instant response */
    }
    
    /* Disable hover on mobile */
    .nav-item-container:hover .dropdown-menu {
        display: none;
    }
    
    /* Keep it visible if open */
    .nav-item-container.dropdown-open:hover .dropdown-menu {
        display: block;
    }
    
    /* Fix sticky hover on mobile: Reset rotation if not open */
    .nav-item-container:hover > a.has-dropdown::after {
        transform: rotate(45deg);
        margin-top: -4px;
    }

    /* Arrow rotation - force override hover */
    .nav-item-container.dropdown-open > a.has-dropdown::after {
        transform: rotate(225deg);
        margin-top: 0;
    }
    
    .logo img {
        height: 40px;
    }
    .logo-scrolled{
     display: block;
    }
    .logo-default{
        display: none;
    }
    
    .main-nav {
        height: 60px;
    }

    /* Mobile Menu Footer Styles */
    .mobile-menu-footer {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 15px;
        padding: 30px 20px;
        width: 100%;
        margin-top: auto;
        border-top: 1px solid #f5f5f5;
        background: #fafafa;
    }

    .mobile-btn-login {
        display: block;
        background-color: var(--primary-color, #1E90FF);
        color: #fff !important;
        padding: 10px 60px;
        border-radius: 25px;
        text-decoration: none;
        font-weight: bold;
        font-size: 16px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        
    }

    .mobile-contact-info {
        display: flex;
        flex-direction: column;
        gap: 12px;
        align-items: center;
        width: 100%;
        margin-top: 10px;
    }

    .mobile-contact-item {
        display: flex;
        align-items: center;
        gap: 8px;
        color: #666;
        font-size: 14px;
        justify-content: center;
    }

    .mobile-contact-item a {
        color: #666 !important;
        text-decoration: none;
        padding: 0;
        border: none;
        width: auto;
        display: inline;
        font-weight: normal;
    }

    .mobile-contact-item .icon-img {
        background-color: #999;
        width: 16px;
        height: 16px;
        margin-right: 0;
    }
}
