/* ===================================================================
   Product list page (PLP) — breadcrumb, toolbar, filters, grid layout.
=================================================================== */

.cw-plp { padding-bottom: 44px; }

.cw-plp__head { margin-top: 20px; margin-bottom: 12px; }
.cw-plp__head--mobile { display: none; }
.cw-plp__title { font-size: 18px; font-weight: 800; color: var(--ink); margin: 0 0 4px; line-height: 1.85; }
.cw-plp__title-base { color: var(--ink); font-weight: 800; }
.cw-plp__title-filter { color: var(--muted); font-weight: 700; }
.cw-plp__title-mobile-count { display: inline; color: var(--muted); font-weight: 600; }
.cw-plp__count { font-size: 12.5px; color: var(--muted); margin: 0; }

@media (min-width: 992px) {
    .cw-plp__title { font-size: 22px; }
    .cw-plp__title-mobile-count { display: none; }
}

/* ===================== mobile quick-filter chips ===================== */

.cw-plp-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 4px 2px 16px;
}
.cw-plp-chips::-webkit-scrollbar { display: none; }

.cw-plp-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 15px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--ink);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.cw-plp-chip svg { width: 15px; height: 15px; flex: 0 0 auto; }
.cw-plp-chip--filter { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ===================== desktop sort bar ===================== */

.cw-plp-sortbar { display: none; }

@media (min-width: 992px) {
    .cw-plp-chips { display: none; }

    .cw-plp-sortbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        padding: 12px 18px;
        margin-bottom: 20px;
        background: var(--white);
    }
    .cw-plp-sortbar__options { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
    .cw-plp-sort-opt {
        background: none;
        border: 0;
        padding: 7px 10px 12px;
        border-radius: var(--radius-sm);
        transition: background .15s ease, color .15s ease;
        font-size: 13px;
        color: var(--muted);
        font-weight: 600;
        cursor: pointer;
        position: relative;
    }
    .cw-plp-sort-opt:hover,
    .cw-plp-sort-opt.is-active {
        color: var(--brand);
    }
    .cw-plp-sort-opt:hover {
        background: var(--brand-soft);
    }
    .cw-plp-sort-opt.is-active::after {
        content: '';
        position: absolute;
        right: 0; left: 0; bottom: 0;
        height: 2px;
        background: var(--brand);
        border-radius: 2px;
    }
    .cw-plp-sortbar__count { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
}

/* ===================== layout: sidebar + grid ===================== */

.cw-plp__layout { display: flex; flex-direction: column; }

@media (min-width: 992px) {
    .cw-plp__layout { flex-direction: row; align-items: flex-start; gap: 24px; }
}

.cw-plp-grid {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@media (min-width: 640px) {
    .cw-plp-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
        gap: 7px;
    }
}
@media (min-width: 992px) {
    .cw-plp-grid { grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 9px; }
}

/* ===================== sidebar filters (desktop only) ===================== */

.cw-plp-filters { display: none; }

@media (min-width: 992px) {
    .cw-plp-filters {
        display: block;
        flex: 0 0 264px;
        width: 264px;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        padding: 16px 18px;
        position: sticky;
        top: calc(var(--header-h) + var(--subheader-h) + 16px);
        max-height: calc(100vh - var(--header-h) - var(--subheader-h) - 32px);
        overflow-y: auto;
    }
}
.cw-plp-filters__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.cw-plp-filters__head h2 { font-size: 15px; margin: 0; }
.cw-plp-filters__clear { background: none; border: 0; color: var(--brand); font-size: 12px; font-weight: 700; cursor: pointer; padding: 0; }

/* ===================== filter groups (shared: sidebar + drawer) ===================== */

.cw-plp-facc { border-bottom: 1px solid var(--border); }
.cw-plp-filters .cw-plp-facc:last-of-type,
.cw-plp-drawer__body .cw-plp-facc:last-of-type { border-bottom: 0; }

.cw-plp-facc__head {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: 0;
    padding: 14px 0;
    cursor: pointer;
    text-align: right;
    color: var(--ink);
}
.cw-plp-facc__icon { width: 20px; height: 20px; color: var(--brand); flex: 0 0 auto; }
.cw-plp-facc__title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}
.cw-plp-facc__title { font-size: 13.5px; font-weight: 700; }
.cw-plp-facc__summary {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.7;
    color: var(--muted);
}
.cw-plp-facc__sub { font-size: 11px; color: var(--muted); }
.cw-plp-facc__chev { width: 18px; height: 18px; color: var(--muted); flex: 0 0 auto; transition: transform .2s ease; }
.cw-plp-facc.is-open .cw-plp-facc__chev { transform: rotate(180deg); }

.cw-plp-facc__body { display: none; flex-direction: column; gap: 12px; padding: 0 0 16px; }
.cw-plp-facc.is-open .cw-plp-facc__body { display: flex; }

/* Keep very long brand lists from making the whole filter panel excessively tall. */
.cw-plp-facc[data-plp-filter-group="brand"] .cw-plp-facc__body {
    max-height: 280px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-inline-end: 7px;
    scrollbar-width: thin;
}
.cw-plp-facc[data-plp-filter-group="brand"] .cw-plp-facc__body::-webkit-scrollbar { width: 6px; }
.cw-plp-facc[data-plp-filter-group="brand"] .cw-plp-facc__body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }


