/*
 * Product listings: the filter sidebar, toolbar and results (components/shop/results.blade.php).
 *
 * The look is the store's existing shop sidebar: uppercase group titles with a chevron and a black
 * rule, 13px option rows and the "Width ... in to ... in" size inputs. What is new is a checkbox on
 * each option (filters combine), a sort menu and the chips that undo a filter.
 * listing.js submits the form in the background and swaps in the #listing block.
 */

/* ---- Layout (was pushed by components/shop/layout.blade.php) ---- */
.shop-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    justify-content: space-between;
}

.shop-body {
    flex: 1;
    min-width: 0;
    padding-left: 4px;
}

.filter-sidebar-modern {
    flex: 0 0 280px;
    width: 280px;
}

.filter-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
}

.filter-sidebar-overlay.active {
    display: block;
}

@media (max-width: 991px) {
    .shop-wrapper {
        flex-direction: column;
        gap: 0;
    }

    .shop-body {
        padding-left: 0;
        width: 100%;
    }

    /* #listing-filters: outranks the sidebar component's own "position: relative; z-index: 1",
       whichever order the two stylesheets arrive in. */
    #listing-filters.filter-sidebar-modern {
        position: fixed !important;
        top: 0;
        left: -100%;
        width: 320px;
        max-width: 85vw;
        height: 100vh;
        height: 100dvh;
        z-index: 9999;
        background: #ffffff !important;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15) !important;
        padding: 0 !important;
        display: flex;
        flex-direction: column;
    }

    #listing-filters.filter-sidebar-modern.active {
        left: 0;
    }
}

@media (max-width: 768px) {
    #listing-filters.filter-sidebar-modern {
        width: 100%;
        max-width: 100vw;
    }
}

body.sidebar-open {
    overflow: hidden;
}

@media (min-width: 992px) {
    body.sidebar-open {
        overflow: auto;
    }
}

/* ---- Filter groups (same look as the accordion they replace) ---- */
.lf-group {
    border-bottom: 1px solid #000000;
}

.lf-group:last-of-type {
    border-bottom: none;
}

.lf-group > summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 16px 10px 16px 0;
    cursor: pointer;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #000000;
}

.lf-group > summary::-webkit-details-marker {
    display: none;
}

.lf-group > summary::after {
    content: '';
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: 1px solid #000000;
    background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000000'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e") center / 14px 14px no-repeat;
    transition: transform 0.2s ease;
}

/* Open groups show the down chevron, as the sidebar always has; a closed group points sideways. */
.lf-group:not([open]) > summary::after {
    transform: rotate(-90deg);
}

.lf-group > summary:focus-visible {
    outline: 2px solid #c8ad80;
    outline-offset: 2px;
}

.lf-group__title {
    flex: 1;
}

.lf-group__chosen {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #c8ad80;
    color: #ffffff;
    font-size: 11px;
    letter-spacing: 0;
}

.lf-options {
    list-style: none;
    margin: 0 0 12px;
    padding: 0 4px 0 0;
    max-height: 280px;
    overflow-y: auto;
}

.lf-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 0 8px;
    cursor: pointer;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: #232e35;
}

.lf-option input {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    margin: 2px 0 0;
    accent-color: #c8ad80;
    cursor: pointer;
}

.lf-option:hover .lf-option__label {
    text-decoration: underline;
}

.lf-option input:checked ~ .lf-option__label {
    font-weight: 700;
}

.lf-option__count {
    color: #6b7280;
}

/* ---- Size (same inputs as the old "Search by dimension" box) ---- */
.lf-dimensions {
    padding-bottom: 12px;
}

.lf-range {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    padding: 0;
    border: 0;
    min-width: 0;
}

.lf-range legend {
    float: left;
    width: 54px;
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    color: #000000;
}

.lf-range__input {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.lf-range input {
    width: 60px;
    padding: 8px 6px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #000000;
    text-align: center;
    background: #ffffff;
    -moz-appearance: textfield;
}

.lf-range input::-webkit-outer-spin-button,
.lf-range input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.lf-range input:focus {
    outline: none;
    border-color: #999999;
}

.lf-range__unit,
.lf-range__to {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #666666;
}

.lf-dimensions__apply {
    width: 100%;
    padding: 8px 16px;
    border: none;
    border-radius: 0;
    background: #f8fafc;
    color: #000000;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    cursor: pointer;
}

.lf-dimensions__apply:hover {
    background: #f3f4f6;
}

/* ---- Panel footer: "Show N items" (phone drawer, or without JavaScript) and Clear all ---- */
.lf-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0 4px;
}

.lf-apply {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: none;
    border-radius: 0;
    background: #c8ad80;
    color: #ffffff;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
}

.lf-apply:hover,
.lf-apply:focus {
    background: #b59a6d;
    color: #ffffff;
}

.lf-clear {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    color: #232e35;
    text-decoration: underline;
    white-space: nowrap;
}

/* With JavaScript the desktop sidebar applies each change at once; the button is only needed in the drawer. */
@media (min-width: 992px) {
    .js-listing .lf-foot .lf-apply {
        display: none;
    }
}

@media (max-width: 991px) {
    .filter-sidebar-modern .filter-content-wrapper {
        padding: 8px 20px 20px;
        flex: 1;
        overflow-y: auto;
    }

    .lf-foot {
        position: sticky;
        bottom: 0;
        padding: 12px 20px;
        background: #ffffff;
        border-top: 1px solid #e5e7eb;
    }
}

/* ---- Toolbar: count, sort, active filters ---- */
.filter-count-section {
    flex-wrap: wrap;
    gap: 12px;
}

.lf-sort {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    color: #232e35;
}

.lf-sort select {
    padding: 7px 30px 7px 10px;
    border: 1px solid #d1d5db;
    border-radius: 0;
    background: #ffffff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000000'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e") right 10px center / 12px 12px no-repeat;
    -webkit-appearance: none;
    appearance: none;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    color: #000000;
    cursor: pointer;
}

.lf-sort select:focus {
    outline: 2px solid #c8ad80;
    outline-offset: 1px;
}

.lf-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 12px 0 4px;
    padding: 0;
}

.lf-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid #c8ad80;
    background: #faf6ef;
    color: #232e35;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    line-height: 1.3;
    text-decoration: none;
}

.lf-chip:hover,
.lf-chip:focus {
    background: #c8ad80;
    color: #ffffff;
}

.lf-chip--clear {
    border-color: transparent;
    background: transparent;
    text-decoration: underline;
}

.lf-chip--clear:hover,
.lf-chip--clear:focus {
    background: transparent;
    color: #000000;
}

.mobile-filter-btn .lf-group__chosen {
    position: absolute;
    top: -6px;
    right: -6px;
}

.mobile-filter-btn {
    position: relative;
}

/* ---- Nothing matches ---- */
.lf-empty {
    margin: 24px 0;
    padding: 40px 24px;
    border: 1px solid #e5e7eb;
    text-align: center;
    font-family: Arial, Helvetica, sans-serif;
}

.lf-empty h2 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: #000000;
}

.lf-empty p {
    max-width: 520px;
    margin: 0 auto 20px;
    font-size: 15px;
    color: #4b5563;
}

.lf-empty .lf-apply {
    flex: none;
}

/* ---- While a change is loading ---- */
#listing[aria-busy="true"] .shop-body {
    opacity: 0.55;
    transition: opacity 0.15s ease;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
