/* ==========================================================
   MAHERA JEWELS - PRODUCT LISTING
   Desktop sidebar + responsive mobile bottom-sheet filters
========================================================== */

.mj-listing-page {
    position: relative;
    width: 100%;
    padding: 18px 24px 60px;
    background: #fff;
    color: #171717;
}

.mj-listing-wrapper {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    align-items: start;
    gap: 20px;
    width: 100%;
    max-width: 1196px;
    margin: 0 auto;
}

/* ==========================================================
   FILTER SIDEBAR / FILTER SHEET
========================================================== */

.mj-filter-sidebar {
    width: 100%;
    min-width: 0;
    padding: 0 17px;
    background: #fff;
    border: 1px solid #eaeaea;
    border-radius: 12px;
}

.mj-mobile-sheet-header {
    display: none;
}

.mj-filter-form {
    width: 100%;
}

.mj-filter-section {
    padding: 20px 0;
    border-bottom: 1px solid #ededed;
}

.mj-filter-section:last-of-type {
    border-bottom: 0;
}

.mj-filter-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: #171717;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .35px;
    text-align: left;
    cursor: pointer;
    user-select: none;
}

.mj-filter-toggle {
    color: #d99a21;
    font-size: 17px;
    line-height: 1;
    font-weight: 500;
}

.mj-filter-content {
    display: flex;
    flex-direction: column;
    gap: 13px;
    padding-top: 18px;
}

.mj-filter-section.is-collapsed .mj-filter-content {
    display: none;
}

.mj-filter-option {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 19px;
    color: #777;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    cursor: pointer;
}

.mj-filter-option:hover {
    color: #4c092c;
}

.mj-filter-option input {
    position: relative;
    flex: 0 0 13px;
    width: 13px;
    height: 13px;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid #aaa;
    border-radius: 2px;
    background: #fff;
    cursor: pointer;
}

.mj-filter-option input:checked {
    border-color: #4c092c;
    background: #4c092c;
}

.mj-filter-option input:checked::after {
    position: absolute;
    top: 0;
    left: 3px;
    width: 4px;
    height: 7px;
    border: solid #fff;
    border-width: 0 1.5px 1.5px 0;
    content: "";
    transform: rotate(45deg);
}

.mj-filter-child {
    padding-left: 20px;
}

/* ==========================================================
   PRICE RANGE SLIDER
========================================================== */

.mj-price-values {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #444;
    font-size: 12px;
    font-weight: 600;
}

.mj-range-slider {
    position: relative;
    height: 24px;
    margin: 4px 7px 0;
}

.mj-range-track,
.mj-range-selected {
    position: absolute;
    top: 10px;
    height: 3px;
    border-radius: 10px;
}

.mj-range-track {
    right: 0;
    left: 0;
    background: #dedede;
}

.mj-range-selected {
    left: var(--min-percent);
    right: calc(100% - var(--max-percent));
    background: #4c092c;
}

.mj-range-slider input[type="range"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 22px;
    margin: 0;
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    background: none;
    pointer-events: none;
}

.mj-range-slider input[type="range"]::-webkit-slider-runnable-track {
    height: 3px;
    background: transparent;
}

.mj-range-slider input[type="range"]::-moz-range-track {
    height: 3px;
    background: transparent;
}

.mj-range-slider input[type="range"]::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
    margin-top: -5.5px;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #4c092c;
    box-shadow: 0 0 0 1px #4c092c;
    cursor: grab;
    pointer-events: auto;
}

.mj-range-slider input[type="range"]::-moz-range-thumb {
    width: 11px;
    height: 11px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #4c092c;
    box-shadow: 0 0 0 1px #4c092c;
    cursor: grab;
    pointer-events: auto;
}

/* ==========================================================
   FILTER ACTION BUTTONS
========================================================== */

.mj-filter-actions {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 20px 0;
}

.mj-apply-filter-btn,
.mj-reset-filter-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 38px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.mj-apply-filter-btn {
    border: 1px solid #4c092c;
    background: #4c092c;
    color: #fff;
}

.mj-apply-filter-btn:hover {
    background: #650c3a;
}

.mj-reset-filter-btn {
    border: 1px solid #dedede;
    background: #f7f7f7;
    color: #333;
}

.mj-reset-filter-btn:hover {
    border-color: #4c092c;
    color: #4c092c;
}

/* ==========================================================
   PRODUCT TOOLBAR
========================================================== */

.mj-products-area {
    width: 100%;
    min-width: 0;
}

.mj-listing-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 39px;
    margin-bottom: 13px;
}

.mj-product-count {
    color: #333;
    font-size: 12px;
    font-weight: 500;
}

.mj-sort-form select {
    min-width: 145px;
    height: 37px;
    padding: 0 12px;
    border: 1px solid #e8e2df;
    border-radius: 8px;
    outline: none;
    background: #fff;
    color: #333;
    font-size: 12px;
    cursor: pointer;
}

/* ==========================================================
   PRODUCT GRID AND CARDS
========================================================== */

.mj-product-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: start;
    gap: 17px;
}