/* Desktop: long filter value lists scroll inside the filter group so the
   final options (including «فقط کالاهای موجود») remain reachable without
   scrolling the entire page/filter panel. */
@media (min-width: 992px) {
    .cw-plp-filters .cw-plp-facc[data-plp-filter-group="brand"] .cw-plp-facc__body,
    .cw-plp-filters .cw-plp-facc[data-variant-filter-group] .cw-plp-facc__body {
        max-height: 240px;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding-inline-end: 7px;
        scrollbar-width: thin;
        scrollbar-color: var(--border) transparent;
    }

    .cw-plp-filters .cw-plp-facc[data-plp-filter-group="brand"] .cw-plp-facc__body::-webkit-scrollbar,
    .cw-plp-filters .cw-plp-facc[data-variant-filter-group] .cw-plp-facc__body::-webkit-scrollbar {
        width: 6px;
    }

    .cw-plp-filters .cw-plp-facc[data-plp-filter-group="brand"] .cw-plp-facc__body::-webkit-scrollbar-thumb,
    .cw-plp-filters .cw-plp-facc[data-variant-filter-group] .cw-plp-facc__body::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 999px;
    }

    .cw-plp-filters .cw-plp-facc[data-plp-filter-group="brand"] .cw-plp-facc__body::-webkit-scrollbar-track,
    .cw-plp-filters .cw-plp-facc[data-variant-filter-group] .cw-plp-facc__body::-webkit-scrollbar-track {
        background: transparent;
    }
}

.cw-plp-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; }
.cw-plp-check input {
    width: 16px; height: 16px;
    accent-color: var(--brand);
    flex: 0 0 auto;
}

.cw-plp-colorlist { display: flex; flex-wrap: wrap; gap: 10px; }
.cw-plp-colorlist__dot {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    border: 1px solid var(--border);
    box-shadow: 0 0 0 1px rgba(33, 28, 27, .04) inset;
    cursor: pointer;
    padding: 0;
}
.cw-plp-colorlist__dot.is-selected { outline: 2px solid var(--brand); outline-offset: 2px; }

.cw-plp-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--ink);
    cursor: pointer;
}
.cw-plp-filters .cw-plp-toggle:last-of-type,
.cw-plp-drawer__body .cw-plp-toggle:last-of-type { border-bottom: 0; }

.cw-plp-switch { position: relative; display: inline-block; width: 40px; height: 23px; flex: 0 0 auto; }
.cw-plp-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.cw-plp-switch__track { position: absolute; inset: 0; background: var(--border); border-radius: var(--radius-full); transition: background .18s ease; }
.cw-plp-switch__track::after {
    content: '';
    position: absolute;
    top: 2.5px;
    inset-inline-start: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: inset-inline-start .18s ease;
}
.cw-plp-switch input:checked + .cw-plp-switch__track { background: var(--brand); }
.cw-plp-switch input:checked + .cw-plp-switch__track::after { inset-inline-start: 19px; }

/* ===================== mobile filters drawer ===================== */

.cw-plp-drawer { position: fixed; inset: 0; z-index: 9000; display: none; }
.cw-plp-drawer.is-open { display: block; }

.cw-plp-drawer__backdrop { position: absolute; inset: 0; background: rgba(20, 15, 14, .55); opacity: 0; transition: opacity .25s ease; }
.cw-plp-drawer.is-visible .cw-plp-drawer__backdrop { opacity: 1; }

.cw-plp-drawer__panel {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: min(92vw, 400px);
    background: var(--white);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .28s ease;
}
.cw-plp-drawer.is-visible .cw-plp-drawer__panel { transform: translateX(0); }

