/**
 * 导航栏及通用页头样式
 * 包含搜索框、返回顶部按钮及响应式调整
 */

/* 导航栏基础样式 - 保持胶囊形状 */
.navbar-pill {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 26px; /* 始终保持 26px 圆角 */
    padding: 0 15px;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
    width: fit-content !important;
    min-width: auto;
    max-width: 95%;
    margin: 10px auto;
    height: 52px;
    min-height: 52px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-content-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
}

body.dark-mode .navbar-pill {
    border-color: var(--glass-border);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.15rem; /* 稍微减小 logo 文字大小以适应 52px 高度 */
    color: var(--text-color) !important;
    text-decoration: none;
}

.nav-link {
    color: var(--text-color) !important;
    opacity: 0.8;
    font-weight: 500;
    padding: 0.4rem 1rem !important;
    border-radius: 20px;
    transition: all 0.2s ease;
    font-size: 0.9rem; /* 稍微减小菜单文字大小 */
}

.nav-link:hover {
    color: var(--primary-color) !important;
    background: rgba(var(--primary-color-rgb), 0.1);
    opacity: 1;
}

body.dark-mode .nav-link:hover {
    background: rgba(var(--primary-color-rgb), 0.15);
}

.search-trigger {
    padding: 4px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    transition: all 0.2s ease;
    color: var(--text-color) !important;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

.search-trigger:hover {
    background: rgba(var(--primary-color-rgb), 0.1);
    color: var(--primary-color) !important;
}

.navbar-search-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.navbar-search-wrapper .search-input-container {
    height: 52px;
    display: flex;
    align-items: center;
    padding: 0 20px; /* 保持与导航条一致的内边距 */
    width: 100%;
}

.navbar-search-wrapper input {
    font-weight: 500;
    color: var(--text-color);
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
}

.navbar-search-wrapper input::placeholder {
    color: var(--text-muted);
}

.navbar-search-wrapper.d-flex {
    animation: navSearchFadeIn 0.3s ease;
}

@keyframes navSearchFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 搜索激活状态的导航栏 - 保持宽度和圆角不变 */
.navbar-pill.search-active {
    height: auto;
    min-height: 52px;
    width: auto;
    min-width: 600px;
    border-radius: 26px;
    background: var(--card-bg);
    align-items: flex-start;
    padding: 0;
    overflow: hidden; /* 关键：确保子元素的背景不会超出圆角 */
}

@media (max-width: 768px) {
    .navbar-pill.search-active {
        min-width: 90%;
        margin: 10px auto;
    }
}

.navbar-pill.search-active:has(.search-quick-links:not(.d-none)) {
    border-radius: 26px; /* 搜索时也保持全圆角 */
}

.search-quick-links {
    border-top: 1px solid var(--border-color);
    width: 100%;
    background: var(--card-bg);
    border-radius: 0 0 26px 26px; /* 底部圆角 26px */
    margin-top: 0;
    padding: 10px 20px 20px 20px;
    position: relative; /* 确保 z-index 正常 */
}

.search-quick-links .list-group-item {
    background: transparent;
    border: none;
    transition: all 0.2s ease;
    font-weight: 500;
    color: var(--text-muted);
}

.search-quick-links .list-group-item:hover {
    background: var(--html-bg);
    color: var(--primary-color);
    transform: translateX(5px);
}

/* 按钮样式微调 */
.navbar-pill .btn-primary {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-color);
    font-weight: 500;
    transition: all 0.2s ease;
}

.navbar-pill .btn-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--card-bg);
}

.navbar-pill .btn-outline-primary {
    color: var(--text-color);
    border-color: var(--border-color);
    font-weight: 600;
    background: transparent;
}

