/* 桌面侧边栏收起样式（仅图标） */
#desktopSidebar.sidebar-collapsed {
  width: 64px;
}
#desktopSidebar.sidebar-collapsed .sidebar-text {
  display: none;
}
#desktopSidebar .sidebar-item { display: flex; align-items: center; gap: 10px; }
#desktopSidebar .sidebar-item .icon { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
#desktopSidebar.sidebar-collapsed .sidebar-item { justify-content: center; }
#desktopSidebar.sidebar-collapsed .sidebar-item .icon { margin: 0; }

/* 选中项样式：图标前竖直圆角条 + 浅背景 */
#desktopSidebar .sidebar-item.active {
  position: relative;
  background: rgba(102, 126, 234, 0.12);
  border-radius: 8px;
}
#desktopSidebar .sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  background: #667eea;
  border-radius: 4px;
}

.sidebar-toggle-btn {
  width: 32px; height: 32px; display: inline-flex; align-items:center; justify-content:center; border: none; background: transparent; cursor: pointer; margin: 8px;
}
/* 导航栏样式 */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.55); /* 玻璃效果半透明背景 */
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
    padding: 0.75rem 0; /* 减少垂直padding */
    z-index: 1000; /* 低于移动菜单 */
    transition: transform 0.2s ease, padding 0.2s ease, background 0.3s ease, backdrop-filter 0.3s ease, box-shadow 0.2s ease;
    height: auto; /* 自适应高度 */
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
}

.navbar.hidden {
    transform: translateY(-100%);
}

/* 页面滚动后，稍微增强背景与阴影，便于与内容区分 */
.navbar.scrolled {
    background: rgba(255, 255, 255, 0.7);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
    border-bottom-color: rgba(255, 255, 255, 0.4);
}

