/*
 * HD Desktop Cart V1.3 — header desktop (>= 1200px):  [ ô tìm kiếm | nút ]   [ icon + badge  Giỏ hàng ]
 *
 * Markup (header.php V1.1, nhánh logo trái), bên trong .cg-logo-inner-cart-wrap (position: relative, cao 80px):
 *   .cg-wp-menu-wrapper > .cg-header-search.oni-fix-search  (theme: float right, rộng 300px, input 40px ở top 20px)
 *                       > .hd-desktop-customer-tools > .hd-desktop-cart > span.hd-desktop-cart-label + ul.tiny-cart
 *
 * Cách bố trí: cart nằm trong CỘT RIÊNG ở mép phải (right: 0, top 20px, cao 40px = đúng hàng với ô tìm kiếm);
 * ô tìm kiếm giữ float của theme nhưng chừa margin-right = bề rộng cột cart + khoảng cách ⇒ không thể chồng nhau.
 * Không đụng logo, tagline (.cg-announcements), menu bên dưới, header sticky, mobile/tablet.
 * Woo: giữ nguyên markup/fragments của cg_woocommerce_cart_dropdown(); chỉ CSS.
 */

@media (min-width: 1200px) {

    .cg-menu-below {
        --hd-cart-col: 120px;  /* bề rộng cột cart */
        --hd-cart-gap: 20px;   /* khoảng cách ô tìm kiếm ↔ cart */
        --hd-cart-ink: #14213d;
        --hd-cart-accent: #0b6283;
        --hd-cart-badge: #e31e24;
    }

    /* Ô tìm kiếm: giữ nguyên kích thước/float của theme, chỉ chừa cột cho cart. */
    .cg-menu-below .cg-header-search.oni-fix-search {
        margin-right: calc(var(--hd-cart-col) + var(--hd-cart-gap));
    }

    /* Cột cart: neo vào .cg-logo-inner-cart-wrap, cùng hàng với input tìm kiếm (top 20px, cao 40px). */
    .cg-menu-below .hd-desktop-customer-tools {
        position: absolute;
        top: 20px;
        right: 0;
        z-index: 1002;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        width: var(--hd-cart-col);
        height: 40px;
    }

    .hd-desktop-cart {
        position: relative;           /* khối chứa cho vùng click + mini-cart */
        display: flex;
        align-items: center;
        height: 40px;
        margin: 0;
        padding: 0;
        border: 0;
        color: var(--hd-cart-ink);
    }

    .hd-desktop-cart-label {
        order: 2;
        margin: 0 0 0 12px;
        color: inherit;
        font-family: Roboto, Arial, sans-serif;
        font-size: 14px;
        font-weight: 500;
        line-height: 1;
        letter-spacing: 0;
        white-space: nowrap;
    }

    /* Woo native trong wrapper HD: bỏ float/chiều cao của theme. */
    .hd-desktop-cart ul.tiny-cart {
        order: 1;
        position: static;             /* mini-cart neo theo .hd-desktop-cart */
        float: none;
        height: 40px;
        margin: 0;
        padding: 0;
        line-height: 1;
    }

    .hd-desktop-cart ul.tiny-cart > li {
        position: static;
        float: none;
        height: 40px;
        margin: 0;
        padding: 0;
    }

    .hd-desktop-cart .cart-parent {
        display: flex;
        align-items: center;
        height: 40px;
        padding: 0;
        color: inherit;
        text-decoration: none;
    }

    /* Cả icon lẫn chữ "Giỏ hàng" là một vùng click (chữ nằm ngoài thẻ <a> trong markup). */
    .hd-desktop-cart .cart-parent::after {
        content: "";
        position: absolute;
        inset: 0;
        z-index: 1;
    }

    .hd-desktop-cart .cg-header-cart-icon-wrap {
        position: relative;
        display: block;
        width: 28px;
        height: 28px;
        margin: 0;
    }

    .hd-desktop-cart .cg-header-cart-icon-wrap .icon {
        position: static;
        display: block;
        width: 28px;
        height: 28px;
        margin: 0;
        color: inherit;
        font-size: 26px;
        line-height: 28px;
        text-align: center;
    }

    .hd-desktop-cart .cg-cart-count {
        position: absolute;
        top: -7px;
        right: -9px;
        left: auto;
        display: block;
        box-sizing: border-box;
        min-width: 18px;
        height: 18px;
        margin: 0;
        padding: 0 5px;
        border-radius: 9px;
        background: var(--hd-cart-badge);
        box-shadow: 0 0 0 2px #fff;
        color: #fff !important;
        font-family: Roboto, Arial, sans-serif;
        font-size: 11px;
        font-weight: 700;
        line-height: 18px;
        text-align: center;
    }

    .hd-desktop-cart .cart_subtotal {
        display: none !important;     /* không hiện thành tiền trên header */
    }

    .hd-desktop-cart:hover {
        color: var(--hd-cart-accent);
    }

    .hd-desktop-cart .cart-parent:focus-visible {
        outline: 2px solid var(--hd-cart-accent);
        outline-offset: 4px;
        border-radius: 4px;
    }

    /* Mini-cart: neo mép phải của cart, không vượt viewport, nằm trên vùng click. */
    .hd-desktop-cart ul.tiny-cart li ul.cart_list {
        top: calc(100% + 10px) !important;  /* theme đặt top: 48px !important */
        right: 0;
        left: auto;
        z-index: 1005;
        width: 360px;
        max-width: calc(100vw - 32px);
        margin: 0;
        border-radius: 6px;
        box-shadow: 0 14px 38px rgba(20, 33, 61, .16);
    }

    /* Cầu nối 10px để rê chuột từ cart xuống mini-cart không bị đóng. */
    .hd-desktop-cart ul.tiny-cart li ul.cart_list::before {
        content: "";
        position: absolute;
        top: -12px;
        right: 0;
        left: 0;
        height: 12px;
    }

    .hd-desktop-cart ul.cart_list .container {
        width: 100%;
        max-width: 100%;
    }

    /* Nút giỏ nổi của WPC Fly Cart (#woofc-count, góc dưới trái): desktop đã có cart trên header. */
    #woofc-count {
        display: none !important;
    }
}

/* Tablet/mobile: không có cart desktop mới; giữ nguyên cart mobile, header sticky và nút giỏ nổi. */
@media (max-width: 1199px) {
    .hd-desktop-customer-tools {
        display: none !important;
    }
}