.mj-product-grid .product-card {
    width: 100%;
    height: 100%;
    min-width: 0;
    overflow: hidden;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    background: #fff;
    box-shadow: none;
    transition: transform .2s ease, box-shadow .2s ease;
}

.mj-product-grid .product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 18px rgba(0, 0, 0, .07);
}

.mj-product-grid .product-card-image {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1.32;
    overflow: hidden;
    background: #f8f6f3;
}

.mj-product-grid .product-card-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mj-product-grid .product-image-hover {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .25s ease;
}

@media (hover: hover) and (pointer: fine) {
    .mj-product-grid .product-card-image.has-hover-image:hover .product-image-hover {
        opacity: 1;
    }
}

.mj-product-grid .product-card-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    padding: 12px 11px 13px;
}

.mj-product-grid .product-brand {
    color: #777;
    font-size: 10px;
    line-height: 1.4;
}

.mj-product-grid .product-name {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    color: #171717;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.45;
    text-decoration: none;
}

.mj-product-grid .product-price {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.mj-product-grid .product-current-price {
    color: #171717;
    font-size: 13px;
    font-weight: 700;
}

.mj-product-grid .product-cta {
    margin-top: 5px;
    color: #4c092c;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
}

.mj-product-grid .product-top-selling-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    padding: 5px 8px;
    border-radius: 4px;
    background: #4c092c;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
}

/* ==========================================================
   EMPTY STATE AND LOAD MORE
========================================================== */

.mj-empty-products {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: #777;
    text-align: center;
}

.mj-empty-products h3 {
    margin: 0 0 8px;
    color: #333;
    font-size: 18px;
}

.mj-empty-products p {
    margin: 0;
    font-size: 13px;
}

.mj-load-more-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 35px 15px;
}

.mj-load-more-btn {
    min-width: 180px;
    min-height: 44px;
    padding: 12px 30px;
    border: 1px solid #4c092c;
    border-radius: 30px;
    background: #fff;
    color: #4c092c;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, opacity .2s ease;
}

.mj-load-more-btn:hover:not(:disabled) {
    background: #4c092c;
    color: #fff;
}

.mj-load-more-btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* ==========================================================
   MOBILE BOTTOM SHEETS (hidden on desktop)
========================================================== */

.mj-mobile-listing-actions,
.mj-mobile-sheet-backdrop,
.mj-mobile-sort-sheet {
    display: none;
}

.mj-mobile-sheet-header {
    display: none;
}

/* ==========================================================
   TABLET
========================================================== */

@media (max-width: 1100px) and (min-width: 768px) {
    .mj-listing-wrapper {
        grid-template-columns: 220px minmax(0, 1fr);
        gap: 15px;
    }

    .mj-product-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 13px;
    }
}

/* ==========================================================
   MOBILE
========================================================== */

