/* Hide original OpenCart refine section */
#product-category #content > h3,
#product-category #content > h3 + .row {
    display: none !important;
}

.figs-refine-wrap {
    position: relative;
    z-index: 20;
    margin: 16px 0 22px;
}

.figs-refine-title {
    font-size: 24px;
    font-weight: 800;
    color: #111;
    margin-bottom: 10px;
    letter-spacing: .3px;
}

/* Desktop */
.figs-refine-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.figs-refine-card {
    position: relative;
    z-index: 21;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 88px;
    padding: 8px 10px;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    background: #fff;
    text-decoration: none;
    color: #111;
    transition: all .18s ease;
}

/* Desktop: 5 across x 2 rows = 10 */
.figs-refine-card:nth-child(n+11) {
    display: none;
}

.figs-refine-wrap.show-more .figs-refine-card {
    display: flex;
}

.figs-refine-card:hover {
    border-color: #d7d7d7;
    box-shadow: 0 4px 14px rgba(0,0,0,.05);
    transform: translateY(-1px);
    text-decoration: none;
}

.figs-refine-image {
    width: 78px;
    min-width: 78px;
    margin-right: 4px;
    flex-shrink: 0;
    text-align: center;
}

.figs-refine-image img {
    width: auto;
    max-width: 78px;
    max-height: 58px;
    object-fit: contain;
}

.figs-refine-name {
    font-size: 12px;
    line-height: 1.05;
    font-weight: 800;
    color: #777;
    text-transform: uppercase;
    text-align: left;
}

.figs-more-toggle {
    position: relative;
    z-index: 21;
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    background: #fff;
    color: #111;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
    cursor: pointer;
}

.figs-more-icon {
    display: inline-block;
    margin-left: 6px;
    transition: transform .18s ease;
}

.figs-more-toggle.active .figs-more-icon {
    transform: rotate(180deg);
}

/* Tablet: 4 across x 2 rows = 8 */
@media (max-width: 991px) {
    .figs-refine-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .figs-refine-card:nth-child(n+9) {
        display: none;
    }

    .figs-refine-wrap.show-more .figs-refine-card {
        display: flex;
    }

    .figs-refine-image {
        width: 62px;
        min-width: 62px;
        margin-right: 4px;
    }

    .figs-refine-image img {
        max-width: 62px;
        max-height: 46px;
    }

    .figs-refine-name {
        font-size: 10px;
    }
}

/* Mobile */
@media (max-width: 600px) {

    .figs-refine-wrap {
        z-index: 30;
        margin: 14px 0 28px;
    }

    .figs-refine-wrap.show-more {
        margin-bottom: 36px;
    }

    .figs-refine-title {
        font-size: 20px;
        margin-bottom: 8px;
    }

    .figs-refine-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .figs-refine-card {
        z-index: 31;
        min-height: 60px;
        padding: 5px 8px;
        border-radius: 8px;
        align-items: center;
    }

    .figs-refine-card:nth-child(n+5) {
        display: none;
    }

    .figs-refine-wrap.show-more .figs-refine-card {
        display: flex;
    }

    .figs-refine-image {
        width: 48px;
        min-width: 48px;
        margin-right: 6px;
        text-align: center;
    }

    .figs-refine-image img {
        max-width: 64px;
        max-height: 42px;
        object-fit: contain;
    }

    .figs-refine-name {
        font-size: 12px;
        line-height: 1.05;
        text-align: left;
        white-space: normal;
        overflow-wrap: break-word;
        flex: 1;
    }

    .figs-more-toggle {
        z-index: 31;
        margin-top: 6px;
        padding: 8px;
        font-size: 10px;
        border-radius: 8px;
    }
}
/* ----------------------------------------
   Hide "More Subcategories" when everything
   is already visible for the current breakpoint
----------------------------------------- */

/* Desktop: 5 columns × 2 rows = 10 visible */
@media (min-width: 992px) {
    .figs-count-5 .figs-more-toggle,
    .figs-count-6 .figs-more-toggle,
    .figs-count-7 .figs-more-toggle,
    .figs-count-8 .figs-more-toggle,
    .figs-count-9 .figs-more-toggle,
    .figs-count-10 .figs-more-toggle {
        display: none;
    }
}

/* Tablet: 4 columns × 2 rows = 8 visible */
@media (min-width: 601px) and (max-width: 991px) {
    .figs-count-5 .figs-more-toggle,
    .figs-count-6 .figs-more-toggle,
    .figs-count-7 .figs-more-toggle,
    .figs-count-8 .figs-more-toggle {
        display: none;
    }
}

/* Mobile: 2 columns × 2 rows = 4 visible */
/* No CSS needed. The Twig already hides the button for 4 or fewer categories. */