/* 
 * 导航栏与页脚专用样式文件
 * 包含所有导航栏和页脚相关样式
 * 结构优化版本 - 按功能模块组织
 */

/* ============================================================================
 * 1. 导航栏基础结构
 * ============================================================================
 */

/* 导航栏容器 - 固定定位 */
.navbar {
    padding: 2px 0;
    margin: 0;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100%;
    z-index: 10001;
    background-color: #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 确保导航栏字体继承全局字体定义 */
.navbar,
.navbar * {
    font-family: inherit;
}

/* 导航栏顶部区域（Logo + 搜索 + 邮箱） */
.navbar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 2px;
    border-bottom: 3px solid #9ca3af;
    margin-bottom: 0px;
}

/* 导航栏主区域（导航链接） */
.navbar-main {
    display: flex;
    justify-content: space-between;
    padding: 1px 0 2px 0;
    margin-top: 4px;
}



/* ============================================================================
 * 2. Logo 组件
 * ============================================================================
 */

.logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    text-decoration: none;
}

/* 导航栏字体大小clamp控制 */
nav.navbar .logo-text,
.navbar .logo-text {
    font-size: clamp(16px, 0.647vw + 13.574px, 26px) !important;
    background: linear-gradient(135deg, #2563eb, #dc2626) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    font-weight: bold !important;
    text-decoration: none !important;
}

/* Logo图片缩放 */
nav.navbar .logo-image,
.navbar .logo-image {
    width: clamp(40px, 1.942vw + 32.718px, 70px) !important;
    height: auto !important;
    max-width: none !important;
}

/* ============================================================================
 * 3. 顶部右侧功能区（搜索 + 邮箱 + 登录）
 * ============================================================================
 */

.top-bar-right {
    display: flex !important;
    align-items: center !important;
    gap: 16px !important;
    flex: 0 0 auto !important;
    justify-content: flex-end !important;
}

/* 搜索表单 */
.search-form {
    display: flex;
    align-items: center;
    background: #f3f4f6;
    border-radius: 9999px;
    padding: 0 6px;
    width: clamp(100px, 12.945vw + 51.456px, 300px);
    height: clamp(22px, 0.388vw + 20.545px, 28px);
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
}

.search-input {
    border: none;
    background: transparent;
    outline: none;
    flex: 1 1 auto;
    color: #374151;
    min-width: 0;
    height: 100%;
    padding: 0;
    margin: 0;
    font-size: clamp(10px, 0.3vw + 9.4px, 14px);
}

.search-input::placeholder {
    color: #9ca3af;
    font-size: clamp(8px, 0.518vw + 6.058px, 16px);
}

.search-btn {
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    margin-left: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    flex-shrink: 0;
    font-size: clamp(10px, 0.3vw + 9.4px, 14px);
}

/* 邮箱链接 */
.email-link {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #374151;
    text-decoration: none;
    transition: color 150ms;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
    font-size: clamp(8px, 0.518vw + 6.058px, 16px);
}

.email-link i {
    font-size: clamp(8px, 0.518vw + 6.058px, 16px);
}

.email-link:hover {
    color: #2563eb;
}

/* 导航文本链接（用于登录/注册等） */
.nav-text-link {
    color: #374151;
    text-decoration: none;
    font-weight: 500;
    transition: color 150ms;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
    font-size: clamp(8px, 0.518vw + 6.058px, 16px);
}

.nav-text-link:hover {
    color: #2563eb;
}

/* ============================================================================
 * 4. 导航链接区域
 * ============================================================================
 */

.navbar-main .nav-links {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
}

.navbar-main .nav-links a {
    flex: 0 0 auto;
    text-align: center;
    white-space: nowrap;
    padding: 4px 3px;
    font-size: clamp(10px, 0.647vw + 7.574px, 20px);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    color: #1f2937;
    text-decoration: none; /* 设置第二层元素名字字体无下划线 */
}

.navbar-main .nav-links a:hover {
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    color: #2563eb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-decoration: none; /* 确保hover时也无下划线 */
}

.navbar-main .nav-links a.active {
    color: #374151;
    font-weight: 500;
}

/* ============================================================================
 * 5. 下拉菜单组件
 * ============================================================================
 */

.dropdown {
    position: relative;
    flex: 0 0 auto;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    min-width: 112px;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transition: all 150ms;
    z-index: 10002;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
}

.dropdown.show .dropdown-menu {
    opacity: 1;
    visibility: visible;
}

/* 当下拉菜单为空时，即使悬停或点击也不显示 - 最高优先级规则 */
.dropdown.dropdown-empty .dropdown-menu,
.dropdown.dropdown-empty:hover .dropdown-menu,
.dropdown.dropdown-empty.show .dropdown-menu,
.dropdown.dropdown-empty[class] .dropdown-menu,
.debug-navbar .dropdown.dropdown-empty .dropdown-menu,
.debug-navbar .dropdown.dropdown-empty:hover .dropdown-menu,
.debug-navbar .dropdown.dropdown-empty.show .dropdown-menu,
body.debug-navbar .dropdown.dropdown-empty .dropdown-menu,
body.debug-navbar .dropdown.dropdown-empty:hover .dropdown-menu,
body.debug-navbar .dropdown.dropdown-empty.show .dropdown-menu {
    opacity: 0 !important;
    visibility: hidden !important;
    display: none !important;
    pointer-events: none !important;
    z-index: -1 !important;
    transform: none !important;
    transition: none !important;
    box-shadow: none !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

/* 当下拉菜单为空时，隐藏整个dropdown元素（包括"更多"按钮） */
.dropdown.dropdown-empty {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

/* 窄屏状态下恢复显示dropdown */
.dropdown:not(.dropdown-empty) {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: #374151;
    text-decoration: none;
    flex: 1;
    font-size: clamp(10px, 0.3vw + 9.4px, 14px);
}

.dropdown-menu a:hover {
    background: #f3f4f6;
    color: #2563eb;
}

/* ============================================================================
 * 6. 导航栏布局优化（强制覆盖样式）
 * ============================================================================
 */

/* 导航栏顶部区域布局优化 */
nav.navbar .navbar-top,
.navbar .navbar-top {
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    min-width: 100% !important;
}

nav.navbar .navbar-top .top-bar-right,
.navbar .navbar-top .top-bar-right {
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    min-width: clamp(180px, calc(10vw + 120px), 320px) !important;
}

nav.navbar .navbar-top .logo,
.navbar .navbar-top .logo {
    flex: 0 0 auto !important;
    flex-shrink: 1 !important;
    min-width: 0 !important;
    max-width: none !important;
    overflow: visible !important;
    text-decoration: none !important;
}

nav.navbar .navbar-top .logo:hover,
.navbar .navbar-top .logo:hover {
    text-decoration: none !important;
}

/* ============================================================================
 * 7. 响应式调整
 * ============================================================================
 */

/* 屏幕宽度小于400px时隐藏网站名字 */
@media (max-width: 400px) {
    nav.navbar .logo-text,
    .navbar .logo-text {
        display: none !important;
    }
}

/* ============================================================================
 * 8. 页脚样式
 * ============================================================================
 */

.footer {
    background: transparent;
    margin-top: -3px;
    padding-top: 0;
}

/* 页脚第一层：文字链接 */
.footer-links-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    padding: 5px 0;
    width: 100%;
}

.footer-links-row > * {
    flex: 1;
    text-align: center;
    white-space: nowrap;
}

.footer-links-row .footer-divider {
    flex: 0 0 auto;
    width: 1px;
    color: #9ca3af;
    user-select: none;
}

.footer-links-row a {
    color: #374151;
    text-decoration: none;
    font-size: clamp(8px, 0.518vw + 6.058px, 16px) !important;
    font-weight: 500;
    transition: color 150ms;
}

.footer-links-row a:hover {
    color: #2563eb;
}

/* 分隔线 */
.footer-divider-line {
    height: 1px;
    background-color: #e5e7eb;
    width: 100%;
}

/* 页脚第二层：图标链接 */
.footer-icons-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    padding: 5px 0;
    width: 100%;
    gap: 12px;
}

.footer-icons-row > * {
    flex: 1;
    text-align: center;
    white-space: nowrap;
    aspect-ratio: 2.5 / 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
}

.footer-icons-row a {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
    text-decoration: none;
    transition: all 150ms;
    width: 100%;
    height: 100%;
}

.footer-icons-row a:hover {
    color: #2563eb;
    transform: translateY(-2px);
}

.footer-site-icon {
    width: 100%;
    height: 100%;
    object-fit: fill;
    border-radius: 0;
    background: none;
    box-shadow: none;
    padding: 0;
}

.footer-icons-row span {
    font-size: 0.75rem;
    white-space: nowrap;
}

/* 页脚底部信息 */
.footer-bottom {
    text-align: center;
    padding: 20px 0;
    color: #6b7280;
    font-size: 0.875rem;
    border-top: 1px solid #e5e7eb;
    margin-top: 5px;
}

/* ============================================================================
 * 9. 全局调整
 * ============================================================================
 */

/* 固定导航栏后为页面内容留出空间 */
/* 在1920px屏幕宽度时105px，375px屏幕宽度时55px，中间线性变化 */
/* 线性公式: padding-top = 3.23625vw + 42.8641px */

/* 首先设置html元素以确保滚动条基础 */
html {
    /* 强制html始终有滚动条，并且滚动条始终占用空间 */
    overflow-y: scroll !important;
    /* 同时使用多种方法确保滚动条空间被保留 */
    scrollbar-gutter: stable;
    padding-right: var(--scrollbar-width) !important;
}

/* 然后设置body，继承html的滚动条设置 */
body {
    padding-top: clamp(55px, calc(3.23625vw + 42.8641px), 105px);
    /* body不需要额外的padding-right，因为html已经设置了 */
}

/* 防止SPA页面切换期间任何可能导致滚动条消失的样式 */
html.spa-page-transition,
body.spa-page-transition {
    /* 双重保障：在切换期间绝对强制滚动条显示 */
    overflow-y: scroll !important;
    overflow-x: hidden !important;
    /* 确保有最小高度，强制显示滚动条 */
    min-height: 101vh !important;
    /* 使用固定padding，不依赖动态计算 */
    padding-right: var(--scrollbar-width) !important;
}

/* 在SPA页面切换期间，防止任何元素修改滚动条行为 */
.spa-page-transition * {
    /* 防止内部元素通过overflow:hidden等样式影响滚动条 */
    overflow: visible !important;
}

/* ============================================================================
 * 10. 导航栏调试模式
 * ============================================================================
 * 启用方式：在<body>标签上添加class="debug-navbar"
 * 或在任意元素上添加class="debug-navbar"
 */

.debug-navbar .navbar,
body.debug-navbar .navbar {
    /* 高亮显示导航栏边界 */
    outline: 3px solid #ff0000 !important;
    outline-offset: -3px;
    background-color: rgba(255, 0, 0, 0.05) !important;
    position: relative;
}

.debug-navbar .navbar::before {
    content: '🚨 导航栏调试模式';
    position: absolute;
    top: 0;
    left: 0;
    background: #ff0000;
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 0 0 4px 0;
    z-index: 10002;
    pointer-events: none;
}

.debug-navbar .navbar-top {
    /* 高亮显示顶部区域边界 */
    outline: 2px dashed #ff9900 !important;
    outline-offset: -2px;
    background-color: rgba(255, 153, 0, 0.05) !important;
    position: relative;
}

.debug-navbar .navbar-top::before {
    content: '🔧 navbar-top';
    position: absolute;
    top: 0;
    right: 0;
    background: #ff9900;
    color: white;
    font-size: 9px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 0 0 0 4px;
    pointer-events: none;
}

.debug-navbar .navbar-main {
    /* 高亮显示主区域边界 */
    outline: 2px dashed #00aa00 !important;
    outline-offset: -2px;
    background-color: rgba(0, 170, 0, 0.05) !important;
    position: relative;
}

.debug-navbar .navbar-main::before {
    content: '🧭 navbar-main';
    position: absolute;
    bottom: 0;
    right: 0;
    background: #00aa00;
    color: white;
    font-size: 9px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 4px 0 0 0;
    pointer-events: none;
}

.debug-navbar .dropdown {
    /* 高亮显示下拉菜单容器 */
    outline: 2px dotted #0088ff !important;
    outline-offset: -2px;
    background-color: rgba(0, 136, 255, 0.05) !important;
    position: relative;
}

.debug-navbar .dropdown::before {
    content: '📋 dropdown';
    position: absolute;
    top: -10px;
    right: 0;
    background: #0088ff;
    color: white;
    font-size: 8px;
    font-weight: bold;
    padding: 1px 3px;
    border-radius: 4px 4px 0 0;
    pointer-events: none;
    white-space: nowrap;
}

.debug-navbar .dropdown-menu {
    /* 强制显示下拉菜单进行调试 */
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    outline: 3px solid #9900ff !important;
    outline-offset: -3px;
    background-color: rgba(153, 0, 255, 0.1) !important;
    position: relative;
}

.debug-navbar .dropdown-menu::before {
    content: '📋 dropdown-menu';
    position: absolute;
    top: -12px;
    right: 0;
    background: #9900ff;
    color: white;
    font-size: 8px;
    font-weight: bold;
    padding: 1px 3px;
    border-radius: 4px 4px 0 0;
    pointer-events: none;
    white-space: nowrap;
}

.debug-navbar .nav-links a {
    /* 高亮显示导航链接 */
    outline: 1px solid #ff66cc !important;
    outline-offset: -1px;
    background-color: rgba(255, 102, 204, 0.05) !important;
    position: relative;
}

.debug-navbar .nav-links a:hover {
    /* 悬停时更明显的效果 */
    outline-width: 2px !important;
    outline-color: #ff0066 !important;
    background-color: rgba(255, 0, 102, 0.1) !important;
}

/* 调试信息显示 */
.debug-navbar .nav-links a::after {
    content: attr(href);
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 8px;
    padding: 1px 3px;
    border-radius: 2px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 10002;
}

.debug-navbar .nav-links a:hover::after {
    opacity: 1;
}

/* 调试模式下显示尺寸信息 */
.debug-navbar .navbar::after {
    content: '尺寸: ' attr(data-width) 'px';
    position: absolute;
    bottom: 0;
    left: 0;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    font-size: 9px;
    font-family: monospace;
    padding: 2px 4px;
    pointer-events: none;
    z-index: 10002;
}

/* 动态更新尺寸信息（需要JavaScript配合） */
.debug-navbar .navbar[data-width]::after {
    content: '尺寸: ' attr(data-width) 'px';
}