/* ==========================================================================
   PRODUCT LISTING PAGE STYLING
   Brand Colors:
   - Green: var(--color-3, #0e6938), #094826 (dark hover), #eaf5ee (light tint)
   - Yellow: #fcbb01
   - Red: var(--color-5, #e50308)
   ========================================================================== */

.products-listing {
    padding: 20px 0 30px;
    color: #333333;
}

section.products-listing {
    overflow: hidden;
    background: #f8faf9;
}

/* 1. Toolbar & Sort */
.products-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 14px;
    gap: 30px;
}

.products-toolbar__left {
    color: #1f2937;
    flex: 1;
    font-size: 15px;
}

.products-toolbar__left strong {
    color: var(--color-3, #0e6938);
    font-weight: 700;
}

.products-toolbar__right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.products-sort {
    display: flex;
    align-items: center;
    gap: 12px;
}

.products-sort__label {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
    white-space: nowrap;
}

.products-sort__group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.products-sort__item {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 18px;
    font-size: 13.5px;
    line-height: 1.3;
    color: #374151;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 50px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    user-select: none;
    overflow: hidden;
    outline: none;
}

.products-sort__item:hover {
    border-color: var(--color-3, #0e6938);
    background-color: #eaf5ee;
    color: var(--color-3, #0e6938);
}

.products-sort__item--active {
    background-color: var(--color-3, #0e6938);
    border-color: var(--color-3, #0e6938);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(14, 105, 56, 0.25);
}

.products-sort__item--active:hover {
    background-color: #094826;
    border-color: #094826;
    color: #ffffff;
}

.products-sort__badge {
    position: absolute;
    top: 0;
    left: 0;
    width: 16px;
    height: 15px;
    background-color: var(--color-3, #0e6938);
    border-bottom-right-radius: 10px;
    align-items: center;
    justify-content: end;
    color: #ffffff;
    padding-right: 3px;
    padding-bottom: 2px;
    display: none !important;
}

.products-sort__badge-icon {
    width: 8px;
    height: 8px;
    stroke: #ffffff;
}

.products-sort__item--active .products-sort__badge {
    display: flex;
}

.products-sort__text {
    position: relative;
    z-index: 1;
}

.mobile-filters-btn {
    display: none;
}

.products-sort__mobile {
    display: none;
}

.products-view-mode {
    display: flex;
    gap: 8px;
}

.view-mode-btn {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 4px 10px;
    cursor: pointer;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.view-mode-btn:hover,
.view-mode-btn.active {
    background: #eaf5ee;
    color: var(--color-3, #0e6938);
    border-color: var(--color-3, #0e6938);
}

.view-mode-btn svg {
    width: 18px;
    height: 18px;
}

.mobile-modal__overlay,
.mobile-modal__header,
.mobile-modal__footer,
.js-mobile-sort-modal {
    display: none;
}

/* 2. Filter Tags & Dropdowns */
.products-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 30px;
    border-bottom: 1px solid #f1f1f1;
    padding-bottom: 20px;
}

.filter-dropdown {
    position: relative;
}

.filter-tag-btn {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    padding: 6px 14px;
    font-size: 13.5px;
    color: #374151;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.filter-tag-btn:hover {
    border-color: var(--color-3, #0e6938);
    color: var(--color-3, #0e6938);
}

.filter-tag-btn svg {
    width: 12px;
    height: 12px;
}

.filter-tag-btn.is-active {
    border-color: var(--color-3, #0e6938);
    background-color: #eaf5ee;
    color: var(--color-3, #0e6938);
    font-weight: 600;
}

.filter-tag-btn.is-active svg {
    stroke: var(--color-3, #0e6938);
}

.filter-dropdown__panel {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    min-width: 250px;
    padding: 20px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.filter-dropdown.is-open .filter-dropdown__panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.category-main,
.category-main__inner,
.products-layout,
.ctnr {
    overflow: visible !important;
}

/* 3. Layout & Sidebar */
.products-layout {
    display: flex;
    align-items: flex-start;
    gap: 30px;
}

.products-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: #ffffff;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.products-sidebar::-webkit-scrollbar {
    width: 5px;
}

.products-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.products-sidebar::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

.products-sidebar::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

.filter-widget {
    border-bottom: 1px solid #f1f1f1;
    padding: 18px 0 0;
}

.filter-widget:first-child {
    padding-top: 0;
}

.filter-widget__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    margin-bottom: 14px;
}

.filter-widget__title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.filter-widget.has-checked .filter-widget__title {
    color: var(--color-3, #0e6938);
    font-weight: 700;
}

.filter-widget__arrow {
    width: 16px;
    height: 16px;
    color: #9ca3af;
    transition: transform 0.3s ease;
}

.filter-widget.is-collapsed .filter-widget__arrow {
    transform: rotate(-180deg);
}

.filter-widget.is-collapsed .filter-widget__body {
    display: none;
}

/* Price range inputs and slider */
.filter-price__inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.filter-price__inputs input {
    flex: 1;
    width: 100%;
    height: 36px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0 10px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
}

.filter-price__inputs input:focus {
    border-color: var(--color-3, #0e6938);
}

.filter-price__slider {
    position: relative;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    margin: 20px 0 10px;
}

.filter-price__range {
    position: absolute;
    height: 100%;
    background: var(--color-3, #0e6938);
    left: 0;
    right: 0;
    border-radius: 2px;
}

.filter-price__input {
    position: absolute;
    width: 100%;
    height: 4px;
    top: 0;
    left: 0;
    background: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    outline: none;
    z-index: 2;
}

.filter-price__input::-webkit-slider-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--color-3, #0e6938);
    pointer-events: auto;
    -webkit-appearance: none;
    cursor: pointer;
    position: relative;
    z-index: 3;
    box-shadow: 0 0 0 2px #ffffff, 0 1px 4px rgba(14, 105, 56, 0.3);
}

.filter-price__input::-moz-range-thumb {
    height: 16px;
    width: 16px;
    border: none;
    border-radius: 50%;
    background: var(--color-3, #0e6938);
    pointer-events: auto;
    cursor: pointer;
    position: relative;
    z-index: 3;
    box-shadow: 0 0 0 2px #ffffff, 0 1px 4px rgba(14, 105, 56, 0.3);
}

/* Checkboxes & trees */
.filter-checkbox-input {
    appearance: none;
    -webkit-appearance: none;
    width: 17px;
    height: 17px;
    border: 1.5px solid #cbd5e1;
    border-radius: 4px;
    background-color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
    position: relative;
    margin: 0;
}

.filter-checkbox-input:checked {
    background-color: var(--color-3, #0e6938);
    border-color: var(--color-3, #0e6938);
}

.filter-checkbox-input:checked::after {
    content: '';
    width: 4px;
    height: 8px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.filter-checkbox-input:hover {
    border-color: var(--color-3, #0e6938);
}

.filter-category-tree,
.filter-brand-list {
    list-style: none;
    padding: 0;
    margin: 0 0 10px 0;
}

.filter-category-tree li,
.filter-brand-list li {
    margin-bottom: 4px;
}

.filter-category-tree li.level-0>label {
    font-weight: 600;
    color: #1f2937;
    font-size: 13.5px;
}

.filter-category-tree li.level-child>label {
    font-weight: 400;
    color: #4b5563;
    font-size: 13px;
}

.filter-category-tree li label,
.filter-brand-list li label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
    cursor: pointer;
    user-select: none;
}

.filter-category-tree li label:hover,
.filter-brand-list li label:hover {
    background: #eaf5ee;
    color: var(--color-3, #0e6938);
}

.filter-category-tree li.is-active>label,
.filter-category-tree li label.is-checked,
.filter-brand-list li.is-active>label,
.filter-brand-list li label.is-checked {
    background-color: #eaf5ee;
    color: var(--color-3, #0e6938);
    font-weight: 600;
}

.js-expandable-list.is-collapsed li:nth-child(n+6) {
    display: none;
}

.filter-expand-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 5px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-3, #0e6938);
    cursor: pointer;
    transition: color 0.2s;
    margin-bottom: 10px;
}

.filter-expand-btn:hover {
    color: #094826;
    text-decoration: underline;
}

.filter-expand-btn .filter-expand-icon {
    transition: transform 0.3s ease;
}

.filter-expand-btn.is-expanded .filter-expand-icon {
    transform: rotate(180deg);
}

/* 4. Products Grid */
.products-main {
    flex: 1;
    min-width: 0;
}

.products-grid.view-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.products-grid.view-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.products-grid.view-list .product-card {
    flex-direction: row;
    align-items: center;
    gap: 30px;
}

.products-grid.view-list .product-card__img-wrap {
    width: 240px;
    margin-bottom: 0;
    flex-shrink: 0;
}

.products-grid.view-list .product-card__info {
    justify-content: center;
}

.products-grid.view-list .product-card__title {
    font-size: 18px;
    margin-bottom: 12px;
}

/* 5. Pagination */
.pagination-wrap {
    margin-top: 30px;
}

.pagination-wrap .pagination {
    display: flex;
    gap: 6px;
    list-style: none;
    padding: 0;
    margin: 0;
    justify-content: center;
}

.pagination-wrap .page-item .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #374151;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.pagination-wrap .page-item:not(.active):not(.disabled) .page-link:hover {
    background: #eaf5ee;
    border-color: var(--color-3, #0e6938);
    color: var(--color-3, #0e6938);
}

.pagination-wrap .page-item.active .page-link {
    background: var(--color-3, #0e6938);
    border-color: var(--color-3, #0e6938);
    color: #ffffff;
    box-shadow: 0 3px 10px rgba(14, 105, 56, 0.25);
}

.pagination-wrap .page-item.disabled .page-link {
    color: #9ca3af;
    background: #f9fafb;
    border-color: #e5e7eb;
    cursor: not-allowed;
}

/* 6. Responsive */
@media (max-width: 1200px) {
    .products-grid.view-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .products-toolbar {
        flex-wrap: wrap;
    }

    .products-toolbar__left {
        flex: auto;
    }

    .products-sidebar {
        top: 0;
    }
}

@media (max-width: 991px) {
    .products-main {
        width: 100%;
    }

    .products-layout {
        flex-direction: column;
    }

    .mobile-filters-btn {
        /* display: block; */
        background: #eaf5ee;
        border: 1px solid rgba(14, 105, 56, 0.2);
        border-radius: 20px;
        padding: 6px 14px;
        color: var(--color-3, #0e6938);
        font-weight: 600;
        font-size: 13px;
        cursor: pointer;
        text-transform: uppercase;
    }

    .products-sort {
        border-radius: 20px;
        color: var(--color-3, #0e6938);
        font-weight: 600;
        text-transform: uppercase;
        flex-wrap: wrap;
    }

    .products-sort__group {
        display: none;
    }

    .products-sort__mobile {
        display: block !important;
    }

    .products-sort__select {
        padding: 8px 30px 8px 15px;
        border: 1px solid #e5e7eb;
        border-radius: 20px;
        background-color: #ffffff;
        color: #374151;
        font-size: 13px;
        outline: none;
        cursor: pointer;
        -webkit-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230e6938' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 10px center;
        background-size: 14px;
        font-weight: 500;
        text-transform: none;
        max-width: 100%;
    }

    .products-sort svg path {
        stroke: var(--color-3, #0e6938);
    }

    .products-toolbar__right {
        gap: 10px;
    }

    .products-filter-tags {
        display: none;
    }

    .mobile-modal {
        position: fixed;
        inset: 0;
        z-index: 1000;
        display: block;
        pointer-events: none;
    }

    .mobile-modal__overlay {
        display: block;
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .mobile-modal__content {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        background: #ffffff;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
        max-height: 85vh;
    }

    .mobile-modal.is-open {
        pointer-events: auto;
        width: 100%;
    }

    .mobile-modal.is-open .mobile-modal__overlay {
        opacity: 1;
    }

    .mobile-modal.is-open .mobile-modal__content {
        transform: translateY(0);
    }

    .mobile-modal__header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
        border-bottom: 1px solid #f1f1f1;
        margin-bottom: 20px;
    }

    .mobile-modal__header h3 {
        margin: 0;
        font-size: 16px;
        font-weight: 600;
    }

    .mobile-modal__close {
        background: none;
        border: none;
        padding: 4px;
        cursor: pointer;
        color: #000000;
    }

    .mobile-modal__body {
        flex: 1;
        overflow-y: auto;
        padding: 0 20px;
    }

    .mobile-modal__footer {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 16px 20px;
        border-top: 1px solid #f1f1f1;
    }

    .mobile-modal__btn {
        width: 100%;
        padding: 12px;
        border-radius: 6px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        border: 1px solid transparent;
        text-align: center;
    }

    .mobile-modal__btn--primary {
        background: var(--color-3, #0e6938);
        color: #ffffff;
    }

    .mobile-modal__btn--outline {
        background: #ffffff;
        border-color: #e5e7eb;
        color: #e50308;
    }

    .products-sidebar {
        display: block;
        position: fixed;
        max-height: none;
        overflow-y: visible;
        top: 0;
        background: transparent;
    }

    .products-grid.view-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .products-grid.view-list .product-card__img-wrap {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .products-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .products-toolbar__right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .products-grid.view-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 15px;
    }

    .products-grid.view-grid>* {
        width: calc(50% - 7.5px);
    }

    .products-grid.view-list .product-card {
        flex-direction: row;
        gap: 15px;
    }

    .products-grid.view-list .product-card__img-wrap {
        width: 140px;
    }

    .products-grid.view-list .product-card__title {
        font-size: 15px;
    }

    .products-sidebar__heading {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .products-grid.view-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    .products-grid.view-grid>* {
        width: calc(50% - 5px);
    }

    .products-grid.view-list .product-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .products-grid.view-list .product-card__img-wrap {
        width: 100%;
    }

    .filter-dropdown__panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        margin: 0;
        border-radius: 12px 12px 0 0;
        transform: translateY(100%);
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }

    .filter-dropdown.is-open .filter-dropdown__panel {
        transform: translateY(0);
    }
}

@media (max-width: 380px) {
    .products-grid.view-grid>* {
        /* width: 100%; */
    }
}
