/* 顶部导航结构基础样式 */
.header-navbar,
.header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.header-flex {
    gap: 10px;
}

.topnav-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    white-space: nowrap;
}

.topnav-logo img {
    display: block;
    flex: 0 0 auto;
}

.logo-title {
    margin-left: 0;
    white-space: nowrap;
    line-height: 1;
}

.nav-link {
    color: white;
    text-decoration: none;
    margin-left: 10px;
    font-size: 1.1rem;
}

.nav-link:hover {
    color: #ff0000;
}

.menu-icon {
    display: none;
    font-size: 30px;
    cursor: pointer;
    color: white;
    position: static;
    right: auto;
    line-height: 1;
    flex: 0 0 auto;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    flex: 1 1 auto;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    flex: 0 0 auto;
}

.header-logo-link {
    float: none;
    min-width: 0;
}

.header-theme-label {
    color: #fffff0;
    margin-right: 5px;
    white-space: nowrap;
}

.header-navbar .dropdown {
    position: relative;
}

.header-select-dropdown {
    display: inline-flex;
    flex-direction: column;
    align-items: stretch;
    width: auto;
    min-width: 0;
}

.header-select-btn {
    width: 100%;
    min-width: 0;
    white-space: nowrap;
    justify-content: space-between;
}

.header-select-menu {
    top: calc(100% + 4px);
    left: 0;
    right: auto;
    min-width: 100% !important;
    width: 100% !important;
    margin-top: 0;
    text-align: center;
    border-radius: 2px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    border: none;
    background-color: #fff;
    z-index: 1000;
}

.dropdown-menu[aria-labelledby="dropdownMenuButton"] {
    min-width: 100% !important;
    width: auto;
    text-align: center;
    border-radius: 2px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    border: none;
    background-color: #fff;
    z-index: 1000;
}

.dropdown-menu a.dropdown-item,
.header-navbar .dropdown-menu .dropdown-item {
    padding: 10px 12px;
    font-size: 14px;
    transition: background-color 0.2s, color 0.2s;
    background: none;
    border: 0;
    width: 100%;
    text-align: left;
    white-space: nowrap;
}

.dropdown-menu a.dropdown-item:hover,
.header-navbar .dropdown-menu .dropdown-item:hover {
    background-color: #f0f0f5;
    color: #007bff;
}

.header-navbar .dropdown-menu form {
    margin: 0;
}

.mobile-nav-btn {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
}

/* 分类 + 搜索 */
.search-bar-wrapper {
    background-color: transparent;
    margin-left: 2px;
    margin-right: 2px;
}

.search-bar-wrapper .container {
    background-color: #f8f9fa;
    border-radius: 5px;
    padding: 10px 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.search-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.category-box {
    flex-shrink: 0;
    max-width: 280px;
}

.category-box select {
    height: 38px;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 14px;
    border: 1px solid #ced4da;
    background-color: #fff;
}

.search-box {
    flex-grow: 1;
    max-width: 420px;
    position: relative;
}

.search-box input {
    width: 100%;
    height: 38px;
    border-radius: 6px;
    border: 1px solid #ced4da;
    padding: 6px 36px 6px 10px;
    font-size: 14px;
}

.search-box .uil-search {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    pointer-events: none;
}

.header-mobile-controls {
    width: auto;
    padding: 0 !important;
    gap: 4px;
    flex-wrap: nowrap;
    justify-content: flex-end !important;
}

.header-mobile-dropdown {
    flex: 0 0 auto;
    min-width: 0;
}

.header-mobile-template-btn {
    padding: 6px 10px !important;
    min-width: 0;
    width: auto;
    max-width: 100%;
    font-size: 13px;
    line-height: 1.2;
}

.header-mobile-dropdown-menu {
    min-width: 100% !important;
    width: 100% !important;
}

.header-mobile-menu-icon {
    font-size: 30px;
    margin-left: 4px !important;
}

/* 移动端 */
@media (max-width: 768px) {
    .menu-icon {
        display: block;
    }

    .header-flex {
        gap: 6px;
    }

    .header-left {
        flex: 1 1 auto;
        min-width: 0;
    }

    .header-right {
        flex: 0 0 auto;
        min-width: 0;
    }

    .topnav-logo {
        justify-content: flex-start;
        order: 1;
        gap: 6px;
    }

    .topnav-logo img {
        width: 34px;
        height: 34px;
        object-fit: contain;
    }

    .logo-title {
        line-height: 1;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-mobile-controls {
        display: inline-flex !important;
        align-items: center;
    }

    .header-mobile-template-btn,
    .header-mobile-template-btn.dropdown-toggle {
        padding: 6px 8px !important;
    }

    .header-mobile-template-btn::after,
    .header-select-btn::after {
        margin-left: 6px;
    }

    .mobile-nav {
        display: none;
        position: absolute;
        top: 60px;
        right: 0;
        background-color: #393D49;
        flex-direction: column;
        z-index: 1000;
        width: auto;
    }

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

    .mobile-nav a {
        color: white;
        padding: 10px;
        text-align: center;
        border-bottom: 1px solid #575757;
        text-decoration: none;
        white-space: nowrap;
    }

    .mobile-nav a:hover {
        background-color: #575757;
    }

    .search-bar-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .category-box,
    .search-box {
        width: 100%;
        max-width: none;
    }

    .category-box select {
        width: 100%;
    }

    .search-box {
        margin-top: 10px;
    }
}
