/* product-modal.css */

.product-modal {
    position: fixed;
    inset: 0;
    z-index: 1100; /* выше bootstrap offcanvas */
    display: none;
    align-items: stretch;
    justify-content: center;
    font-family: inherit;
    overflow: hidden;
}

.product-modal--open {
    display: flex;
}

.product-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.product-modal__dialog {
    position: relative;
    margin: 24px auto;
    width: 100%;
    max-width: 1200px;
    background: #fdfaf5;
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
    padding: 24px 32px 32px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0; /* важно для flex-скролла */
}

.product-modal__back {
    align-self: flex-start;
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 8px;
    font-size: 14px;
    color: #64748b;
    cursor: pointer;
    flex-shrink: 0;
}

.product-modal__back:hover {
  text-decoration: none;
}

.product-modal__close {
    position: absolute;
    top: 18px;
    right: 22px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    flex-shrink: 0;
    color: #64748b;
}

.product-modal__close:hover {
    color: #1e293b;
}

.product-modal__content {
    display: grid;
    grid-template-columns: minmax(0, 480px) minmax(0, 1fr);
    gap: 32px;
    align-items: flex-start;
    min-height: 0;
}

.product-modal__image-col {
    border-radius: 16px;
    overflow: hidden;
    flex-shrink: 0;
}

.product-modal__image {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 520px;
    object-fit: cover;
}

.product-modal__info-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    min-width: 0;
}

.product-modal__title {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    flex-shrink: 0;
}

.product-modal__sku {
    font-size: 13px;
    color: #94a3b8;
    flex-shrink: 0;
}

.product-modal__price-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 4px;
    flex-shrink: 0;
}

.product-modal__price {
    font-size: 20px;
    font-weight: 600;
}

.product-modal__unit {
    font-size: 14px;
    color: #94a3b8;
}

/* блок с − 1 + и кнопкой */
.product-modal__controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 12px 0 8px;
    flex-shrink: 0;
}

.product-modal__btn-add {
    min-width: 160px;
}

/* описание — прокручиваемая область на десктопе не нужна, на мобиле — внутри скролла диалога */
.product-modal__desc {
    font-size: 14px;
    line-height: 1.6;
    color: #1e293b;
    min-height: 0;
}

/* блокируем скролл когда модалка открыта */
html.is-modal-open,
html.is-modal-open body {
    overflow: hidden;
    touch-action: none;
}

/* ——— АДАПТИВ: мобильные — скролл всего диалога ——— */
@media (max-width: 992px) {
    .product-modal {
        align-items: flex-end;
        padding: 0;
    }

    .product-modal__dialog {
        margin: 0;
        max-height: 96vh;
        max-height: 96dvh;
        border-radius: 20px 20px 0 0;
        padding: 16px 16px 24px;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        flex: 0 1 auto;
        width: 100%;
    }

    .product-modal__content {
        grid-template-columns: minmax(0, 1fr);
        min-height: auto;
    }

    .product-modal__image-col {
        max-height: 280px;
        flex-shrink: 0;
    }

    .product-modal__image {
        max-height: 280px;
    }

    .product-modal__info-col {
        min-height: auto;
    }

    .product-modal__desc {
        padding-bottom: env(safe-area-inset-bottom, 16px);
    }

    .product-modal__back {
        padding: 8px 0;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .product-modal__close {
        top: 12px;
        right: 12px;
    }
}

/* очень маленькие экраны */
@media (max-width: 480px) {
    .product-modal__dialog {
        max-height: 98vh;
        max-height: 98dvh;
        padding: 12px 12px 20px;
    }

    .product-modal__title {
        font-size: 20px;
    }

    .product-modal__price {
        font-size: 18px;
    }

    .product-modal__controls {
        flex-wrap: wrap;
    }

    .product-modal__btn-add {
        min-width: 100%;
    }
}
