/* Bộ lọc + sắp xếp trang danh mục kiểu Coolmate (inc/gemmi-filter.php). */

/* Bỏ ô sắp xếp / số kết quả cũ của theme */
body:has(.gm-filter) .shop-page-title .woocommerce-ordering,
body:has(.gm-filter) .shop-page-title .woocommerce-result-count,
body:has(.gm-filter) .category-filtering {
    display: none !important;
}
/* Tiêu đề danh mục kiểu Coolmate: breadcrumb nhỏ xám ở trên, tên danh mục chữ hoa to bên dưới, canh trái */
.category-page-title .page-title-inner > .flex-col:first-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left !important;
}
.category-page-title .page-title-inner > .flex-col:first-child > .is-large {
    order: -1;
}
.category-page-title .woocommerce-breadcrumb {
    margin: 0 0 10px;
    color: #111;
    font-size: 13px !important;
    font-weight: 400 !important;
    letter-spacing: 0;
    line-height: 1.4;
    text-transform: none !important;
}
.category-page-title .woocommerce-breadcrumb a {
    color: #888;
    font-size: inherit !important;
    font-weight: 400 !important;
}
.category-page-title .woocommerce-breadcrumb .divider {
    margin: 0 6px;
    color: #bbb;
    font-weight: 400;
}
.category-page-title h1.shop-page-title {
    margin: 0;
    font-size: 26px !important;
    font-weight: 800;
    letter-spacing: .3px;
    line-height: 1.25;
    text-transform: uppercase;
}
@media (max-width: 849px) {
    .category-page-title .page-title-inner {
        padding-top: 14px;
        padding-bottom: 4px;
    }
    .category-page-title h1.shop-page-title {
        font-size: 22px !important;
    }
}
html.gm-filter-loading .shop-container .products {
    opacity: .45;
    transition: opacity .2s;
}

/* ---------- Thanh: số kết quả · sắp xếp · bộ lọc ---------- */
.gm-filter__bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
}
.gm-filter__count {
    flex: 1;
    color: #666;
    font-size: 14px;
}
.gm-filter button {
    min-height: 0;
    margin: 0;
    letter-spacing: 0;
    text-transform: none;
    box-shadow: none;
}
.gm-sort {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}
.gm-sort__label {
    display: none;
    color: #888;
    font-size: 13px;
    text-transform: uppercase;
}
.gm-sort__btn,
.gm-filter__open,
.gm-filter__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: #fff;
    color: #111;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
}
.gm-filter__open b {
    color: #a50e43;
}
.gm-sort__btn svg {
    transition: transform .2s;
}
.gm-filter.is-sort-open .gm-sort__btn {
    background: #f2f2f2;
}
.gm-filter.is-sort-open .gm-sort__btn svg {
    transform: rotate(180deg);
}
.gm-sort__menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 30;
    min-width: 170px;
    margin: 0;
    padding: 6px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .14);
    list-style: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .18s, transform .18s, visibility 0s linear .18s;
}
.gm-filter.is-sort-open .gm-sort__menu {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity .18s, transform .18s;
}
.gm-sort__menu li {
    margin: 0;
}
.gm-sort__menu a {
    display: block;
    padding: 8px 14px;
    border-radius: 8px;
    color: #555;
    font-size: 14px;
    white-space: nowrap;
}
.gm-sort__menu a:hover,
.gm-sort__menu a.is-on {
    background: #f2f2f2;
    color: #111;
}
.gm-sort__menu a.is-on {
    font-weight: 600;
}
.gm-filter__toggle {
    display: none;
}

/* ---------- Dải size bấm nhanh ---------- */
.gm-filter__sizes {
    margin: 0 0 16px;
}
.gm-filter__sizes-label {
    display: none;
    margin-bottom: 10px;
    color: #666;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
}
.gm-filter__sizes-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}
.gm-filter__sizes-list::-webkit-scrollbar {
    display: none;
}
.gm-chip,
.gm-opt--chip .gm-opt__text {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: #ececec;
    color: #111;
    font-size: 15px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.gm-chip.is-on,
.gm-opt--chip input:checked + .gm-opt__text {
    background: #111;
    color: #fff;
}

/* ---------- Bảng lọc ---------- */
.gm-filter__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
}
.gm-filter__head strong {
    font-size: 17px;
    font-weight: 700;
    text-transform: uppercase;
}
.gm-filter__close,
.gm-filter__clear {
    padding: 4px;
    border: 0;
    background: transparent;
    color: #111;
}
.gm-filter__clear {
    color: #2f5acf;
    font-size: 14px;
    font-weight: 600;
}
.gm-fsec {
    border-bottom: 1px solid #eee;
}
.gm-fsec__title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 0;
    border: 0;
    background: transparent;
    color: #888;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
}
.gm-fsec__title svg {
    transition: transform .2s;
}
.gm-fsec.is-open .gm-fsec__title svg {
    transform: rotate(180deg);
}
.gm-fsec__body {
    display: none;
    padding: 0 0 16px;
}
.gm-fsec.is-open .gm-fsec__body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.gm-fsec__body--chip,
.gm-fsec__body--color {
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 8px !important;
}
.gm-opt {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: #333;
    font-size: 15px;
    font-weight: 400;
    cursor: pointer;
}
.gm-opt input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
/* Ô tròn như Coolmate */
.gm-opt__box {
    flex: none;
    width: 20px;
    height: 20px;
    border: 1.5px solid #333;
    border-radius: 50%;
    background: #fff;
    transition: box-shadow .15s, background .15s;
}
.gm-opt input:checked + .gm-opt__box {
    background: #111;
    box-shadow: inset 0 0 0 4px #fff;
}
.gm-opt--chip .gm-opt__text {
    min-width: 56px;
    font-size: 14px;
}
/* Màu: chấm tròn + tên */
.gm-opt--color {
    flex-direction: column;
    gap: 4px;
    width: 58px;
    font-size: 12px;
    text-align: center;
}
.gm-opt__dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--c);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
}
.gm-opt--color input:checked + .gm-opt__dot {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12), 0 0 0 2px #fff, 0 0 0 3.5px #111;
}
.gm-opt--color input:checked ~ .gm-opt__text {
    font-weight: 600;
}
.gm-filter__foot {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid #eee;
}
.gm-filter__apply {
    width: 100%;
    height: 48px;
    border: 0;
    border-radius: 24px;
    background: #111;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase !important;
}
.gm-filter__backdrop {
    display: none;
}