/* 暗色主题下的导航玻璃效果与文字颜色 */
html.theme-dark .navbar {
    background: rgba(17, 19, 24, 0.6);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom-color: rgba(255,255,255,0.06);
    box-shadow: 0 10px 28px rgba(0,0,0,0.5);
}
html.theme-dark .navbar.scrolled {
    background: rgba(17, 19, 24, 0.72);
    border-bottom-color: rgba(255,255,255,0.12);
}
html.theme-dark .logo span { color: #76a7ff; }
html.theme-dark .logo-subtitle { color: #b6c2d0; }
html.theme-dark .nav-links a { color: #e8e8e8; }
html.theme-dark .nav-links a:hover { background: rgba(118,167,255,0.12); color: #b8d1ff; }

/* 向下滚动时收缩 */


/* 移除不需要的菜单相关样式 */

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 100%;
    padding: 0 2rem;
    margin: 0;
    position: relative; /* 添加相对定位，作为汉堡按钮的参考 */
    overflow: visible; /* 确保导航栏内容完整显示 */
}

@media (max-width: 768px) {
    .nav-container {
        padding: 0 1rem;
        padding-right: 4.5rem; /* 增加右侧填充，为汉堡菜单留出更多空间 */
    }
    
    .navbar {
        padding: 0.6rem 0; /* 在移动设备上进一步减少padding */
    }
    
    .logo {
        max-width: calc(100% - 80px); /* 移动端上为汉堡菜单留出更多空间 */
    }
}

.logo {
    display: flex;
    flex-direction: row;
    align-items: center;
    color: #333;
    font-weight: bold;
    font-size: 1.2rem;
    position: relative;
    gap: 10px; /* Increased from 8px to add more space between icon and text */
    min-width: 0; /* 允许子元素缩小 */
    max-width: calc(100% - 200px); /* 为右侧导航留出更多空间 */
    overflow: visible; /* 确保内容完整显示 */
    cursor: pointer; /* 确保鼠标悬停时显示为可点击状态 */
}

.logo-icon {
    width: 50px; /* Increased from 40px */
    height: 50px; /* Increased from 40px */
    flex-shrink: 0; /* 防止图标被压缩 */
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 4px; /* Increased from 2px to add more vertical space between text elements */
    min-width: 0; /* 允许子元素缩小 */
    max-width: calc(100% - 60px); /* 确保留出空间给图标 */
}

.logo span {
    font-size: 1.2rem; /* Reduced from 1.3rem */
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #4285f4; /* Changed to blue color */
}

.logo-subtitle {
    position: static;
    font-size: 0.85rem; /* Reduced from 0.9rem */
    color: #666;
    font-weight: normal;
    white-space: normal;
    overflow: visible;
    max-width: 100%;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem; /* 进一步减小间距确保有足够空间 */
    position: relative;
    flex-shrink: 0; /* 防止被压缩 */
    min-width: 0; /* 允许内容自适应 */
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 0.75rem; /* 进一步减小间距 */
    overflow: visible; /* 确保可见 */
    flex-shrink: 0; /* 防止导航链接被压缩 */
}

.nav-links a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease, border 0.3s ease, background 0.3s ease;
    border-radius: 8px;
    border: 2px solid transparent;
    padding: 0.25rem 0.5rem; /* 减小内边距 */
    display: block; /* 确保完整显示 */
}

.nav-links a:hover {
    color: #4285f4;
    border: 2px solid transparent;
    background: rgba(66,133,244,0.15);
}

.login-btn {
    background: #4285f4;
    color: white;
    padding: 0.4rem 0.75rem; /* 减小内边距 */
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    flex-shrink: 0; /* 防止按钮被压缩 */
}

.login-btn:hover {
    background: #3b78e7; /* 稍暗一点的蓝色，与移动版一致 */
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* 汉堡菜单包装器 - 确保汉堡菜单按钮始终在顶层 */
.hamburger-wrapper {
    position: absolute; /* 改为绝对定位 */
    top: 50%; /* 垂直居中 */
    right: 1rem; /* 右侧1rem */
    width: 60px;
    height: 60px;
    z-index: 2000; /* 需低于用户Portal */
    display: none; /* 默认不显示 */
    justify-content: center;
    align-items: center;
    pointer-events: none; /* 默认不接收点击事件 */
    transition: opacity 0.3s ease, visibility 0.3s ease; /* 添加平滑过渡 */
    transform: translateY(-50%); /* 垂直居中调整 */
}

/* 菜单内的汉堡按钮包装器 */
.hamburger-wrapper-menu {
    position: fixed;
    top: 1rem;
    right: 1rem;
    transform: none;
    z-index: 2100; /* 确保在菜单之上 */
    display: none;
    background: transparent;
}

/* 在移动端视图下且菜单打开时显示菜单内的关闭按钮 */
@media (max-width: 768px) {
    .mobile-menu.active .hamburger-wrapper-menu {
        display: flex;
    }
    
    /* 当菜单打开时隐藏导航栏中的汉堡按钮 */
    .mobile-menu.active ~ .navbar .hamburger-wrapper {
        display: none;
    }
}

/* 只有在移动设备视图下才显示汉堡按钮包装器 */
@media (max-width: 768px) {
    .hamburger-wrapper {
        display: flex;
        right: 0.75rem; /* 调整位置，确保不会重叠 */
    }
}

/* 汉堡菜单按钮 */
.hamburger {
    display: none; /* 默认不显示 */
    flex-direction: column;
    cursor: pointer;
    gap: 5px;
    padding: 8px;
    transition: all 0.3s ease, display 0s; /* 添加过渡效果，但display无需过渡 */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    justify-content: center;
    align-items: center;
    background: transparent; /* 改为透明背景 */
    box-shadow: none; /* 移除阴影 */
    pointer-events: auto; /* 确保可以接收点击事件 */
}

/* 移动视图中显示汉堡按钮 */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }
    
    /* 移动端视图中调整登录按钮的样式 */
    .nav-right .login-btn {
        padding: 0.5rem 0.75rem; /* 减少水平内边距 */
        font-size: 13px; /* 略微减小字体大小 */
        margin-right: 60px; /* 增加右侧外边距，为汉堡菜单留出足够空间 */
    }
    
    /* 在非常小的屏幕上进一步调整 */
    @media (max-width: 360px) {
        .nav-right .login-btn {
            padding: 0.4rem 0.6rem; /* 进一步减少内边距 */
            font-size: 12px; /* 进一步减小字体 */
        }
        
        .logo-subtitle {
            font-size: 0.8rem; /* Smaller font on very small screens but still visible */
            max-width: 100%; /* Ensure full width available */
            white-space: normal; /* Allow wrapping */
        }
    }
}

.hamburger:hover {
    background: transparent; /* 移除悬停时的背景 */
    box-shadow: none; /* 移除悬停时的阴影 */
}

.hamburger.active {
    background: transparent; /* 移除激活状态的背景 */
    box-shadow: none; /* 移除激活状态的阴影 */
}

/* 具体针对菜单内的关闭按钮 */
.hamburger-menu:hover,
.hamburger-menu.active {
    background: transparent;
    box-shadow: none;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: #333;
    transition: all 0.3s cubic-bezier(.68,-0.55,.27,1.55);
    transform-origin: center;
}

.hamburger.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
    transform: scale(0);
}

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

/* 保持汉堡菜单按钮的文字颜色 */
.hamburger.active span {
    background: #333;
}

/* 移动菜单打开时的body样式 */
body.modal-open {
    overflow: hidden; /* 防止背景滚动 */
    position: fixed;
    width: 100%;
    height: 100%;
}

