/* =========== 基础重置样式与 Header 主体 =========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    scrollbar-width: thin;
}

header {
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    background-color: transparent;
    z-index: 1000;
    transition: background-color 0.3s ease-in-out;
}

header.scrolled {
    background-color: rgba(245, 245, 247, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

nav {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    width: 100%;
    height: 50px;
    position: relative;
}

nav a {
    color: #000;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    transition: background-color 0.3s ease, border 0.3s ease, color 0.3s ease;
    padding: 10px 15px;
    display: inline-block;
}

/* =========== Logo 子菜单（点击展开） =========== */
.logo-menu {
    position: relative;
    cursor: pointer;
}

.nav-logo {
    height: 22px;
    width: auto;
    display: block;
    padding: 0;
    transition: transform 0.3s ease;
}

/* 隐藏默认列表（若有） */
/* .logo-menu > ul { display: none; } */

/* 子菜单容器：固定定位、全屏覆盖 */
.logo-submenu-container {
    display: none;
    position: fixed;
    top: 50px;
    left: 0;
    width: 100vw;
    height: calc(100vh - 50px);
    background-color: #050506;
    color: #fff;
    z-index: 998;
    overflow-y: auto;
    /* 淡入动画 */
    animation: none; /* 初始无动画，由JS或激活状态触发 */
    scroll-behavior: smooth;
    scrollbar-width: thin;
    -ms-overflow-style: none;
    overflow: visible; /* 允许内容超出容器 */
}

.logo-menu.active .logo-submenu-container {
    display: flex;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 左半部分：菜单列表 */
.logo-submenu {
    width: 50%;
    list-style: none;
    padding: 60px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.logo-submenu li {
    position: relative;
    margin: 0;
    padding: 0;
}

.logo-submenu li a {
    color: #fff;
    text-decoration: none;
    font-size: 24px;
    font-weight: 300;
    letter-spacing: 0.5px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: inline-block;
    padding-bottom: 8px;
}

.logo-submenu li a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background-color: #7fa2ea;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left center;
}

.logo-submenu li:hover a {
    color: #7fa2ea;
    transform: translateX(10px);
}

.logo-submenu li:hover a::after {
    width: 100%;
}

/* 右半部分：大图预览 */
.logo-submenu-preview {
    width: 50%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000;
    overflow: hidden;
    position: relative;
}

.logo-submenu-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 改为 cover 确保填充整个容器 */
    opacity: 0;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-submenu-preview img.active {
    opacity: 1;
    transform: scale(1);
}

/* =========== 产品中心 子菜单（点击展开） =========== */
.products-dropdown {
    position: relative;
    z-index: 1000;
}

.dropdown-content {
    display: none;
    position: fixed;
    top: 50px;
    left: 0;
    width: 100vw;
    height: calc(100vh - 50px);
    background-color: rgba(5, 5, 6, 0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    z-index: 999;
    flex-direction: row;
}

.products-dropdown.active .dropdown-content {
    display: flex;
}

/* 左侧：产品类型 */
.dropdown-left {
    width: 200px;
    min-width: 200px;
    background-color: rgba(0, 0, 0, 0.3);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 70px; /* 增加顶部内边距，为关闭按钮留出空间 */
    align-self: flex-start;
}

.dropdown-left ul {
    list-style: none;
    margin-top: -10px; /* 微调整体位置 */
}

.dropdown-left li {
    padding: 15px 25px; /* 稍微增加左右内边距 */
    cursor: pointer;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    letter-spacing: 0.5px;
}

.dropdown-left li::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20px;
    width: 0;
    height: 1px;
    background-color: #7fa2ea;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left center;
}

.dropdown-left li:hover,
.dropdown-left li.active {
    background: transparent;
    color: #7fa2ea;
    transform: translateX(10px);
}

.dropdown-left li:hover::after,
.dropdown-left li.active::after {
    width: calc(100% - 40px);
}

.dropdown-left li.active {
    font-weight: 500;
    text-shadow: 0 0 10px rgba(127, 162, 234, 0.3);
}

/* 中间：具体产品区域 */
.dropdown-right {
    display: flex;
    flex-direction: row;
    width: calc(100% - 200px); /* 减去左侧菜单宽度 */
    position: relative;
}

/* 产品列表区域 */
.submenu-group {
    width: 40%; /* 确保与预览图的 60% 宽度相配合 */
    padding: 20px;
    overflow-y: auto;
    color: #fff;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    -ms-overflow-style: none;
    height: 100%;
}
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 20px;
}
.products-grid a {
    display: block;
    padding: 12px 15px;
    color: #fff;
    text-decoration: none;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    transition: all 0.3s ease;
}
.products-grid a:hover {
    background-color: rgba(127, 162, 234, 0.2);
    transform: translateX(5px);
}

