/* ============================================
 * Navbar - 顶部导航栏
 * 对应 layout/_navbar.php 的 HTML 结构
 * ============================================ */

/* ---- Navbar 主容器 ---- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #ffffff;
    border-bottom: 1px solid #e5e0d6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: background 0.2s, box-shadow 0.2s;
}

.navbar.scrolled {
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

[data-theme="dark"] .navbar,
.dark .navbar {
    background: #1a1a1f;
    border-bottom-color: #333;
}

/* ---- Flex 布局容器（100% 全宽） ---- */
.navbar-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    width: 100%;
    padding: 0 32px;
}

/* ---- Logo / 品牌 ---- */
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    text-decoration: none;
    color: #333;
    font-size: 18px;
    font-weight: 700;
}
.navbar-brand:hover { color: #913500; }

.navbar-logo {
    height: 32px;
    width: auto;
    object-fit: contain;
}

[data-theme="dark"] .navbar-brand,
.dark .navbar-brand {
    color: #eee;
}

/* ---- 导航菜单 ---- */
.navbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    margin-left: 32px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 15px;
    font-weight: 500;
    color: #555555;
    text-decoration: none;
    border-radius: 6px;
    transition: color 0.15s, background-color 0.15s;
    white-space: nowrap;
}

/* 导航菜单图标 */
.nav-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-link-icon svg {
    width: 18px;
    height: 18px;
    color: currentColor;
}

.nav-link:hover .nav-link-icon svg {
    color: #913500;
}

.nav-link.active .nav-link-icon svg {
    color: #913500;
}

.nav-link-text {
    /* 文字部分 */
}

.nav-link:hover {
    color: #913500;
    background-color: rgba(145,53,0,0.06);
}

.nav-link.active {
    color: #913500;
    background-color: rgba(145,53,0,0.08);
    font-weight: 600;
}

[data-theme="dark"] .nav-link,
.dark .nav-link {
    color: #bbb;
}
[data-theme="dark"] .nav-link:hover,
.dark .nav-link:hover {
    color: #c97a3a;
    background-color: rgba(201,122,58,0.1);
}
[data-theme="dark"] .nav-link.active,
.dark .nav-link.active {
    color: #c97a3a;
    background-color: rgba(201,122,58,0.12);
}

/* ---- 右侧工具栏 ---- */
.navbar-tools {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 16px;
}

.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #666;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.tool-btn:hover {
    background-color: rgba(0,0,0,0.06);
    color: #913500;
}

[data-theme="dark"] .tool-btn,
.dark .tool-btn {
    color: #aaa;
}
[data-theme="dark"] .tool-btn:hover,
.dark .tool-btn:hover {
    background-color: rgba(255,255,255,0.08);
    color: #c97a3a;
}

/* ---- 用户菜单 ---- */
.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border: none;
    border-radius: 20px;
    background: transparent;
    cursor: pointer;
    transition: background-color 0.15s;
}

.user-menu-trigger:hover {
    background-color: rgba(0,0,0,0.05);
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e5e0d6;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: #444;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 下拉面板 */
.user-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 320px;
    background: #fff;
    border: 1px solid #e5e0d6;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 8px;
    z-index: 1100;
}

.user-menu-dropdown.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    font-size: 14px;
    color: #444;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.12s;
}

.dropdown-item:hover {
    background-color: rgba(145,53,0,0.06);
    color: #913500;
}

.dropdown-divider {
    height: 1px;
    background: #e5e0d6;
    margin: 4px 6px;
}

/* ---- 下拉菜单用户信息头部 ---- */
.dropdown-user-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 10px;
    margin: -8px -8px 0 -8px;
    border-radius: 10px 10px 0 0;
    background: linear-gradient(135deg, #faf8f5 0%, #f0ebe5 100%);
}

.dropdown-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(145,53,0,0.15);
}

.dropdown-header-info {
    flex: 1;
    min-width: 0;
}

.dropdown-header-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-header-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

