/* TubeSnap 移动端抽屉式导航样式 */
/* 基于 CastLoom 设计，适配 TubeSnap 的橙色主题 */

/* 导航栏基础样式 */
.navbar {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 24px;
    font-weight: bold;
}

.nav-brand .logo-icon {
    width: 32px;
    height: 32px;
    display: block;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 30px;
}

.nav-links a {
    color: var(--text-gray);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: color 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

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

.nav-links a i {
    margin-right: 4px;
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: var(--primary-orange);
    border-radius: 2px;
}

/* 手机端菜单按钮 */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-dark);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s;
}

.mobile-menu-btn:hover {
    background: var(--bg-light);
    color: var(--primary-orange);
}

/* 手机端抽屉菜单 */
.mobile-drawer {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    background: var(--bg-white);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: left 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
}

.mobile-drawer.open {
    left: 0;
}

/* 抽屉菜单滚动条样式 */
.mobile-drawer::-webkit-scrollbar {
    width: 6px;
}

.mobile-drawer::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 3px;
}

.mobile-drawer::-webkit-scrollbar-thumb {
    background: var(--text-gray);
    border-radius: 3px;
    opacity: 0.6;
}

.mobile-drawer::-webkit-scrollbar-thumb:hover {
    background: var(--primary-orange);
    opacity: 1;
}

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

.mobile-drawer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 20px;
    font-weight: bold;
}

.mobile-drawer-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-gray);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.3s;
}

.mobile-drawer-close:hover {
    background: var(--bg-light);
    color: var(--text-dark);
}

.mobile-drawer-nav {
    padding: 20px 0;
}

.mobile-drawer-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    color: var(--text-gray);
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s;
    border-left: 4px solid transparent;
}

.mobile-drawer-nav a:hover {
    background: var(--bg-light);
    color: var(--text-dark);
    border-left-color: var(--primary-orange);
}

.mobile-drawer-nav a.active {
    background: rgba(255, 106, 0, 0.1);
    color: var(--primary-orange);
    border-left-color: var(--primary-orange);
}

.mobile-drawer-nav a i {
    width: 20px;
    text-align: center;
    font-size: 18px;
}

.mobile-drawer-lang {
    padding: 20px 20px 180px 20px; /* 大幅增加底部空间，相当于4个语言选项的高度 */
    border-top: 1px solid var(--border-color);
}

.mobile-drawer-lang-title {
    font-size: 14px;
    color: var(--text-gray);
    margin-bottom: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-lang-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px; /* 减少间距让内容更紧凑 */
    max-height: none; /* 确保没有高度限制 */
}

.mobile-lang-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 8px; /* 减少padding让内容更紧凑 */
    background: var(--bg-light);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 13px; /* 稍微减小字体 */
    transition: all 0.3s;
    min-height: 40px; /* 确保最小高度一致 */
}

.mobile-lang-option:hover {
    background: var(--border-color);
}

.mobile-lang-option.active {
    background: var(--primary-orange);
    color: white;
}

.mobile-lang-option .lang-flag {
    font-size: 16px;
}

/* 遮罩层 */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.mobile-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* 语言切换器 */
.lang-switcher {
    margin-left: 20px;
    padding-left: 20px;
    border-left: 1px solid var(--border-color);
    position: relative;
}

.lang-dropdown {
    position: relative;
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-gray);
    font-size: 14px;
    font-weight: 500;
}

.lang-toggle:hover {
    border-color: var(--primary-orange);
    color: var(--primary-orange);
    background: rgba(255, 106, 0, 0.05);
}

.lang-toggle i {
    font-size: 10px;
    transition: transform 0.3s;
}

.lang-dropdown.active .lang-toggle i {
    transform: rotate(180deg);
}

.lang-flag {
    font-size: 18px;
    line-height: 1;
}

.lang-name {
    min-width: 50px;
}

.lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    max-height: 400px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s;
    z-index: 10000;
    overflow-y: auto;
    overflow-x: hidden;
}

.lang-menu::-webkit-scrollbar {
    width: 6px;
}

.lang-menu::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 3px;
}

.lang-menu::-webkit-scrollbar-thumb {
    background: var(--text-gray);
    border-radius: 3px;
}

.lang-menu::-webkit-scrollbar-thumb:hover {
    background: var(--primary-orange);
}

.lang-dropdown.active .lang-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-dark);
    text-decoration: none;
    transition: all 0.2s;
    border-bottom: 1px solid var(--bg-light);
}

.lang-option:last-child {
    border-bottom: none;
}

.lang-option:hover {
    background: var(--bg-light);
    color: var(--primary-orange);
}

.lang-option.active {
    background: rgba(255, 106, 0, 0.1);
    color: var(--primary-orange);
    font-weight: 600;
}

.lang-option .lang-flag {
    font-size: 20px;
}

.lang-option .lang-name {
    flex: 1;
}

.lang-option i {
    color: var(--primary-orange);
    font-size: 12px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .lang-switcher {
        display: none;
    }
}

/* 小屏幕优化 */
@media (max-width: 480px) {
    .mobile-drawer {
        width: 260px; /* 稍微减小宽度给更多空间 */
    }
    
    .mobile-lang-option {
        font-size: 12px; /* 更小的字体 */
        padding: 8px 6px; /* 更紧凑的padding */
        min-height: 36px;
    }
    
    .mobile-lang-option .lang-flag {
        font-size: 14px; /* 稍小的旗帜图标 */
    }
    
    .mobile-drawer-lang {
        padding: 15px 15px 200px 15px; /* 小屏幕增加更多底部空间，确保所有语言都可访问 */
    }
}

/* RTL (从右到左) 语言支持 - 阿拉伯语、波斯语、乌尔都语 */
[dir="rtl"] .nav-container {
    flex-direction: row-reverse;
}

[dir="rtl"] .nav-links {
    flex-direction: row-reverse;
}

[dir="rtl"] .lang-switcher {
    margin-left: 0;
    margin-right: 20px;
    padding-left: 0;
    padding-right: 20px;
    border-left: none;
    border-right: 1px solid var(--border-color);
}

[dir="rtl"] .lang-menu {
    left: auto;
    right: 0;
    direction: ltr; /* 语言下拉菜单保持 LTR 布局 */
    text-align: left;
}

[dir="rtl"] .lang-option {
    direction: ltr; /* 语言选项保持 LTR 布局 */
    text-align: left;
}

[dir="rtl"] .lang-toggle {
    direction: ltr; /* 语言切换按钮保持 LTR 布局 */
}

/* RTL 抽屉菜单支持 */
[dir="rtl"] .mobile-drawer {
    left: auto;
    right: -100%;
}

[dir="rtl"] .mobile-drawer.open {
    right: 0;
    left: auto;
}

[dir="rtl"] .mobile-drawer-nav a {
    border-left: none;
    border-right: 4px solid transparent;
}

[dir="rtl"] .mobile-drawer-nav a:hover,
[dir="rtl"] .mobile-drawer-nav a.active {
    border-right-color: var(--primary-orange);
    border-left: none;
}

[dir="rtl"] .mobile-drawer-header {
    flex-direction: row-reverse;
}

/* RTL滚动条位置调整 */
[dir="rtl"] .mobile-drawer::-webkit-scrollbar {
    left: 0;
    right: auto;
}
