/*
 * Product card with hover panel (product/main_product_forma_3.tpl, .pc-card)
 * Panel is absolutely positioned under the card and slides down over the card below.
 * Cart button and cart-counter styles stay in custom.css.
 */

.pc-card {
    --pc-c1: #1F05B4;
    --pc-c2: #325AFB;
    --pc-grad: linear-gradient(90deg, #1F05B4 0%, #325AFB 100%);
    --pc-tint: linear-gradient(90deg, rgba(31, 5, 180, .06) 0%, rgba(50, 90, 251, .06) 100%);
}

.pc-card [hidden] {
    display: none !important;
}

/* Stacking: open card (30) > closing card (20, .pc-closing from js while panel slides up) > others (1) */
.pc-card {
    z-index: 1;
}

.pc-card.pc-closing {
    z-index: 20;
}

.pc-card .thumbnail {
    position: relative;
}

/* ---------- Main part ---------- */

.pc-card .pc-price-qty {
    font-size: 13px;
    font-weight: 400;
    color: #8a8a8a;
    margin-left: 4px;
    white-space: nowrap;
}

.pc-card .pc-qty-discount {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--pc-grad);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
}

/* ---------- Hover panel (desktop) / bottom sheet (touch) ---------- */

.pc-card .pc-hover {
    background: #fff;
}

.pc-card .pc-hover .caption-action-buttons {
    padding: 0 !important;
}

.pc-card .pc-hover .cart-control {
    margin-bottom: 0;
}

/* Mobile-only parts are hidden on desktop */
.pc-card .pc-sheet-btn,
.pc-card .pc-sheet-backdrop,
.pc-card .pc-sheet-only {
    display: none;
}

@media (hover: hover) {
    .pc-card .pc-hover {
        position: absolute;
        top: 100%;
        left: -1px;
        right: -1px;
        z-index: 5;
        margin-top: -1px;
        padding: 0 20px;
        border: 1px solid rgba(233, 233, 233, 1);
        border-top: none;
        border-radius: 0 0 16px 16px;
        max-height: 0;
        opacity: 0;
        visibility: hidden;
        overflow: hidden;
        transition: max-height .25s ease, opacity .2s ease, padding .25s ease, visibility 0s linear .25s;
    }

    /* Open state */
    .pc-card:hover,
    .pc-card.pc-open {
        z-index: 30;
    }

    .pc-card:hover .thumbnail,
    .pc-card.pc-open .thumbnail {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-bottom-color: transparent;
    }

    .pc-card:hover .pc-hover,
    .pc-card.pc-open .pc-hover {
        max-height: 700px;
        opacity: 1;
        visibility: visible;
        padding: 4px 20px 20px;
        box-shadow: 0 4px 4px rgba(0, 0, 0, .25);
        transition: max-height .3s ease, opacity .2s ease, padding .25s ease, visibility 0s;
    }
}

/* Touch devices: card is static, cart button opens bottom sheet (.pc-sheet-open from js) */
@media (hover: none) {
    .pc-card .thumbnail {
        display: flex;
        flex-direction: column;
    }

    .pc-card .caption-main-part {
        flex: 1 1 auto;
    }

    /* Compact card: less paddings, square photo instead of min-height 200px */
    .pc-card .thumbnail {
        padding: 6px;
        margin-bottom: 10px;
    }

    .pc-card .thumbnail .caption {
        padding: 4px;
    }

    .pc-card .product-image {
        min-height: 0;
        line-height: normal;
        aspect-ratio: 1 / 1;
        justify-content: center;
        margin-bottom: 6px;
    }

    .pc-card .product-image img {
        max-width: 100%;
        max-height: 100%;
    }

    .pc-card .thumbnail .caption .upper-info {
        margin-bottom: 4px;
    }

    .pc-card .thumbnail .caption h5 {
        margin: 4px 0 6px;
    }

    .pc-card .pc-qty-discount {
        margin-top: 4px;
        font-size: 11px;
        white-space: nowrap;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .pc-card .pc-sheet-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        width: auto;
        margin: 6px 4px 4px;
        padding-left: 8px;
        padding-right: 8px;
        white-space: nowrap;
    }

    .pc-card .pc-sheet-btn.pc-in-cart {
        background: #4CAF50;
    }

    .pc-card .pc-sheet-btn-arrow {
        margin-left: 2px;
    }

    .pc-card .pc-hover {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        /* above own card elements (labels, wishlist z-index 10) */
        z-index: 1001;
        max-height: 85vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, .15);
        transform: translateY(100%);
        visibility: hidden;
        transition: transform .3s ease, visibility 0s linear .3s;
    }

    .pc-card .pc-sheet-backdrop {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1000;
        background: rgba(0, 0, 0, .45);
        opacity: 0;
        visibility: hidden;
        transition: opacity .3s ease, visibility 0s linear .3s;
    }

    /* .pc-sheet-closing (js) keeps card above others until backdrop faded out */
    .pc-card.pc-sheet-open,
    .pc-card.pc-sheet-closing {
        z-index: 100000;
    }

    .pc-card.pc-sheet-open .pc-hover {
        transform: none;
        visibility: visible;
        transition: transform .3s ease, visibility 0s;
    }

    .pc-card.pc-sheet-open .pc-sheet-backdrop {
        opacity: 1;
        visibility: visible;
        transition: opacity .3s ease, visibility 0s;
    }

    .pc-card .pc-sheet-only {
        display: block;
    }

    /* Cards without cart (out of stock etc.): panel stays inside card */
    .pc-card.pc-nooffer .pc-sheet-btn,
    .pc-card.pc-nooffer .pc-sheet-backdrop,
    .pc-card.pc-nooffer .pc-sheet-only {
        display: none;
    }

    .pc-card.pc-nooffer .pc-hover {
        position: static;
        transform: none;
        visibility: visible;
        max-height: none;
        padding: 0 10px 10px;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
    }
}

