/* ── Category filter header & tabs layout ── */
.kai-category-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}
.kai-sim-type-tabs {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
    padding: 8px;
    border-radius: 40px;
    border: 1px solid #e2e8f0;
}
.kai-tab-btn {
    /* Reset WordPress / Flatsome theme button defaults */
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    text-shadow: none !important;
    text-transform: none !important;
    min-height: 0 !important;
    height: auto !important;
    line-height: 1.2 !important;
    letter-spacing: normal !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;

    /* Custom styles */
    color: #475569;
    font-size: 13px;
    font-weight: 700;
    padding: 10px 22px !important;
    border-radius: 30px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    outline: none;
}
.kai-tab-btn:hover {
    color: #0f172a;
}
.kai-tab-btn.active {
    background: #19c4f9 !important;
    color: #fff !important;
    border-radius: 30px !important;
    box-shadow: 0 4px 10px rgba(25,196,249,0.2) !important;
}

@media (max-width: 600px) {
    .kai-category-filter-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .kai-sim-type-tabs {
        width: 100%;
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
        scrollbar-width: none; /* Hide scrollbar for clean design */
    }
    .kai-sim-type-tabs::-webkit-scrollbar {
        display: none;
    }
    .kai-tab-btn {
        flex: 1 0 auto;
        text-align: center;
    }
    #kai-filter-wrap {
        margin-bottom: 0;
    }
    .kai-filter-toggle {
        width: 100%;
        justify-content: center;
    }
}

/* ── Toggle button ── */
#kai-filter-wrap {
    margin-bottom: 0; /* managed by header margin */
}
.kai-filter-toggle {
    /* Reset WordPress / Flatsome button defaults */
    margin: 0 !important;
    border: 1.5px solid #19c4f9 !important;
    background: #fff !important;
    box-shadow: 0 2px 8px rgba(25,196,249,0.12) !important;
    text-shadow: none !important;
    text-transform: uppercase !important;
    min-height: 0 !important;
    height: auto !important;
    line-height: 1.2 !important;
    letter-spacing: normal !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    vertical-align: middle !important;

    /* Custom styles */
    gap: 8px;
    padding: 10px 22px !important; /* matches tab button spacing */
    border-radius: 30px !important;
    color: #19c4f9 !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    outline: none;
}
.kai-filter-toggle:hover,
.kai-filter-toggle[aria-expanded="true"] {
    background: #19c4f9 !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(25,196,249,0.25) !important;
    transform: translateY(-1px);
}
.kai-filter-toggle:active {
    transform: translateY(0);
}
.kai-filter-toggle svg { flex-shrink: 0; }
.kai-filter-badge {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: #ff4757;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    margin-left: 4px;
}

/* ── Overlay ── */
.kai-filter-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45); /* modern dark slate overlay */
    z-index: 9998;
    backdrop-filter: blur(4px);
    animation: kaiFadeIn 0.25s ease-out;
}
.kai-filter-overlay.open { display: block; }

/* ── Drawer ── */
.kai-filter-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: 90vw;
    background: #fff;
    border-radius: 20px 0 0 20px;
    box-shadow: -10px 0 40px rgba(15,23,42,0.15);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex !important;         /* luôn flex để layout không bị phá vỡ */
    flex-direction: column !important;
    height: 100vh;
    overflow: hidden;                 /* ngăn nội dung drawer tràn ra ngoài */
}
.kai-filter-drawer.open {
    transform: translateX(0);
}
.kai-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;                   /* header không co lại */
}
.kai-drawer-title {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.3px;
}
.kai-drawer-close {
    background: #f1f5f9;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #64748b;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    line-height: 1;
    padding: 0;
}
.kai-drawer-close:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: rotate(90deg);
}
.kai-drawer-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;                          /* body chiếm toàn bộ space còn lại */
    min-height: 0;                    /* quan trọng: cho phép flex item scroll đúng */
}

/* ── Filter groups inside drawer ── */
#kai-variation-filters .kai-filter-group {
    margin-bottom: 28px;
}
#kai-variation-filters .kai-filter-group:last-child { margin-bottom: 0; }
#kai-variation-filters .kai-filter-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 13px;
    color: #475569;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}