/* ---------- Điện thoại / máy tính bảng: bảng lọc toàn màn hình ---------- */
@media (max-width: 849px) {
    .gm-filter__panel {
        position: fixed;
        inset: 0;
        z-index: 100003;
        display: flex;
        flex-direction: column;
        background: #fff;
        transform: translate3d(100%, 0, 0);
        visibility: hidden;
        transition: transform .3s cubic-bezier(.22, .9, .24, 1), visibility 0s linear .3s;
    }
    html.gm-filter-open .gm-filter__panel {
        transform: none;
        visibility: visible;
        transition: transform .3s cubic-bezier(.22, .9, .24, 1);
    }
    html.gm-filter-open,
    html.gm-filter-open body {
        overflow: hidden;
    }
    .gm-filter__body {
        flex: 1;
        padding: 0 24px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .gm-filter__count {
        font-size: 13px;
    }
    .gm-sort__btn,
    .gm-filter__open {
        height: 38px;
        padding: 0 14px;
    }
}

/* ---------- Máy tính: cột lọc bên trái ---------- */
@media (min-width: 850px) {
    .shop-container:has(> .gm-filter) {
        display: grid;
        grid-template-columns: 250px minmax(0, 1fr);
        grid-template-areas:
            "sizes sizes"
            "bar bar"
            "panel products"
            "panel more";
        column-gap: 36px;
        align-items: start;
    }
    .shop-container:has(> .gm-filter) > * {
        grid-column: 1 / -1;
    }
    .shop-container > .gm-filter {
        display: contents;
    }
    .shop-container:has(> .gm-filter) > .products {
        grid-area: products;
    }
    .shop-container:has(> .gm-filter) > .container {
        grid-area: more;
    }
    .gm-filter__sizes {
        grid-area: sizes;
        margin-bottom: 24px;
    }
    .gm-filter__sizes-label {
        display: block;
    }
    .gm-filter__sizes-list {
        flex-wrap: wrap;
        overflow: visible;
    }
    .gm-chip {
        min-width: 80px;
        height: 40px;
        background: #d9d9d9;
    }
    .gm-chip:hover {
        background: #c9c9c9;
    }
    .gm-chip.is-on {
        background: #111;
    }
    .gm-filter__bar {
        grid-area: bar;
        display: grid;
        grid-template-columns: 250px 1fr;
        column-gap: 36px;
        row-gap: 12px;
        margin-bottom: 16px;
    }
    .gm-filter__toggle {
        display: inline-flex;
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
        height: 34px;
        padding: 0 14px;
        border-color: #111;
        font-size: 14px;
        font-weight: 600;
    }
    .gm-filter__count {
        grid-column: 1;
        grid-row: 2;
        padding-bottom: 12px;
        border-bottom: 1px solid #ddd;
        font-size: 15px;
    }
    .gm-sort {
        grid-column: 2;
        grid-row: 1 / span 2;
        justify-self: end;
        align-self: end;
        margin-bottom: 8px;
    }
    .gm-sort__label {
        display: inline;
    }
    .gm-sort__btn {
        border-color: transparent;
        background: #f2f2f2;
    }
    .gm-filter__open {
        display: none;
    }
    .gm-filter__panel {
        grid-area: panel;
        position: sticky;
        top: 160px;
        max-height: calc(100vh - 180px);
        overflow-y: auto;
        scrollbar-width: thin;
    }
    .gm-filter__head,
    .gm-filter__foot {
        display: none;
    }
    .gm-fsec:first-child .gm-fsec__title {
        padding-top: 4px;
    }
    /* Ẩn bộ lọc: sản phẩm tràn hết bề ngang */
    html.gm-filter-hidden .gm-filter__panel,
    html.gm-filter-hidden .gm-filter__count {
        display: none;
    }
    html.gm-filter-hidden .shop-container:has(> .gm-filter) {
        grid-template-areas:
            "sizes sizes"
            "bar bar"
            "products products"
            "more more";
    }
}