/* Page under sheet does not scroll: body is fixed at current scroll position (js) */
html.pc-sheet-lock,
body.pc-sheet-lock {
    overflow: hidden;
}

body.pc-sheet-lock {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
}

/* ---------- Bottom sheet parts ---------- */

.pc-card .pc-sheet-head {
    position: relative;
    padding: 10px 32px 4px 0;
    margin-bottom: 12px;
}

.pc-card .pc-sheet-handle {
    display: block;
    width: 40px;
    height: 4px;
    margin: 0 auto 12px;
    border-radius: 2px;
    background: #d9d9d9;
}

.pc-card .pc-sheet-title {
    font-size: 18px;
    font-weight: 600;
    color: rgba(64, 64, 64, 1);
}

.pc-card .pc-sheet-name {
    margin-top: 4px;
    font-size: 13px;
    color: #8a8a8a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pc-card .pc-sheet-close {
    position: absolute;
    top: 18px;
    right: -6px;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    font-size: 28px;
    line-height: 1;
    color: #8a8a8a;
    cursor: pointer;
}

/* Secondary brand button: gradient border and gradient text */
.pc-card a.pc-sheet-goto {
    margin-top: 10px;
    padding: 11px 12px;
    text-align: center;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    line-height: 20px;
    text-decoration: none;
    background: var(--pc-tint) padding-box, linear-gradient(#fff, #fff) padding-box, var(--pc-grad) border-box;
}

.pc-card a.pc-sheet-goto span {
    background: var(--pc-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.pc-card .pc-block-title {
    font-size: 12px;
    color: #8a8a8a;
    margin-bottom: 6px;
}

/* ---------- Subtypes: groups by characteristic (Размер / Цвет or category titles) ---------- */

.pc-card .pc-variants {
    margin-bottom: 12px;
}

.pc-card .pc-variant-group + .pc-variant-group {
    margin-top: 10px;
}

.pc-card .pc-variant-current {
    color: rgba(64, 64, 64, 1);
    font-weight: 500;
}

.pc-card .pc-variant-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pc-card .pc-variant-opt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 5px 10px;
    border: 1px solid rgba(233, 233, 233, 1);
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    font-weight: 400;
    line-height: 18px;
    color: rgba(64, 64, 64, 1);
    cursor: pointer;
    transition: border-color .2s, background .2s, opacity .2s;
}

.pc-card .pc-variant-opt:hover {
    border-color: rgba(50, 90, 251, .5);
}

.pc-card .pc-variant-opt.is-checked {
    border-color: transparent;
    background: var(--pc-tint) padding-box, linear-gradient(#fff, #fff) padding-box, var(--pc-grad) border-box;
    color: var(--pc-c1);
}

/* no subtype with this value and current value of other characteristic: click switches both */
.pc-card .pc-variant-opt.is-dim {
    opacity: .5;
}

.pc-card .pc-variant-opt.is-disabled {
    cursor: default;
    color: #bbb;
    text-decoration: line-through;
    border-color: rgba(233, 233, 233, 1);
    background: none;
    opacity: 1;
}

.pc-card .pc-variant-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, .1);
}

/* ---------- Quantity tiers (package-options) ---------- */

.pc-card .package-options {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
}

.pc-card .package-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0;
    padding: 7px 10px;
    border: 1px solid rgba(233, 233, 233, 1);
    border-radius: 8px;
    font-weight: 400;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}

.pc-card .package-option:hover {
    border-color: rgba(50, 90, 251, .5);
}