.header-stat {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: #888;
    background: rgba(145,53,0,0.06);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.header-stat svg {
    flex-shrink: 0;
    opacity: 0.75;
}

.header-stat-vip {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

.header-stat-vip svg {
    color: #d97706;
    opacity: 1;
}

/* 统计数字链接：去掉 a 标签默认样式 */
a.header-stat-link {
    text-decoration: none;
    color: inherit;
}
a.header-stat-link:hover .header-stat {
    background: rgba(145,53,0,0.12);
    color: #913500;
}

/* ---- 下拉菜单两列布局 ---- */
.dropdown-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.dropdown-column {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* 下拉菜单内联 SVG 图标样式 */
.dropdown-item svg {
    flex-shrink: 0;
    opacity: 0.7;
    color: #913500;
}

.dropdown-item:hover svg {
    opacity: 1;
}

.dropdown-item span {
    flex: 1;
}

/* ---- 搜索遮罩层（桌面端） ---- */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.45);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 120px;
    animation: fadeIn 0.15s ease;
}
.search-overlay.show { display: flex; }
.search-overlay-inner {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    width: 560px;
    max-width: 92vw;
    padding: 24px;
    animation: slideDown 0.2s ease;
}
.search-overlay-inner .search-form {
    display: flex;
    gap: 10px;
}
.search-overlay-inner .search-input {
    flex: 1;
    height: 44px;
    padding: 0 16px;
    border: 2px solid #e0dcd4;
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s;
}
.search-overlay-inner .search-input:focus {
    border-color: #913500;
    box-shadow: 0 0 0 3px rgba(145,53,0,0.1);
}
.search-overlay-inner .search-btn {
    width: 44px; height: 44px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #913500 0%, #c45537 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.search-overlay-inner .search-btn:hover {
    background: linear-gradient(135deg, #a84d00 0%, #d46442 100%);
}
.search-overlay-hint {
    font-size: 12px;
    color: #999;
    margin-top: 10px;
    text-align: center;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 移动端搜索栏 */
.mobile-search {
    display: none;
    background: #fff;
    border-bottom: 1px solid #e5e0d6;
    padding: 12px 20px;
}

.mobile-search.show {
    display: block;
}

.search-form {
    display: flex;
    gap: 8px;
    max-width: 100%;
}

.search-input {
    flex: 1;
    height: 40px;
    padding: 0 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s;
}

.search-input:focus {
    border-color: #913500;
    box-shadow: 0 0 0 3px rgba(145,53,0,0.1);
}

.search-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: #913500;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.search-btn:hover {
    background: #b45a1a;
}

/* ---- 移动端响应式：隐藏桌面菜单，显示汉堡按钮 ---- */
@media (max-width: 768px) {

    .navbar-container {
        padding: 0 16px;
        height: 56px;
    }

    /* 隐藏导航菜单 */
    .navbar-nav {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: #fff;
        flex-direction: column;
        margin-left: 0;
        padding: 8px 16px 16px;
        border-bottom: 1px solid #e5e0d6;
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
        gap: 2px;
    }

    .navbar-nav.show {
        display: flex;
    }

    .nav-link {
        padding: 12px 16px;
        font-size: 16px;
        border-radius: 8px;
    }

    /* 显示移动端按钮 */
    .mobile-menu-btn {
        display: flex !important;
    }

    /* 隐藏桌面端元素 */
    #themeToggle { display: none; }
    #searchToggle { display: none; }
    .user-name { display: none; }
    .user-menu-trigger { padding: 4px; border-radius: 50%; }

    /* 工具栏间距 */
    .navbar-tools { margin-left: 8px; gap: 2px; }

    /* 下拉菜单移动端单列 */
    .dropdown-grid { grid-template-columns: 1fr; }
    .user-menu-dropdown { min-width: 260px; left: auto; right: -10px; }
}

/* 桌面端隐藏移动菜单按钮 */
@media (min-width: 769px) {
    .mobile-menu-btn { display: none; }
    .mobile-search { display: none !important; }
}
