/* ===================================================================
   PLP product card — distinct from the home page's `.cw-card`.
   Mobile-first: a horizontal list row. From 640px up it turns into a
   vertical grid card (used together with `.cw-plp-grid` in
   product-list.css). One markup, two layouts — no duplicated DOM.
=================================================================== */

.cw-plp-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: box-shadow .18s ease, border-color .18s ease;
}
.cw-plp-card:hover { border-color: #E0D2CB; box-shadow: 0 10px 24px rgba(33, 28, 27, .08); }

.cw-plp-card__link {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
    padding: 10px;
}

.cw-plp-card__media {
    position: relative;
    flex: 0 0 106px;
    width: 106px;
    height: 106px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}
.cw-plp-card__media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    user-select: none;
    -webkit-user-drag: none;
}
.cw-plp-card.is-oos .cw-plp-card__media img { opacity: .45; }

.cw-plp-card__ribbon {
    position: absolute;
    top: 8px;
    inset-inline-end: 0;
    background: var(--brand-dark);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    padding: 4px 7px;
    border-radius: 6px 0 0 6px;
    z-index: 1;
}

.cw-plp-card__colors {
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    display: flex;
    gap: 3px;
    z-index: 1;
}
.cw-plp-card__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .8);
    box-shadow: 0 0 0 1px rgba(33, 28, 27, .1);
}

.cw-plp-card__discount-tag {
    position: absolute;
    bottom: 6px;
    inset-inline-end: 6px;
    background: var(--brand);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 6px;
    z-index: 1;
}

.cw-plp-card__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-block: 1px;
}