@media (max-width: 767px) {
    .mj-listing-page {
        padding: 12px 12px calc(126px + env(safe-area-inset-bottom));
    }

    .mj-listing-wrapper {
        display: block;
        width: 100%;
        max-width: none;
        padding: 0;
    }

    .mj-products-area {
        width: 100%;
    }

    .mj-listing-toolbar {
        min-height: 30px;
        margin-bottom: 12px;
    }

    .mj-product-count {
        font-size: 12px;
    }

    /* Hide desktop dropdown; mobile uses bottom Sort sheet. */
    .mj-sort-form {
        display: none;
    }

    /* The desktop sidebar becomes a bottom sheet on mobile. */
    .mj-filter-sidebar {
        position: fixed;
        z-index: 10002;
        right: 0;
        bottom: 0;
        left: 0;
        display: flex;
        flex-direction: column;
        width: 100%;
        max-height: 78dvh;
        margin: 0;
        padding: 0;
        overflow: hidden;
        border: 0;
        border-radius: 18px 18px 0 0;
        background: #fff;
        box-shadow: 0 -8px 35px rgba(0, 0, 0, .12);
        transform: translateY(105%);
        visibility: hidden;
        transition: transform .3s ease, visibility .3s ease;
    }

    .mj-filter-sidebar.is-open {
        transform: translateY(0);
        visibility: visible;
    }

    .mj-mobile-sheet-header {
        display: flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: space-between;
        min-height: 56px;
        padding: 0 16px;
        border-bottom: 1px solid #eee;
        background: #fff;
        color: #171717;
        font-size: 15px;
    }

    .mj-mobile-sheet-header button {
        display: grid;
        place-items: center;
        width: 34px;
        height: 34px;
        padding: 0;
        border: 0;
        background: transparent;
        color: #777;
        font-size: 26px;
        line-height: 1;
        cursor: pointer;
    }

    .mj-filter-form {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 0 16px;
        -webkit-overflow-scrolling: touch;
    }

    .mj-filter-section {
        flex: 0 0 auto;
        padding: 0;
        border-bottom: 1px solid #eee;
    }

    .mj-filter-heading {
        min-height: 49px;
        font-size: 12px;
    }

    .mj-filter-toggle {
        color: #4c092c;
    }

    .mj-filter-content {
        gap: 12px;
        padding: 2px 0 15px;
    }

    .mj-filter-option {
        min-height: 32px;
        font-size: 13px;
    }

    .mj-filter-option input {
        flex-basis: 15px;
        width: 15px;
        height: 15px;
    }

    .mj-filter-option input:checked::after {
        left: 4px;
        width: 4px;
        height: 7px;
    }

    .mj-price-values {
        font-size: 13px;
    }

    .mj-range-slider {
        margin: 8px 8px 3px;
    }

    /* Sticky Reset / Apply footer inside the filter sheet. */
    .mj-filter-actions {
        position: sticky;
        z-index: 2;
        bottom: 0;
        display: grid;
        flex: 0 0 auto;
        grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
        gap: 10px;
        margin-top: auto;
        padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid #eee;
        background: #fff;
    }

    .mj-apply-filter-btn,
    .mj-reset-filter-btn {
        min-height: 44px;
        margin: 0;
        border-radius: 7px;
        font-size: 13px;
    }

    /* Sort bottom sheet. */
    .mj-mobile-sort-sheet {
        position: fixed;
        z-index: 10002;
        right: 0;
        bottom: 0;
        left: 0;
        display: flex;
        flex-direction: column;
        max-height: 58dvh;
        overflow: hidden;
        border-radius: 18px 18px 0 0;
        background: #fff;
        box-shadow: 0 -8px 35px rgba(0, 0, 0, .12);
        transform: translateY(105%);
        visibility: hidden;
        transition: transform .3s ease, visibility .3s ease;
    }

    .mj-mobile-sort-sheet.is-open {
        transform: translateY(0);
        visibility: visible;
    }

    .mj-mobile-sort-sheet form {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
    }

    .mj-sort-options {
        flex: 1 1 auto;
        overflow-y: auto;
        padding: 8px 16px;
    }

    .mj-sort-option {
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 48px;
        border-bottom: 1px solid #eee;
        color: #444;
        font-size: 13px;
        cursor: pointer;
    }

    .mj-sort-option input {
        width: 16px;
        height: 16px;
        margin: 0;
        accent-color: #4c092c;
    }

    .mj-mobile-sheet-actions {
        flex: 0 0 auto;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid #eee;
        background: #fff;
    }

    .mj-mobile-sheet-actions button {
        width: 100%;
        min-height: 44px;
        border: 0;
        border-radius: 7px;
        background: #4c092c;
        color: #fff;
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
    }

    /* Dimmed overlay behind an opened bottom sheet. */
    .mj-mobile-sheet-backdrop {
        position: fixed;
        z-index: 10001;
        inset: 0;
        display: block;
        width: 100%;
        height: 100%;
        padding: 0;
        border: 0;
        background: rgba(0, 0, 0, .48);
        opacity: 0;
        visibility: hidden;
        transition: opacity .25s ease, visibility .25s ease;
    }

    .mj-mobile-sheet-backdrop.is-visible {
        opacity: 1;
        visibility: visible;
    }

    body.mj-bottom-sheet-open {
        overflow: hidden;
    }

    /* Fixed Sort / Filter bar, placed above the existing mobile nav. */
    .mj-mobile-listing-actions {
        position: fixed;
        z-index: 9999;
        right: 0;
        bottom: calc(58px + env(safe-area-inset-bottom));
        left: 0;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1px;
        padding: 7px 12px;
        border-top: 1px solid #eee;
        background: #fff;
        box-shadow: 0 -3px 12px rgba(0, 0, 0, .04);
    }

    .mj-mobile-listing-actions button {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-height: 42px;
        border: 0;
        border-radius: 24px;
        background: #f5f5f5;
        color: #292929;
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
    }

    .mj-mobile-listing-actions button:active {
        background: #eee;
    }

    .mj-action-icon {
        color: #4c092c;
        font-size: 17px;
        line-height: 1;
    }

    body.mj-bottom-sheet-open .mj-mobile-listing-actions {
        visibility: hidden;
    }

    /* Two product cards per row, matching the mobile storefront. */
    .mj-product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 11px;
    }

    .mj-product-grid .product-card-image {
        aspect-ratio: 1 / 1.2;
    }

    .mj-product-grid .product-card-body {
        gap: 4px;
        padding: 9px;
    }

    .mj-product-grid .product-brand {
        font-size: 9px;
    }

    .mj-product-grid .product-name {
        font-size: 11px;
        line-height: 1.4;
    }

    .mj-product-grid .product-current-price {
        font-size: 12px;
    }

    .mj-product-grid .product-cta {
        font-size: 10px;
    }

    .mj-load-more-wrapper {
        padding: 26px 10px 18px;
    }

    .mj-load-more-btn {
        min-width: 160px;
        min-height: 42px;
        font-size: 13px;
    }
}

@media (max-width: 360px) {
    .mj-listing-page {
        padding-right: 9px;
        padding-left: 9px;
    }

    .mj-product-grid {
        gap: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mj-filter-sidebar,
    .mj-mobile-sort-sheet,
    .mj-mobile-sheet-backdrop,
    .mj-product-grid .product-card {
        transition: none;
    }
}