.pc-card .package-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.pc-card .package-option .left-side {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pc-card .package-radio {
    position: relative;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    border: 2px solid #c8c8c8;
    border-radius: 50%;
    transition: border-color .2s;
}

/* gradient ring, overrides .blue-cycle background from custom.css */
.pc-card .package-option.pc-active .package-radio {
    border-color: transparent;
    background: linear-gradient(#fff, #fff) padding-box, var(--pc-grad) border-box;
}

.pc-card .package-option.pc-active .package-radio::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pc-grad);
    opacity: 1;
}

.pc-card .package-price {
    font-size: 14px;
    font-weight: 600;
    color: rgba(64, 64, 64, 1);
}

.pc-card .package-qty {
    font-size: 12px;
    color: #8a8a8a;
    white-space: nowrap;
}

/* gradient border with light tint inside */
.pc-card .package-option.pc-active {
    border-color: transparent;
    background: var(--pc-tint) padding-box, linear-gradient(#fff, #fff) padding-box, var(--pc-grad) border-box;
}

.pc-card .package-option.pc-active .package-price,
.pc-card .package-option.pc-active .package-qty {
    background: var(--pc-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ---------- Sum and benefit ---------- */

.pc-card .pc-summary {
    margin-bottom: 12px;
    font-size: 13px;
    color: rgba(64, 64, 64, 1);
}

.pc-card .pc-summary-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.pc-card .pc-summary-row + .pc-summary-row {
    margin-top: 2px;
}

.pc-card .pc-sum {
    font-size: 15px;
}

.pc-card .pc-benefit-row b {
    color: #2e9e4f;
}

/* ---------- Manual quantity input ---------- */

.pc-card .cart-counter .counter-input {
    pointer-events: auto;
    cursor: text;
}

/* ---------- Equal card height in a row ---------- */
/* .pc-grid is added by product-card.js, :has() works before js */

.template-product-list:has(> .pc-card),
.pc-grid {
    display: flex;
    flex-wrap: wrap;
}

.template-product-list:has(> .pc-card)::before,
.template-product-list:has(> .pc-card)::after,
.pc-grid::before,
.pc-grid::after {
    content: none;
}

.pc-card {
    display: flex;
    float: none;
}

.pc-card > .thumbnail {
    flex: 1 1 auto;
    width: 100%;
}

/* ---------- In cart badge on photo ---------- */

.pc-card .pc-in-cart-badge {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 9;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 12px;
    background: #4CAF50;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
    pointer-events: none;
}

/* Index page blocks (specMain etc.) use .row.thumbnail-row as grid container */
.thumbnail-row:has(> .pc-card) {
    display: flex;
    flex-wrap: wrap;
}

.thumbnail-row:has(> .pc-card)::before,
.thumbnail-row:has(> .pc-card)::after {
    content: none;
}

/* ---------- List view (main_product_forma_1.tpl, .pc-list) ---------- */
/* Row: photo | info | purchase panel (always open on desktop, bottom sheet on touch) */

.pc-card.pc-list .caption-main-part {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    column-gap: 20px;
    align-content: start;
}

.pc-card.pc-list .caption-main-part > * {
    grid-column: 2;
}

.pc-card.pc-list .caption-main-part > .product-image {
    grid-column: 1;
    grid-row: 1 / span 8;
    margin-bottom: 0;
}

.pc-card .pc-list-desc {
    margin: 0 0 8px;
    font-size: 13px;
    color: #666;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (hover: hover) {
    .pc-card.pc-list .thumbnail {
        display: flex;
        align-items: stretch;
        gap: 20px;
    }

    .pc-card.pc-list .caption-main-part {
        flex: 1 1 auto;
    }

    .pc-card.pc-list .pc-hover,
    .pc-card.pc-list:hover .pc-hover,
    .pc-card.pc-list.pc-open .pc-hover {
        position: static;
        flex: 0 0 320px;
        width: 320px;
        max-height: none;
        opacity: 1;
        visibility: visible;
        overflow: visible;
        margin: 0;
        padding: 10px 10px 10px 20px;
        border: none;
        border-left: 1px solid rgba(233, 233, 233, 1);
        border-radius: 0;
        box-shadow: none;
        transition: none;
    }

    .pc-card.pc-list:hover .thumbnail,
    .pc-card.pc-list.pc-open .thumbnail {
        border-radius: 16px;
        border-bottom-color: rgba(233, 233, 233, 1);
    }
}

@media (hover: none) {
    .pc-card.pc-list .caption-main-part {
        grid-template-columns: 110px minmax(0, 1fr);
        column-gap: 12px;
    }

    .pc-card.pc-list .product-image {
        aspect-ratio: 1 / 1;
    }
}

.pc-card.pc-list .caption-main-part > .pc-qty-discount {
    justify-self: start;
}

/* ---------- Minimum order note (wholesale module) ---------- */

.pc-card .pc-min-note {
    margin-bottom: 10px;
    font-size: 12px;
    color: #8a8a8a;
}

.pc-card .pc-min-note b {
    color: rgba(64, 64, 64, 1);
    font-weight: 600;
}