.cw-plp-drawer__head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.cw-plp-drawer__head h2 { font-size: 15.5px; margin: 0; }
.cw-plp-drawer__close {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink);
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 auto; cursor: pointer;
}
.cw-plp-drawer__close svg { width: 17px; height: 17px; }

.cw-plp-drawer__body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 18px; }

.cw-plp-drawer__footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
}
.cw-plp-drawer__clear { background: none; border: 0; color: var(--brand); font-size: 13px; font-weight: 700; padding: 0 4px; white-space: nowrap; cursor: pointer; }

@media (min-width: 992px) {
    .cw-plp-drawer { display: none !important; }
}

/* ===================== mobile sort sheet ===================== */

.cw-plp-sheet { position: fixed; inset: 0; z-index: 9000; display: none; }
.cw-plp-sheet.is-open { display: block; }

.cw-plp-sheet__backdrop { position: absolute; inset: 0; background: rgba(20, 15, 14, .55); opacity: 0; transition: opacity .25s ease; }
.cw-plp-sheet.is-visible .cw-plp-sheet__backdrop { opacity: 1; }

.cw-plp-sheet__panel {
    position: absolute;
    right: 0; left: 0; bottom: 0;
    max-height: 80vh;
    background: var(--white);
    border-radius: 18px 18px 0 0;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform .28s ease;
}
.cw-plp-sheet.is-visible .cw-plp-sheet__panel { transform: translateY(0); }

.cw-plp-sheet__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.cw-plp-sheet__head h2 { font-size: 15px; margin: 0; }

