/*
 * Product archive follow-up fixes.
 *
 * Product-card selectors are scoped to `.kaman-archive`, so the separate
 * product-card component used by product carousels is not affected.
 */

@media (min-width: 1025px) {
    /* Brand filter alignment from the desktop Figma filter component. */
    .kaman-filter-panel__content--brand .kaman-filter-panel__options {
        width: 100%;
    }

    .kaman-filter-panel__content--brand .kaman-filter-panel__option {
        width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "latin main";
        align-items: center;
        column-gap: 8px;
        direction: ltr;
    }

    .kaman-filter-panel__content--brand .kaman-filter-panel__option[hidden] {
        display: none !important;
    }

    .kaman-filter-panel__content--brand .kaman-filter-panel__brand-main {
        grid-area: main;
        justify-self: end;
        min-width: 0;
        margin: 0;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        direction: ltr;
    }

    .kaman-filter-panel__content--brand .kaman-filter-panel__brand-main > span {
        min-width: 0;
        direction: rtl;
        text-align: right;
    }

    .kaman-filter-panel__content--brand .kaman-filter-panel__brand-main input[type="checkbox"] {
        flex: 0 0 16px;
        margin: 0;
    }

    .kaman-filter-panel__content--brand .kaman-filter-panel__brand-latin {
        grid-area: latin;
        justify-self: start;
        min-width: 0;
        margin: 0;
        direction: ltr;
        text-align: left;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Desktop archive toolbar — Figma Shop node 3663:4872. */
    .kaman-archive .kaman-archive__toolbar {
        width: 100%;
        min-height: 61px;
        margin: 0;
        padding: 20px 0;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 24px;
        direction: ltr;
        background: #ffffff;
        border: 0;
        border-bottom: 1px solid var(--kaman-color-border, #ebebeb);
        border-radius: 0;
        box-shadow: none;
        flex-direction: row;
    }

    .kaman-archive .kaman-archive__count {
        margin: 0;
        padding: 0;
        color: var(--kaman-color-text-secondary, #696969);
        background: transparent;
        border: 0;
        font-family: var(--kaman-font-family, "Dana2", "Dana", sans-serif);
        font-size: 12px;
        font-weight: 400;
        line-height: 1;
        direction: rtl;
        white-space: nowrap;
    }

    .kaman-archive .kaman-archive__sort {
        margin: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 20px;
        direction: rtl;
        background: transparent;
        border: 0;
    }

    .kaman-archive .kaman-archive__sort-label {
        min-width: 94px;
        margin: 0 0 0 40px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        color: transparent;
        font-size: 0;
        font-weight: 500;
        line-height: 1;
        white-space: nowrap;
        flex-direction: row-reverse;
    }

    .kaman-archive .kaman-archive__sort-label::before {
        content: "مرتب سازی:";
        color: var(--kaman-color-text-secondary, #696969);
        font-family: var(--kaman-font-family, "Dana2", "Dana", sans-serif);
        font-size: 14px;
        font-weight: 500;
        line-height: 1;
    }

    .kaman-archive .kaman-archive__sort-label::after {
        content: "\f550";
        width: 18px;
        height: 18px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: var(--kaman-color-text-secondary, #696969);
        font-family: "Font Awesome 5 Free";
        font-size: 14px;
        font-weight: 900;
        line-height: 1;
    }

    .kaman-archive .kaman-archive__sort-btn {
        min-width: 0;
        min-height: 0;
        margin: 0;
        padding: 0;
        color: var(--kaman-color-text-secondary, #696969);
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        font-family: var(--kaman-font-family, "Dana2", "Dana", sans-serif);
        font-size: 14px;
        font-weight: 500;
        line-height: 1;
        text-decoration: none;
        white-space: nowrap;
    }

    .kaman-archive .kaman-archive__sort-btn:hover,
    .kaman-archive .kaman-archive__sort-btn:focus-visible,
    .kaman-archive .kaman-archive__sort-btn.is-active {
        color: var(--kaman-color-primary, #aa0002);
        background: transparent;
        border: 0;
        box-shadow: none;
    }

    /* Keep the working query keys while matching the Figma wording. */
    .kaman-archive .kaman-archive__sort-btn[href*="sort=highest-price"],
    .kaman-archive .kaman-archive__sort-btn[href*="sort=lowest-price"] {
        font-size: 0;
    }

    .kaman-archive .kaman-archive__sort-btn[href*="sort=highest-price"]::before {
        content: "گران ترین";
        font-size: 14px;
    }

    .kaman-archive .kaman-archive__sort-btn[href*="sort=lowest-price"]::before {
        content: "ارزان ترین";
        font-size: 14px;
    }

    /* Desktop archive grid — Figma Shop row node 3664:14844. */
    .kaman-archive .kaman-archive__grid {
        width: 100%;
        margin: 20px 0 0;
        padding: 0;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0;
        align-items: stretch;
        background: #ffffff;
        border-top: 1px solid var(--kaman-color-border, #ebebeb);
        border-right: 1px solid var(--kaman-color-border, #ebebeb);
    }

    .kaman-archive .kaman-archive-card,
    .kaman-archive .kaman-archive-card:has(> .kaman-archive-card__badge) {
        position: relative;
        width: auto;
        height: 417px;
        min-height: 417px;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        display: block;
        overflow: hidden;
        background: #ffffff;
        border: 0;
        border-left: 1px solid var(--kaman-color-border, #ebebeb);
        border-bottom: 1px solid var(--kaman-color-border, #ebebeb);
        border-radius: 0;
        box-shadow: none;
        opacity: 1;
    }

    .kaman-archive .kaman-archive-card__badge {
        display: none !important;
    }

    .kaman-archive .kaman-archive-card__media {
        position: absolute;
        top: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 235px;
        min-height: 235px;
        margin: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        background: #ffffff;
        border: 0;
        border-radius: 0;
    }

    .kaman-archive .kaman-archive-card__image {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    .kaman-archive .kaman-archive-card__image img {
        width: 169px;
        height: 169px;
        max-width: 169px;
        max-height: 169px;
        margin: 0;
        padding: 0;
        display: block;
        object-fit: contain;
        mix-blend-mode: normal;
        transform: translateY(13px);
    }

    .kaman-archive .kaman-archive-card__countdown {
        position: absolute;
        top: 8px;
        right: auto;
        left: 8px;
        z-index: 3;
        width: auto;
        min-width: 0;
        margin: 0;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: flex-start;
        gap: 4px;
        direction: ltr;
        color: var(--kaman-color-danger, #dc2626);
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        font-family: var(--kaman-font-family, "Dana2", "Dana", sans-serif);
        font-size: 12px;
        font-weight: 400;
        line-height: 16px;
        white-space: nowrap;
    }

    .kaman-archive .kaman-archive-card__countdown::before {
        content: "\f017";
        width: 16px;
        height: 16px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-family: "Font Awesome 5 Free";
        font-size: 14px;
        font-weight: 400;
        line-height: 1;
    }

    .kaman-archive .kaman-archive-card__colors {
        display: none !important;
    }

    .kaman-archive .kaman-archive-card__title,
    .kaman-archive .kaman-archive-card:has(> .kaman-archive-card__badge) .kaman-archive-card__title {
        position: absolute;
        top: 267px;
        right: 12px;
        left: 12px;
        width: auto;
        height: 63px;
        min-height: 63px;
        margin: 0;
        padding: 0;
        color: var(--kaman-color-text-secondary, #696969);
        font-family: var(--kaman-font-family, "Dana2", "Dana", sans-serif);
        font-size: 14px;
        font-weight: 500;
        line-height: 21px;
        text-align: right;
        direction: rtl;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .kaman-archive .kaman-archive-card__title a,
    .kaman-archive .kaman-archive-card__title a:hover,
    .kaman-archive .kaman-archive-card__title a:focus {
        color: inherit;
        text-decoration: none;
    }

    .kaman-archive article.kaman-archive-card > .kaman-archive__price,
    .kaman-archive .kaman-archive-card:has(> .kaman-archive-card__badge) > .kaman-archive__price {
        position: absolute;
        right: 12px;
        bottom: 12px;
        left: 12px;
        width: auto;
        height: auto;
        min-height: 28px;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-end;
        gap: 4px;
        overflow: visible;
    }

    .kaman-archive .kaman-archive-card__old {
        width: 100%;
        min-height: 23px;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 4px;
        direction: ltr;
    }

    .kaman-archive .kaman-archive-card__old-price {
        margin: 0;
        padding: 0;
        color: var(--kaman-color-text-muted, #898989);
        font-family: var(--kaman-font-family, "Dana2", "Dana", sans-serif);
        font-size: 14px;
        font-weight: 400;
        line-height: 1;
        direction: rtl;
        text-decoration: line-through;
        white-space: nowrap;
    }

    .kaman-archive .kaman-archive-card__old-price::after {
        content: " تومان";
        color: inherit;
        font-size: 12px;
        font-weight: 400;
        text-decoration: none;
    }

    .kaman-archive .kaman-archive-card__percent {
        min-width: 55px;
        min-height: 23px;
        padding: 4px 16px;
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: #ffffff;
        background: var(--kaman-color-danger, #dc2626);
        border-radius: 24px;
        font-family: var(--kaman-font-family, "Dana2", "Dana", sans-serif);
        font-size: 12px;
        font-weight: 400;
        line-height: 15px;
        white-space: nowrap;
    }

    .kaman-archive .kaman-archive-card__price-row {
        width: 100%;
        margin: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        direction: ltr;
    }

    .kaman-archive .kaman-archive-card__price {
        width: auto;
        margin: 0;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 4px;
        direction: rtl;
        white-space: nowrap;
    }

    .kaman-archive .kaman-archive-card__price span {
        color: #282828;
        font-family: var(--kaman-font-family, "Dana2", "Dana", sans-serif);
        font-size: 18px;
        font-weight: 700;
        line-height: 28px;
    }

    .kaman-archive .kaman-archive-card__price small {
        color: var(--kaman-color-text-muted, #898989);
        font-family: var(--kaman-font-family, "Dana2", "Dana", sans-serif);
        font-size: 12px;
        font-weight: 400;
        line-height: 18px;
    }

    .kaman-archive .kaman-archive-card__status {
        margin-top: auto;
        color: var(--kaman-color-danger, #dc2626);
        font-family: var(--kaman-font-family, "Dana2", "Dana", sans-serif);
        font-size: 14px;
        font-weight: 500;
        line-height: 28px;
        text-align: right;
    }
}

/* Keep the mobile toolbar geometry stable before its JS controls are attached. */
@media (max-width: 1024px) {
    body.kaman-mobile-catalog-ready .kaman-archive .kaman-archive__toolbar {
        min-height: 92px;
    }

    body.kaman-mobile-catalog-ready .kaman-archive .kaman-archive__count {
        margin-top: auto;
    }

    body.kaman-mobile-catalog-ready .kaman-archive .kaman-archive__filters-trigger {
        visibility: hidden;
    }

    body.kaman-mobile-catalog-ready .kaman-archive .kaman-archive__mobile-controls .kaman-archive__filters-trigger {
        visibility: visible;
    }
}

@media (min-width: 1025px) and (max-width: 1439px) {
    .kaman-archive .kaman-archive__grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