.cw-plp-card__title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--ink);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cw-plp-card__meta {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.cw-plp-card__rating,
.cw-plp-card__delivery {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    color: var(--muted);
    line-height: 1;
}
.cw-plp-card__rating svg { width: 13px; height: 13px; color: #D9A441; flex: 0 0 auto; }
.cw-plp-card__delivery svg { width: 13px; height: 13px; flex: 0 0 auto; }
.cw-plp-card__delivery--digikala { color: var(--brand); }
.cw-plp-card__delivery--digikala svg { color: var(--brand); }

.cw-plp-card__prices {
    margin-top: auto;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}
.cw-plp-card__old { font-size: 12px; color: var(--muted); text-decoration: line-through; }
.cw-plp-card__price { font-size: 15px; font-weight: 800; color: var(--ink); }
.cw-plp-card__price-value { display: inline-block; }
.cw-plp-card__price .cw-toman { margin-inline-start: 4px; }
.cw-plp-card__oos {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px 9px;
    line-height: 1.6;
}

/* ===================== desktop / tablet: vertical grid card ===================== */

@media (min-width: 640px) {
    .cw-plp-card { overflow: hidden; height: 100%; }

    .cw-plp-card__link {
        flex-direction: column;
        gap: 0;
        padding: 0;
        height: 100%;
    }

    .cw-plp-card__media {
        width: 100%;
        height: 210px;
        flex: 0 0 210px;
        border-radius: 0;
        background: var(--white);
    }

    .cw-plp-card__body { padding: 10px 12px 12px; gap: 8px; }
    .cw-plp-card__title { font-size: 13.5px; height: calc(13.5px * 1.5 * 2); }
    .cw-plp-card__meta { flex-direction: row; align-items: center; gap: 12px; flex-wrap: wrap; }
}


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

.cw-plp-card__colors {
    top: 8px;
    inset-inline-start: 8px;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}
.cw-plp-card__dot {
    width: 10px;
    height: 10px;
}

.cw-plp-card__meta {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: 18px;
    gap: 8px;
}
.cw-plp-card__rating {
    order: 2;
    margin-inline-start: auto;
}
.cw-plp-card__discount {
    order: 1;
    font-size: 11.5px;
    font-weight: 800;
    color: var(--brand);
    line-height: 1;
}
.cw-plp-card__prices {
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: nowrap;
    width: 100%;
}
.cw-plp-card__old {
    order: 1;
    margin-inline-start: auto;
}
.cw-plp-card__prices > .cw-toman {
    order: 1;
    margin: 0 4px 0 0;
}
.cw-plp-card__price {
    order: 2;
    margin-inline-start: auto;
}

/* Price alignment: discounted price sits immediately to the left of the old price. */
.cw-plp-card__prices {
    direction: rtl;
    justify-content: flex-start;
    align-items: baseline;
    flex-wrap: nowrap;
    width: 100%;
    gap: 8px;
}
.cw-plp-card__old {
    order: 1;
    margin: 0;
}
.cw-plp-card__price {
    order: 2;
    margin: 0;
}

/* ===================== final mobile product-card layout ===================== */
.cw-plp-card__colors-more {
    display: none;
    width: 12px;
    height: 10px;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 1px;
}

/* Show only the first five swatches and a compact ellipsis on every layout. */
.cw-plp-card__colors.has-more .cw-plp-card__dot:nth-of-type(n+6) { display: none; }
.cw-plp-card__colors.has-more .cw-plp-card__colors-more { display: inline-flex; }

@media (max-width: 639.98px) {
    .cw-plp-card {
        height: 180px;
        min-height: 180px;
        border: 0;
        border-bottom: 1px solid var(--border);
        border-radius: 0;
        overflow: hidden;
        box-shadow: none;
        background: var(--white);
    }
    .cw-plp-card:hover {
        border-color: var(--border);
        box-shadow: none;
    }

    .cw-plp-card__link {
        height: 100%;
        min-height: 0;
        padding: 10px 0;
        gap: 14px;
        align-items: center;
    }

    /* No artificial image box height/background: image height follows its width/aspect ratio. */
    .cw-plp-card__media {
        flex: 0 0 116px;
        width: 116px;
        height: auto;
        align-self: center;
        border-radius: 0;
        overflow: visible;
        background: transparent;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    .cw-plp-card__media img {
        display: block;
        width: 100%;
        height: auto;
        max-width: 100%;
        object-fit: contain;
        object-position: center;
        background: transparent;
    }

    .cw-plp-card__colors {
        position: static;
        width: 100%;
        margin-top: 8px;
        flex: 0 0 auto;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 4px;
        transform: none;
    }

    .cw-plp-card__body {
        align-self: stretch;
        min-width: 0;
        padding: 0;
        gap: 0;
        justify-content: center;
    }

    /* Title + rating + discount form one vertically centered block beside the image. */
    .cw-plp-card__info {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 7px;
        min-width: 0;
        width: 100%;
    }
    .cw-plp-card__title {
        margin: 0;
        font-size: 12px;
        line-height: 1.6;
        height: auto;
        min-height: calc(12px * 1.6);
        max-height: calc(12px * 1.6 * 2);
        -webkit-line-clamp: 2;
    }

    .cw-plp-card__meta {
        position: relative;
        display: block;
        width: 100%;
        min-height: 18px;
        padding: 0;
    }

    /* Rating is always physically on the left, whether a discount exists or not. */
    .cw-plp-card__rating {
        position: absolute;
        left: 0;
        right: auto;
        top: 50%;
        transform: translateY(-50%);
        display: inline-flex;
        align-items: center;
        gap: 4px;
        margin: 0;
        order: initial;
        font-size: 11.5px;
        color: var(--muted);
    }

    /* Discount, when present, stays on the right of the same meta line. */
    .cw-plp-card__discount {
        display: block;
        width: max-content;
        margin: 0 0 0 auto;
        order: initial;
        font-size: 11.5px;
        font-weight: 800;
        color: var(--brand);
        line-height: 1;
    }

    /* Prices sit below the info block and begin at the physical left. */
    .cw-plp-card__prices {
        margin-top: 12px;
        width: 100%;
        justify-content: flex-start;
        align-items: baseline;
        gap: 8px;
        flex-wrap: nowrap;
        direction: ltr;
    }
    .cw-plp-card__price {
        order: 1;
        margin: 0;
        font-size: 15px;
        font-weight: 800;
    }
    .cw-plp-card__old {
        order: 2;
        margin: 0;
        font-size: 12px;
        color: var(--muted);
        text-decoration: line-through;
    }
}

@media (min-width: 640px) {
    .cw-plp-card__info { display: contents; }
}

/* Precise mobile vertical anchoring: info block centered to the image area, prices below it. */
@media (max-width: 639.98px) {
    .cw-plp-card__body {
        position: relative;
        display: block;
    }
    .cw-plp-card__info {
        position: absolute;
        top: 50%;
        left: 0;
        right: 0;
        transform: translateY(-50%);
    }
    .cw-plp-card__prices {
        position: absolute;
        left: 0;
        right: auto;
        bottom: 0;
        margin-top: 0;
        width: auto;
    }
}


/* ===================== final requested alignment: rating/discount + prices ===================== */
/* Meta row is deliberately LTR so its physical sides are stable on the RTL page:
   discount = left, rating = right. */
.cw-plp-card__meta {
    position: relative;
    display: flex;
    flex-direction: row;
    direction: ltr;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 18px;
    gap: 8px;
}
.cw-plp-card__discount {
    position: static;
    inset: auto;
    transform: none;
    order: 1;
    margin: 0;
    flex: 0 0 auto;
    background: var(--brand);
    color: #fff;
    font-size: 11.5px;
    font-weight: 800;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 7px;
    white-space: nowrap;
}
.cw-plp-card__rating {
    position: static;
    inset: auto;
    transform: none;
    order: 2;
    margin: 0 0 0 auto;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    color: var(--muted);
    white-space: nowrap;
}

/* Price row is also deliberately LTR and anchored to the physical left.
   Exact order: unit image | قیمت اصلی | قیمت قبل تخفیف */
.cw-plp-card__prices {
    display: flex;
    flex-direction: row;
    direction: ltr;
    justify-content: flex-start;
    align-items: baseline;
    flex-wrap: nowrap;
    width: 100%;
    gap: 0;
    overflow: visible;
    text-align: left;
}
.cw-plp-card__price {
    order: 2;
    display: inline-flex;
    flex: 0 0 auto;
    flex-direction: row;
    direction: ltr;
    align-items: baseline;
    gap: 4px;
    margin: 0;
    white-space: nowrap;
}
.cw-plp-card__price-value {
    order: 2;
    white-space: nowrap;
}
.cw-plp-card__old {
    order: 3;
    flex: 0 0 auto;
    margin: 0 0 0 10px;
    white-space: nowrap;
}
@media (max-width: 639.98px) {
    .cw-plp-card__meta {
        direction: ltr;
        justify-content: space-between;
    }
    .cw-plp-card__discount {
        position: static;
        margin: 0;
    }
    .cw-plp-card__rating {
        position: static;
        margin: 0 0 0 auto;
    }
    .cw-plp-card__prices {
        position: absolute;
        left: 0;
        right: auto;
        inset-inline-start: auto;
        inset-inline-end: auto;
        bottom: 0;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        direction: ltr;
        justify-content: flex-start;
        overflow: visible;
        gap: 0;
    }
    .cw-plp-card__price { gap: 3px; }
    .cw-plp-card__prices > .cw-toman { margin-right: 3px; }
    .cw-plp-card__old { margin-left: 9px; font-size: 12px; }
}