.cw-plp-sheet__body { padding: 6px 10px calc(14px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; }
.cw-plp-sheet__opt {
    display: block;
    width: 100%;
    text-align: right;
    background: none;
    border: 0;
    padding: 13px 10px;
    font-size: 13.5px;
    color: var(--ink);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.cw-plp-sheet__opt.is-active { color: var(--brand); font-weight: 700; background: var(--brand-soft); }

@media (min-width: 992px) {
    .cw-plp-sheet { display: none !important; }
}


/* ===================== PLP refinements ===================== */

@media (min-width: 992px) {
    .cw-plp > .cw-container {
        max-width: 1680px;
    }

    .cw-plp__layout {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 24px;
    }

    .cw-plp__products {
        flex: 1 1 auto;
        min-width: 0;
    }

    .cw-plp-sortbar {
        margin-bottom: 18px;
    }

    .cw-plp-grid {
        width: 100%;
    }
}

/* Loading state for test/infinite product loading */
.cw-plp-loadmore {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 0 4px;
    color: var(--muted);
    font-size: 12.5px;
}
.cw-plp-loader {
    width: 22px;
    height: 22px;
    border: 2.5px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: cw-plp-spin .7s linear infinite;
}
.cw-plp-loadmore__text { white-space: nowrap; }
.cw-plp-loadmore.is-done .cw-plp-loader { display: none; }
.cw-plp-loadmore.is-done .cw-plp-loadmore__text::after {
    content: 'محصول دیگری برای نمایش وجود ندارد.';
}
.cw-plp-loadmore.is-done .cw-plp-loadmore__text { font-size: 0; }
.cw-plp-loadmore.is-done .cw-plp-loadmore__text::after { font-size: 12.5px; }
@keyframes cw-plp-spin { to { transform: rotate(360deg); } }
/* The loading indicator is hidden until the user clicks «نمایش بیشتر». */
.cw-plp-loader[hidden],
.cw-plp-loadmore__text[hidden] { display: none !important; }


/* PLP breadcrumb gets a little more breathing room from the header/search area. */
.cw-plp .cw-crumbs { margin-top: 10px; }

/* Product-page breadcrumb/category should contain only the category name. */
.cw-plp .cw-crumbs span { font-weight: 700; color: var(--ink); }

/* The shared story viewer is not used on the PLP. */
.cw-plp ~ .cw-story-viewer { display: none !important; }

/* ===================== latest PLP fixes ===================== */
@media (min-width: 992px) {
    /* Keep the filter panel and the products column on the same vertical frame. */
    .cw-plp__layout { align-items: stretch; }
    .cw-plp__products { display: flex; flex-direction: column; }
    .cw-plp-grid { flex: 0 0 auto; }
    .cw-plp-filters { height: auto; box-sizing: border-box; }
}

.cw-plp-loadmore {
    min-height: 0;
    padding: 18px 0 4px;
}
.cw-plp-loadmore__button {
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--ink);
    border-radius: var(--radius-sm);
    padding: 10px 24px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.cw-plp-loadmore__button:hover {
    background: var(--surface);
    border-color: var(--brand);
    color: var(--brand);
}
.cw-plp-loadmore__button:disabled { opacity: .6; cursor: wait; }
.cw-plp-loadmore.is-loading .cw-plp-loadmore__button { display: none; }
.cw-plp-loadmore .cw-plp-loader[hidden],
.cw-plp-loadmore .cw-plp-loadmore__text[hidden] { display: none; }

/* Loader is hidden until the user explicitly clicks «نمایش بیشتر». */
.cw-plp-loadmore .cw-plp-loader[hidden] { display: none !important; }


/* ===================== best-selling page hero ===================== */
.cw-plp-best-hero {
    width: calc(100% - 288px);
    margin-inline-start: 288px;
    margin-top: 24px;
    margin-bottom: 20px;
    padding: 18px 24px 16px;
    text-align: center;
    position: relative;
}
.cw-plp-best-hero::before {
    content: '';
    display: block;
    width: 42px;
    height: 3px;
    margin: 0 auto 10px;
    border-radius: 999px;
    background: var(--brand);
}
.cw-plp-best-hero h1 {
    margin: 0;
    color: var(--brand);
    font-size: 25px;
    font-weight: 900;
    line-height: 1.5;
}
.cw-plp-best-hero p {
    margin: 7px auto 0;
    max-width: 620px;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 2;
}
@media (max-width: 991.98px) {
    .cw-plp-best-hero {
        width: auto;
        margin: 0 0 10px;
        padding: 2px 4px 8px;
    }
    .cw-plp-best-hero::before { width: 32px; height: 2px; margin-bottom: 8px; }
    .cw-plp-best-hero h1 { font-size: 20px; }
    .cw-plp-best-hero p { font-size: 11.5px; line-height: 1.9; margin-top: 5px; }
}

/* ===================== final PLP mobile layout ===================== */
@media (max-width: 991.98px) {
    /* Desktop title stays in its original place; mobile title is rendered
       inside the products column, immediately above the first product. */
    .cw-plp__head--desktop { display: none; }
    .cw-plp__head--mobile {
        display: block;
        margin: 10px 0 10px;
        text-align: right;
    }
    .cw-plp__head--mobile .cw-plp__title {
        font-size: 15px;
        line-height: 1.8;
        margin: 0;
        text-align: right;
    }
    .cw-plp__head--mobile .cw-plp__title-base { font-weight: 800; }
    .cw-plp__head--mobile .cw-plp__title-filter { font-weight: 700; }

    .cw-plp .cw-crumbs {
        margin-top: 10px;
        margin-bottom: 20px;
        white-space: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        line-height: 1.8;
    }
    .cw-plp .cw-crumbs::-webkit-scrollbar { display: none; }

    /* Search/header rule stays removed on PLP; chips remain directly beneath the flow. */
    .cw-plp-page .cw-header { border-bottom: 0; }

    /* Keep the chip design unchanged; only its contents/order are controlled by the markup. */
    .cw-plp-chips {
        position: sticky;
        top: 58px;
        z-index: 580;
        margin-inline: -14px;
        padding: 8px 16px 12px;
        background: var(--white);
        border-bottom: 1px solid var(--border);
    }
}

@media (min-width: 992px) {
    .cw-plp-sortbar__count {
        font-size: 12.5px;
        color: var(--muted);
        white-space: nowrap;
    }
}

/* Breadcrumb on PLP uses the same neutral scale as FAQ; no colored/bold segments. */
.cw-plp .cw-crumbs,
.cw-plp .cw-crumbs a,
.cw-plp .cw-crumbs span {
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
}

/* ===================== empty state (no products) ===================== */
.cw-plp-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    padding: 36px 16px 48px;
}
.cw-plp-empty__img { width: min(300px, 72%); height: auto; margin-bottom: 8px; }
.cw-plp-empty__title { margin: 0; font-size: 16px; font-weight: 800; color: var(--ink); }
.cw-plp-empty__text { margin: 0; font-size: 13px; line-height: 1.9; color: var(--muted); }
.cw-plp-empty__btn {
    margin-top: 10px;
    display: inline-block;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    background: var(--brand);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}
.cw-plp-empty__btn:hover { background: var(--brand-dark); }