/* 移动菜单 */
.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    background: rgba(255, 255, 255, 0.98);
    z-index: 1900;
    visibility: hidden;
    opacity: 0;
    transform: translateY(8px) translateZ(0);
    will-change: transform, opacity;
    transition: transform 260ms cubic-bezier(.22,1,.36,1), opacity 220ms ease-out, visibility 0s linear 260ms;
    box-shadow: none;
    overflow: hidden;
    pointer-events: none;
}

.mobile-menu.active {
    visibility: visible;
    opacity: 1;
    transform: translateY(0) translateZ(0);
    transition-delay: 0s, 0s, 0s; /* 立即可见 */
    pointer-events: auto;
}

.mobile-menu.closing {
    visibility: visible;
    opacity: 0;
    transform: translateY(8px) translateZ(0);
    pointer-events: none;
}

/* 菜单项动画调整 */
.mobile-menu-items {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    opacity: 0;
    transform: translateY(10px) translateZ(0);
    will-change: transform, opacity;
    transition: transform 220ms cubic-bezier(.22,1,.36,1), opacity 200ms ease-out;
    width: 100%;
    max-width: 300px; /* 限制菜单宽度，避免在大屏幕上过宽 */
    margin-top: 40px; /* 增加更多顶部间距，避开汉堡按钮区域 */
}

/* 菜单项动画状态类 */
.mobile-menu.active .mobile-menu-items {
    opacity: 1;
    transform: translateY(0) translateZ(0);
}

.mobile-menu.closing .mobile-menu-items {
    opacity: 0;
    transform: translateY(10px) translateZ(0);
    transition-delay: 0s;
}

/* 子项分步进入，避免卡顿（最多延迟前三个） */
.mobile-menu-items > * { opacity: 0; transform: translateY(8px) translateZ(0); will-change: transform, opacity; transition: transform 220ms cubic-bezier(.22,1,.36,1), opacity 200ms ease-out; }
.mobile-menu.active .mobile-menu-items > * { opacity: 1; transform: translateY(0) translateZ(0); }
.mobile-menu.active .mobile-menu-items > *:nth-child(1) { transition-delay: 20ms; }
.mobile-menu.active .mobile-menu-items > *:nth-child(2) { transition-delay: 40ms; }
.mobile-menu.active .mobile-menu-items > *:nth-child(3) { transition-delay: 60ms; }
.mobile-menu.closing .mobile-menu-items > * { transition-delay: 0ms; }

/* 修改所有菜单项样式，使宽度一致 */
.mobile-menu-items a,
.mobile-menu-items button:not(.mobile-login) {
    color: #333;
    text-decoration: none;
    font-size: 1.3rem;
    transition: all 0.3s ease;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    width: 200px; /* 固定宽度 */
    display: flex; /* 改为flex，确保垂直水平居中不偏移 */
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    text-align: center;
}

/* 普通菜单项悬停效果 */
.mobile-menu-items a:hover,
.mobile-menu-items button:not(.mobile-login):hover {
    background: rgba(66, 133, 244, 0.1);
    transform: translateY(-2px);
    color: #4285f4;
}

/* 登录按钮包装元素 */
.mobile-login-wrapper {
    width: 200px;
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 登录按钮特殊样式 */
.mobile-login {
    font-size: 1.1rem !important;
    padding: 0.75rem 0 !important;
    background-color: #4285f4;
    color: white !important;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%; /* 使用100%宽度填充父容器 */
    text-align: center; /* 文本居中 */
    display: flex; /* 使用flex布局 */
    justify-content: center; /* 水平居中 */
    align-items: center; /* 垂直居中 */
    border-radius: 8px;
    line-height: 1.5;
    height: 48px; /* 固定高度 */
    position: relative; /* 添加相对定位 */
    z-index: 1; /* 确保在最上层 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* 添加阴影效果 */
}

/* 登录按钮悬停效果 - 更温和的颜色变化 */
.mobile-login:hover {
    background-color: #3b78e7; /* 稍暗一点的蓝色 */
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* 轻微阴影增强 */
}

/* 响应式设计 */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    
    /* 移动端隐藏顶部登录按钮，防止与汉堡按钮重叠。保留侧边菜单中的登录按钮 */
    .nav-right .login-btn {
        display: none !important;
    }
    
    .nav-container {
        padding: 0 1rem;
        position: relative; /* 确保相对定位，使汉堡菜单定位正确 */
    }

    .navbar {
        padding: 0.6rem 0; /* 在移动设备上进一步减少padding */
    }

    .nav-right {
        gap: 0.75rem;
        position: relative; /* 确保相对定位 */
        padding-right: 45px; /* 为汉堡菜单预留空间 */
    }
}

/* 动画关键帧 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* 新增从右到左滑动动画 */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0.5;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0.5;
    }
}
/* 移动菜单内容容器 */
.mobile-menu-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    padding: 2rem;
    padding-top: 80px; /* 为顶部汉堡菜单留出空间 */
    position: relative; /* 添加相对定位 */
    z-index: 1950; /* 比.mobile-menu高，但比hamburger-wrapper低 */
    overflow-y: auto; /* 允许内容滚动 */
    overflow-x: hidden; /* 防止水平滚动 */
}