/* 最右侧：预览大图区域，占60% */
#dropdown-preview {
    width: 60%;
    height: 100%;
    object-fit: cover; /* 改为 cover 实现平铺效果 */
    padding: 0; /* 移除内边距 */
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: #000;
}
#dropdown-preview.active {
    opacity: 1;
}

/* =========== 动画 =========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 滚动条样式（可选） */
.dropdown-middle::-webkit-scrollbar {
    width: 6px;
}
.dropdown-middle::-webkit-scrollbar-track {
    background: transparent;
}
.dropdown-middle::-webkit-scrollbar-thumb {
    background-color: rgba(155, 155, 155, 0.5);
    border-radius: 3px;
}

/* 删除之前的hover触发样式 */
/*
.products-dropdown:hover .dropdown-content {
    display: none;
}
*/

/* =========== 现代化滚动条样式 =========== */
/* 应用于所有可滚动区域 */
.submenu-group,
.logo-submenu-container,
.dropdown-middle {
    /* 启用平滑滚动 */
    scroll-behavior: smooth;
    /* 隐藏默认滚动条 */
    scrollbar-width: thin;
    -ms-overflow-style: none;
}

/* Webkit浏览器的滚动条样式 */
.submenu-group::-webkit-scrollbar,
.logo-submenu-container::-webkit-scrollbar,
.dropdown-middle::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

/* 滚动条轨道 */
.submenu-group::-webkit-scrollbar-track,
.logo-submenu-container::-webkit-scrollbar-track,
.dropdown-middle::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

/* 滚动条滑块 */
.submenu-group::-webkit-scrollbar-thumb,
.logo-submenu-container::-webkit-scrollbar-thumb,
.dropdown-middle::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    backdrop-filter: blur(10px);
    transition: background-color 0.3s ease;
}

/* 滚动条悬停效果 */
.submenu-group::-webkit-scrollbar-thumb:hover,
.logo-submenu-container::-webkit-scrollbar-thumb:hover,
.dropdown-middle::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* 滚动条激活状态 */
.submenu-group::-webkit-scrollbar-thumb:active,
.logo-submenu-container::-webkit-scrollbar-thumb:active,
.dropdown-middle::-webkit-scrollbar-thumb:active {
    background-color: rgba(255, 255, 255, 0.4);
}

/* 确保在深色背景下滚动条可见但不突兀 */
.dropdown-content .submenu-group::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
}

/* 添加关闭按钮样式 */
.menu-close-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-close-btn:hover {
    transform: scale(0.9) rotate(90deg);
    background: rgba(255, 255, 255, 0.2);
}

.menu-close-btn span {
    position: absolute;
    width: 18px;
    height: 2px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 1px;
    transition: all 0.3s ease;
}

.menu-close-btn span:first-child {
    transform: rotate(45deg);
}

.menu-close-btn span:last-child {
    transform: rotate(-45deg);
}

