/**
 * Topbar — bản đơn giản.
 * Nạp SAU style.css (xem detube_topbar_styles trong functions.php) nên ghi đè
 * bằng độ ưu tiên `body .topbar …` thay vì thêm !important mới.
 */

body .topbar {
    background: #0d0f14 !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07) !important;
    box-shadow: none !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    min-height: 56px !important;
    transition: none !important;
}

body .topbar::before {
    display: none;
}

body .topbar.scrolled,
body .topbar:hover {
    background: #0d0f14 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

body .topbar .brand .site-logo {
    height: 34px !important;
}

/* ── Desktop menu ─────────────────────────────────────────── */
@media (min-width: 1025px) {
    /* Căn mép logo/ô tìm kiếm thẳng với khung nội dung (container 1320px, đệm 20px) */
    body .topbar {
        gap: 28px !important;
        padding-left: max(20px, calc((100vw - 1320px) / 2 + 20px)) !important;
        padding-right: max(20px, calc((100vw - 1320px) / 2 + 20px)) !important;
    }

    body .topbar .nav {
        gap: 2px;
    }

    /* style.css tô nền hồng + bo tròn cho mục hiện tại — bỏ, vạch chân đã đủ báo trạng thái */
    body .topbar .nav > li > a,
    body .topbar .nav > li.current-menu-item > a,
    body .topbar .nav > li.current_page_item > a {
        background: none;
        border-radius: 0;
    }

    body .topbar .nav > li > a {
        padding: 18px 14px;
        font-size: 14.5px;
        font-weight: 500;
        color: rgba(255, 255, 255, 0.68);
        transition: color 0.15s ease;
    }

    /* Icon chỉ dùng cho menu mobile; desktop để chữ sạch */
    body .topbar .nav .menu-icon {
        display: none;
    }

    body .topbar .nav > li > a:hover,
    body .topbar .nav > li > a:focus-visible,
    body .topbar .nav > li.current-menu-item > a,
    body .topbar .nav > li.current_page_item > a,
    body .topbar .nav > li.current-menu-ancestor > a {
        color: #fff;
    }

    /* Gạch chân accent: cùng một vạch cho hover và trang hiện tại */
    body .topbar .nav > li > a::before {
        content: "";
        position: absolute;
        left: 14px;
        right: 14px;
        bottom: 0;
        width: auto;
        height: 2px;
        border-radius: 2px 2px 0 0;
        background: var(--accent, #ff4757);
        transform: scaleX(0);
        transition: transform 0.18s ease;
    }

    body .topbar .nav > li > a:hover::before,
    body .topbar .nav > li > a:focus-visible::before,
    body .topbar .nav > li.current-menu-item > a::before,
    body .topbar .nav > li.current_page_item > a::before,
    body .topbar .nav > li.current-menu-ancestor > a::before {
        transform: scaleX(1);
    }

    body .topbar .nav > li > a:focus-visible {
        outline: 2px solid var(--accent, #ff4757);
        outline-offset: -2px;
        border-radius: 6px;
    }
}

/* Màn 1025–1279px: thu gọn khoảng cách để menu + ô tìm kiếm vẫn vừa một hàng */
@media (min-width: 1025px) and (max-width: 1279px) {
    body .topbar {
        gap: 16px !important;
    }

    body .topbar .nav > li > a {
        padding-left: 9px;
        padding-right: 9px;
        font-size: 14px;
    }

    body .topbar .nav > li > a::before {
        left: 9px;
        right: 9px;
    }
}

/* Màn 1025–1119px: sát hơn nữa để ô tìm kiếm còn ≥120px và không bị cắt mép phải */
@media (min-width: 1025px) and (max-width: 1119px) {
    body .topbar {
        gap: 12px !important;
    }

    body .topbar .nav > li > a {
        padding-left: 6px;
        padding-right: 6px;
        font-size: 13.5px;
    }

    body .topbar .nav > li > a::before {
        left: 6px;
        right: 6px;
    }
}

/* ── Ô tìm kiếm desktop ───────────────────────────────────── */
.topbar-search {
    display: none;
}

@media (min-width: 1025px) {
    body .topbar .topbar-search {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-left: auto;
        flex: 0 1 240px;
        min-width: 120px;
        height: 38px;
        padding: 0 14px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.07);
        color: rgba(255, 255, 255, 0.5);
        transition: background 0.15s ease, flex-basis 0.2s ease;
    }

    body .topbar .topbar-search:hover,
    body .topbar .topbar-search:focus-within {
        background: rgba(255, 255, 255, 0.11);
    }

    body .topbar .topbar-search:focus-within {
        flex-basis: 300px;
        color: #fff;
    }

    body .topbar .topbar-search i {
        font-size: 0.8rem;
    }

    body .topbar .topbar-search input {
        flex: 1;
        min-width: 0;
        height: 100%;
        padding: 0;
        border: 0 !important;
        outline: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
        color: #fff;
        font: inherit;
        font-size: 0.875rem;
        -webkit-appearance: none;
        appearance: none;
    }

    body .topbar .topbar-search input::placeholder {
        color: rgba(255, 255, 255, 0.45);
    }

    body .topbar .topbar-search input::-webkit-search-cancel-button {
        -webkit-appearance: none;
    }
}

/* ── Nút icon (hamburger / tìm kiếm) trên mobile ──────────── */
body .topbar .icon-btn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow: none;
    transform: none;
    animation: none !important;
    transition: background 0.15s ease;
}

body .topbar .icon-btn:hover,
body .topbar .icon-btn:active {
    background: rgba(255, 255, 255, 0.08);
    border: 0;
    box-shadow: none;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    body .topbar .nav > li > a::before,
    body .topbar .topbar-search {
        transition: none;
    }
}