.navbar-pill .btn-outline-primary:hover {
    background: var(--html-bg);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Mega Menu 二级菜单增强 */
.nav-item.dropdown:hover .dropdown-menu {
    display: block;
    margin-top: 0;
    animation: megaMenuFadeIn 0.3s ease;
}

.mega-menu {
    min-width: 400px;
    border-radius: 15px !important;
    padding: 10px;
    margin-top: 5px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
}

.dropdown-item {
    color: var(--text-color) !important;
}

.dropdown-item:hover {
    background: rgba(var(--primary-color-rgb), 0.08) !important;
    color: var(--primary-color) !important;
}

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

@media (max-width: 1200px) {
    .navbar-pill {
        width: 100% !important;
        height: 50px; /* 与 index.css 保持一致 */
        min-width: auto;
        padding: 0 12px;
    }

    .navbar-brand span {
        font-size: 1rem; /* 移动端缩小文字 */
    }

    .navbar-collapse {
        position: absolute;
        top: 55px; /* 稍微靠上一点 */
        left: 0;
        right: 0;
        background: var(--glass-bg);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid var(--glass-border);
        border-radius: 20px;
        padding: 10px !important;
        max-height: 80vh;
        overflow-y: auto;
        z-index: 1060;
    }

    .navbar-nav {
        align-items: flex-start !important;
        width: 100%;
        padding: 0;
    }

    .nav-item {
        width: 100%;
        margin: 0 !important;
        border-bottom: 1px solid rgba(var(--primary-color-rgb), 0.05);
    }
    
    .nav-item:last-child {
        border-bottom: none;
    }

    .nav-link {
        padding: 10px 15px !important;
        border-radius: 12px;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.95rem;
    }

    .nav-link:hover, .nav-link:active {
        background: rgba(var(--primary-color-rgb), 0.1);
    }

    .mega-menu {
        position: static !important;
        transform: none !important;
        box-shadow: none !important;
        border: none !important;
        padding: 5px 0 10px 20px !important;
        margin: 0 !important;
        background: transparent !important;
    }

    .dropdown-item {
        padding: 8px 15px !important;
        font-size: 0.85rem;
    }
}

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 45px;
    height: 45px;
    background: var(--card-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-base);
    z-index: 1000;
    border: 1px solid var(--border-color);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-5px);
    background: var(--primary-color);
    color: var(--card-bg) !important;
}

.navbar-content-wrapper {
    position: static;
    height: 100%;
    display: flex;
    align-items: center;
    width: 100%;
}

.navbar-collapse {
    position: static;
    height: 100%;
}

.navbar-nav {
    position: static;
    height: 100%;
    display: flex;
    align-items: center;
}

.nav-item {
    height: 100%;
    display: flex;
    align-items: center;
}

.nav-item.dropdown {
    position: static;
}

/* Mega Menu 样式 - 优化衔接 */
.dropdown-menu-mega {
    position: absolute;
    top: 0; /* 留一点点极小的缝隙或者紧贴，配合圆角 */
    left: 0;
    right: 0;
    width: 100%;
    background: var(--glass-bg); /* 白色半透明 */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 26px; /* 既然导航是圆角，二级菜单也用全圆角包裹感更好 */
    display: flex;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1050;
    border: 1px solid var(--glass-border);
    padding: 2rem;
    padding-top: calc(52px + 2rem);
    min-height: 380px;
    transform: translateY(10px);
    pointer-events: none;
}

.nav-item.dropdown:hover .dropdown-menu-mega {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.dropdown-mega-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-left: 8.5rem;
    padding-right: 3rem;
    background: transparent;
}

.dropdown-mega-left a {
    font-size: 1.15rem; /* 减小字体大小，更符合参考图 */
    font-weight: 600;
    color: var(--text-color);
    text-decoration: none;
    margin-bottom: 0.8rem;
    display: block;
    transition: all 0.2s ease;
}

.dropdown-mega-left a:hover {
    color: var(--primary-color);
}