/* 修改产品中心叉叉按钮的位置 */
.products-dropdown .menu-close-btn {
    position: absolute;
    top: 25px;          /* 略微调整顶部位置 */
    left: 25px;         /* 略微调整左侧位置 */
    z-index: 1002;      /* 确保在最上层 */
}

/* 保持 Logo 菜单叉叉按钮的位置不变 */
.logo-submenu-container .menu-close-btn {
    position: absolute;
    top: 25px;          /* 与产品中心叉叉保持一致的位置 */
    left: 25px;         /* 与产品中心叉叉保持一致的位置 */
    width: 32px;
    height: 32px;
    cursor: pointer;
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;         /* 修改为默认可见 */
}

.logo-submenu-container .menu-close-btn:hover {
    transform: scale(0.9) rotate(90deg);
    background: rgba(255, 255, 255, 0.2);
}

/* 在现有样式的基础上添加返回按钮样式 */

/* 更新返回主页按钮样式 */
.back-to-home {
    position: relative;
    width: 38px;  /* 增加尺寸 */
    height: 38px;
    margin-left: 15px;
    cursor: pointer;
    border-radius: 50%;
    background: rgba(41, 151, 255, 0.1);  /* 使用品牌蓝色 */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* 添加房子图标 */
.back-to-home::before {
    content: '⌂';  /* 使用房子 Unicode 字符 */
    font-size: 22px;
    color: #2997ff;
    position: absolute;
    transition: all 0.3s ease;
}

/* 悬浮效果 */
.back-to-home:hover {
    background: rgba(41, 151, 255, 0.15);
    transform: scale(1.05);
}

.back-to-home:hover::before {
    transform: scale(1.1);
    color: #1d1d1f;
}

/* 点击效果 */
.back-to-home:active {
    transform: scale(0.95);
}

/* 添加提示文字 */
.back-to-home::after {
    content: '首页';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #1d1d1f;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.back-to-home:hover::after {
    opacity: 1;
    bottom: -25px;
}

/* 深色背景下的样式 */
header.scrolled .back-to-home {
    background: rgba(41, 151, 255, 0.08);
}

/* 点击动画 */
.back-to-home.clicked {
    animation: clickEffect 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes clickEffect {
    0% { transform: scale(1); }
    50% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* 响应式适配 */
@media screen and (max-width: 768px) {
    .back-to-home {
        width: 34px;
        height: 34px;
        margin-left: 10px;
    }
    
    .back-to-home::before {
        font-size: 20px;
    }
}

/* 添加移动端响应式布局 */
@media screen and (max-width: 1024px) { /* iPad 及以下屏幕 */
    /* 隐藏预览图片区域 */
    #dropdown-preview {
        display: none;
    }

    /* 扩展产品列表区域 */
    .dropdown-right {
        width: calc(100% - 200px);
    }

    .submenu-group {
        width: 100%; /* 占满剩余空间 */
        padding: 20px 15px;
    }

    /* 优化产品网格布局 */
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
        padding: 15px;
    }

    /* 隐藏Logo菜单预览图 */
    .logo-submenu-preview {
        display: none;
    }

    /* 扩展Logo菜单列表 */
    .logo-submenu {
        width: 100%;
        padding: 40px 30px;
    }
}

@media screen and (max-width: 768px) { /* 手机屏幕 */
    /* 调整左侧菜单宽度 */
    .dropdown-left {
        width: 140px;
        min-width: 140px;
    }

    /* 相应调整右侧区域宽度 */
    .dropdown-right {
        width: calc(100% - 140px);
    }

    /* 调整产品类型按钮样式 */
    .dropdown-left li {
        padding: 12px 15px;
        font-size: 13px;
    }

    /* 优化产品网格布局 */
    .products-grid {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 10px;
    }

    .products-grid a {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* 优化Logo菜单样式 */
    .logo-submenu li a {
        font-size: 18px;
    }

    /* 调整关闭按钮位置 */
    .menu-close-btn {
        top: 15px;
        left: 15px;
        transform: scale(0.7);
    }
}