/* 添加顶部安全区域，确保不会遮挡汉堡按钮 */
.mobile-menu-content::before {
    content: "";
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    width: 60px;
    height: 60px;
    pointer-events: none; /* 允许点击穿透到汉堡按钮 */
}

/* 移动端菜单内的搜索区域 */
.mobile-search-container {
    width: 100%;
    display: flex;
    justify-content: center;
}
.mm-search {
    width: 100%;
    padding: 0 1rem;
}
.mm-search-input-wrap {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    transform: translateY(0);
    transition: transform 420ms cubic-bezier(.22,1,.36,1), box-shadow 300ms ease;
    position: relative;
    z-index: 1962;
}
.mm-search-input-wrap.focused { transform: translateY(-10px); }
.mm-search-input-wrap.has-content { transform: translateY(-20px); }
.mm-search-input {
    width: 100%;
    height: 46px;
    padding: 0 14px 0 14px;
    font-size: 15px;
    color: #111827;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 12px; /* 圆角长方形 */
    outline: none;
    box-shadow: 0 10px 24px rgba(0,0,0,0.06);
}
html.theme-dark .mm-search-input {
    background: #171a20;
    color: #e8e8e8;
    border-color: rgba(255,255,255,0.08);
}
.mm-search-indicator { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; opacity: 0; transition: opacity .2s ease; }
.mm-search-indicator.searching { opacity: 1; }
.mm-search-indicator .spinner { width: 100%; height: 100%; border: 2px solid #e5e7eb; border-top: 2px solid #3b82f6; border-radius: 50%; animation: rtsp-spin 1s linear infinite; }

.mm-search-results {
    position: fixed; /* 脱离移动菜单，悬浮于页面之上 */
    left: 0; /* 由JS动态设置与输入框等宽且左对齐 */
    transform: none;
    top: 120px; /* 初始值，JS 会根据输入框定位更新 */
    width: calc(100vw - 2rem); /* 兜底宽度 */
    max-width: 760px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    box-shadow: 0 14px 40px rgba(0,0,0,0.12);
    padding: 8px;
    z-index: 1966; /* 高于遮罩(1955)与菜单(1900) */
    pointer-events: auto; /* 确保接收点击 */
}
html.theme-dark .mm-search-results { background: rgba(22,24,28,0.92); border-color: rgba(255,255,255,0.06); box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.mm-results-inner { max-height: 54vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px; -ms-overflow-style: none; scrollbar-width: none; pointer-events: auto; }
.mm-results-inner::-webkit-scrollbar { width: 0; height: 0; }
.mm-result-item { padding: 10px 12px; border-radius: 10px; color: #111827; display: block; text-decoration: none; transition: background .2s ease, transform .2s ease, border-color .2s ease, box-shadow .2s ease; border: 1px solid #e5e7eb; background: #fff; cursor: pointer; pointer-events: auto; }
.mm-result-item:hover { background: rgba(66,133,244,0.06); transform: translateY(-3px); border-color: #3b82f6; box-shadow: 0 10px 24px rgba(59,130,246,0.18); }
html.theme-dark .mm-result-item { color: #e8e8e8; }
html.theme-dark .mm-result-item:hover { background: rgba(96,165,250,0.12); border-color: #60a5fa; box-shadow: 0 10px 24px rgba(0,0,0,0.4); }

/* 进入/退出动画 */
@keyframes mm-card-enter {
    0% { opacity: 0; transform: translateY(12px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes mm-card-exit {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(10px) scale(0.98); }
}
.mm-enter { animation: mm-card-enter .36s ease both; }
.mm-exit { animation: mm-card-exit .22s ease both; }
.mobile-menu .rt-search-page {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    width: 100%;
    pointer-events: auto;
    z-index: 1960; /* 高于菜单内容 */
}
.mobile-menu .rtsp-inner {
    position: relative;
    inset: auto;
    width: 100%;
    padding: 0 1rem 0.5rem;
}
.mobile-menu .rtsp-input-wrap {
    width: 94vw;
    transform: translateY(0);
    margin: 0 auto;
}
.mobile-menu .rtsp-input-wrap.has-content { transform: translateY(0); }
.mobile-menu .rt-sp-search { height: 44px; border-radius: 22px; }
.mobile-menu .rtsp-results-card { width: calc(100% - 2rem); }

/* 搜索遮罩，点击收起 */
.mobile-search-mask {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1955;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
}
.mobile-search-mask.active {
    opacity: 1;
    visibility: visible;
}

/* 在移动菜单内时，结果大框进入时距离顶部更近 */
.mobile-menu .rt-search-page.has-query #searchApiList { margin-top: 20px; }