.dropdown-mega-left .meta-links {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.dropdown-mega-left .meta-links a {
    font-size: 0.85rem; /* 进一步减小辅助链接字体 */
    color: var(--text-muted);
    margin-bottom: 0;
    font-weight: 500;
}

.dropdown-mega-right {
    width: 30%; /* 增加右侧图片区域比例 */
    max-width: 500px;
    background: transparent;
    padding: 0;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
}

.mega-image-card {
    width: 100%;
    height: 100%;
    max-height: 300px;
    border-radius: 2rem;
    overflow: hidden;
}

.mega-image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item.dropdown:hover .mega-image-card img {
    transform: scale(1.05);
}

.mega-social-links {
    position: absolute;
    bottom: 3rem;
    left: 3rem;
    display: flex;
    gap: 1.2rem;
}

/* 统一社交图标颜色，因为背景变白了 */
.mega-social-links a {
    font-size: 1.25rem;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.mega-social-links a:hover {
    color: var(--primary-color);
    transform: translateY(-3px);
}

.dropdown-mega-right .mega-image-card {
    width: 100%;
    height: 100%;
    border-radius: 0.8rem;
    overflow: hidden;
    background: var(--card-bg);
}

.dropdown-mega-right .mega-image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.nav-item.dropdown:hover .mega-image-card img {
    transform: scale(1.05);
}

/* 底部图标 */
.mega-social-links {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    display: flex;
    gap: 1rem;
}

.mega-social-links a {
    color: var(--primary-color);
    font-size: 1.25rem;
    transition: transform 0.2s ease;
}

.mega-social-links a:hover {
    transform: scale(1.1);
}

/* 导航栏下拉箭头旋转 */
.nav-link i.fa-chevron-down {
    transition: transform 0.3s ease;
}

.nav-item.dropdown:hover .nav-link i.fa-chevron-down {
    transform: rotate(180deg);
}

/* 胶囊按钮统一样式 */
.navbar-pill .btn-outline-primary {
    border: 1px solid var(--border-color);
    color: var(--text-color);
    background: var(--card-bg);
    font-weight: 500;
    padding: 0.4rem 1.25rem;
    transition: all 0.2s ease;
}

.navbar-pill .btn-outline-primary:hover,
.navbar-pill .btn-outline-primary:focus,
.navbar-pill .btn-outline-primary.show {
    background: var(--html-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.navbar-pill .dropdown-toggle::after,
.no-after::after {
    display: none !important;
}

/* 移动端适配 */
@media (max-width: 991.98px) {
    .dropdown-menu-mega {
        position: static;
        width: 100%;
        transform: none;
        box-shadow: none;
        border: none;
        display: none;
        flex-direction: column;
        background: transparent;
        opacity: 1;
        visibility: visible;
        padding: 0.5rem 1rem;
    }
    
    .nav-item.dropdown.show .dropdown-menu-mega {
        display: flex;
    }
    
    .dropdown-mega-left {
        display: none;
    }
    
    .dropdown-mega-right {
        grid-template-columns: 1fr;
        padding: 0;
        background: transparent;
    }
    
    .dropdown-mega-item {
        background: var(--html-bg);
        margin-bottom: 0.5rem;
    }
}

/* 全屏移动端菜单样式 */
.mobile-full-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s ease;
}

.mobile-full-menu.show {
    visibility: visible;
    pointer-events: auto;
}

.mobile-full-menu .menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-full-menu.show .menu-overlay {
    opacity: 1;
}

.mobile-full-menu .menu-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-full-menu.show .menu-content {
    transform: translateX(0);
}

.mobile-full-menu .menu-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.mobile-full-menu .menu-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
}

.mobile-full-menu .menu-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--html-bg);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-full-menu .menu-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.mobile-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-nav-item {
    margin-bottom: 10px;
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: var(--html-bg);
    border-radius: 15px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.mobile-nav-link:active {
    background: rgba(var(--primary-color-rgb), 0.1);
    transform: scale(0.98);
}

.mobile-sub-list {
    list-style: none;
    padding: 10px 0 10px 45px;
    margin: 0;
}

.mobile-sub-list li {
    margin-bottom: 12px;
}

.mobile-sub-list a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1rem;
    display: flex;
    align-items: center;
}

.mobile-full-menu .menu-footer {
    padding: 25px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--html-bg);
}

.mode-toggle-mobile {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background: var(--card-bg);
    border-radius: 12px;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

/* 导航栏响应式布局修正 */
@media (max-width: 1200px) {
    .navbar-pill {
        width: 95% !important;
        margin: 10px auto !important;
        display: flex !important;
        justify-content: center !important;
        position: relative !important;
    }

    .nav-left {
        position: absolute;
        left: 15px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 10;
    }

    .nav-center {
        margin: 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .nav-right {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 10;
    }

    .navbar-toggler-custom {
        padding: 4px 12px;
        border-radius: 20px;
        border: none;
        background: transparent;
        color: var(--text-color);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.85rem;
        font-weight: 600;
        cursor: pointer;
    }
}

@media (max-width: 576px) {
    .logo-text {
        display: none; /* 极小屏幕隐藏文字只留图标 */
    }
}

/* 移动端/平板端图标胶囊按钮 */
.icon-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-color);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.icon-pill:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.icon-pill i {
    font-size: 0.9rem;
}

/* 关闭按钮样式统一 */
.sidebar-close, .menu-close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-muted);
    background: var(--html-bg);
    border: 1px solid var(--border-color);
}

.sidebar-close:hover, .menu-close-btn:hover {
    background: #ff4757;
    color: white;
    border-color: #ff4757;
    transform: rotate(90deg);
}