.kai-filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.kai-filter-btn {
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.kai-filter-btn:hover {
    border-color: #19c4f9;
    background: #f0fdfa;
    color: #19c4f9;
}
.kai-filter-btn.active {
    background: #19c4f9;
    border-color: #19c4f9;
    color: #fff;
    box-shadow: 0 4px 10px rgba(25,196,249,0.2);
}

/* ── Footer buttons — luôn hiển thị dù drawer mở lần nào ── */
.kai-drawer-footer {
    display: flex !important;         /* !important chặn theme override */
    flex-shrink: 0 !important;        /* footer không co lại hay bị đẩy ra ngoài */
    gap: 12px;
    padding: 16px 24px 24px;
    border-top: 1px solid #f1f5f9;
    background: #fff;
    /* Đảm bảo footer không bị clip bởi overflow của parent elements */
    position: relative;
    z-index: 1;
}
.kai-btn-reset,
.kai-btn-apply {
    /* Reset mọi theme/Flatsome override có thể ẩn button */
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}
.kai-btn-reset {
    flex: 1;
    padding: 14px 8px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-align: center;
}
.kai-btn-reset:hover {
    border-color: #94a3b8;
    background: #f8fafc;
    color: #0f172a;
}
.kai-btn-apply {
    flex: 1;
    padding: 14px 16px;
    border-radius: 12px;
    border: none;
    background: #19c4f9;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(25,196,249,0.3);
    text-align: center;
    white-space: nowrap;
}
.kai-btn-apply:hover {
    background: #00aee0;
    box-shadow: 0 6px 20px rgba(25,196,249,0.4);
    transform: translateY(-1px);
}
.kai-btn-apply:active {
    transform: translateY(0);
}

/* ── Hide products ── */
.type-product[data-kai-hidden="1"],
.product-col.kai-col-hidden,
.col.kai-col-hidden {
    display: none !important;
}

@keyframes kaiFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Custom JS Pagination ── */
.kai-custom-pagination {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 40px 0 20px !important;
    width: 100% !important;
    clear: both !important;
}
.kai-page-num {
    /* Reset WordPress / Flatsome button defaults */
    margin: 0 !important;
    border: 1px solid #e2e8f0 !important;
    background: #fff !important;
    box-shadow: none !important;
    text-shadow: none !important;
    text-transform: none !important;
    min-height: 0 !important;
    letter-spacing: normal !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    vertical-align: middle !important;
    user-select: none;

    /* Enforce circular geometry and equal sizing */
    width: 38px !important;
    height: 38px !important;
    padding: 0 !important;
    border-radius: 50% !important;

    /* Custom styles */
    color: #475569 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}
.kai-page-num:hover {
    border-color: #19c4f9 !important;
    color: #19c4f9 !important;
    background: #f0fdfa !important;
}
.kai-page-num.active {
    background: #19c4f9 !important;
    border-color: #19c4f9 !important;
    color: #fff !important;
    box-shadow: 0 4px 10px rgba(25,196,249,0.3) !important;
}
.kai-page-num.prev,
.kai-page-num.next {
    font-size: 22px !important;
    line-height: 1 !important;
}

/* ── Clear floated elements inside variations form to prevent card height collapse ── */
.product-small form.variations_form::after,
.product-small form.variations_form table.variations::after,
.product-small form.variations_form tr::after {
    content: "" !important;
    display: table !important;
    clear: both !important;
}

/* Hide WooCommerce native single product add-to-cart button inside loops */
.product-small form.variations_form .woocommerce-variation-add-to-cart,
.product-small form.variations_form .single_add_to_cart_button {
    display: none !important;
}

/* Increase card frame height at bottom to wrap the absolutely positioned BUY button */
.product-small .background-product-box {
    padding-bottom: 25px !important;
}

/* ── Fallback styles for cards missing ACF colors or text color ── */
.background-product-box {
    background: linear-gradient(150deg, #253B80 0, #19C4F9); /* default blue gradient */
    color: #fff;
    min-height: 420px !important;
    display: inline-flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.background-product-box:not(.dark-text) h3,
.background-product-box:not(.dark-text) a,
.background-product-box:not(.dark-text) span,
.background-product-box:not(.dark-text) label,
.background-product-box:not(.dark-text) .woocommerce-loop-product__title {
    color: #fff !important;
}

.background-product-box select {
    color: #1f1f30 !important;
}

/* Override Flatsome equal height JS script calculations */
.products .product-col,
.products .col {
    height: 450px !important;
    margin-bottom: 30px !important;
}

.products .product-col .col-inner,
.products .col .col-inner {
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

.products .product-small.box {
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
}

/* ── Force Stacking Order inside Shop Flex Container ── */
.shop-container {
    display: flex !important;
    flex-direction: column !important;
}
.kai-category-filter-header {
    order: 1 !important; /* Filters at the top */
}
.woocommerce-notices-wrapper {
    order: 2 !important; /* WooCommerce notices */
}
.products.row {
    order: 3 !important; /* Product grid in the middle */
}
.kai-custom-pagination {
    order: 4 !important; /* Custom pagination below products grid */
}
.term-description {
    order: 5 !important; /* Category SEO description text at the very bottom */
}







