/* Затемнённый фон карточки товара */
#productModal.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

#productModal.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Белый контейнер pop-up */
#productModal .modal-container {
    position: relative;
    width: min(960px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    border-radius: 16px;
    background: #fff;
    overflow-y: auto;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.3);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s ease;
}

#productModal.active .modal-container {
    transform: translateY(0) scale(1);
}

#productModal .modal-content {
    width: 100%;
    max-width: none;
    padding: 32px;
    box-sizing: border-box;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transform: none;
    transition: none;
}

/* Кнопка закрытия */
#productModal .modal-close {
    position: absolute;
    z-index: 20;
    top: 14px;
    right: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.94);
    color: #172b4d;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.16);
    transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

#productModal .modal-close:hover {
    color: #ee3547;
    background: #fff;
    transform: rotate(90deg);
}

#productModal .modal-close:focus-visible,
.product-popup__cart:focus-visible {
    outline: 3px solid rgba(238, 53, 71, 0.35);
    outline-offset: 3px;
}

/* Загрузка и ошибка запроса */
#productModal .modal-loading,
#productModal .modal-error {
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
}

#productModal .modal-loading {
    color: #6d7078;
}

#productModal .modal-error {
    color: #ee3547;
}

#productModal .modal-loading p,
#productModal .modal-error p {
    margin: 0;
}

#productModal .modal-error i {
    margin-bottom: 12px;
    font-size: 42px;
}

#productModal .spinner {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    border: 4px solid #edf0f4;
    border-top-color: #ee3547;
    border-radius: 50%;
    animation: product-popup-spin 0.8s linear infinite;
}

@keyframes product-popup-spin {
    to {
        transform: rotate(360deg);
    }
}

.product-popup {
    display: grid;
    grid-template-columns: minmax(270px, 42%) minmax(0, 1fr);
    gap: clamp(28px, 4vw, 44px);
    width: 100%;
}

.product-popup__visual {
    position: relative;
    min-height: 520px;
    display: flex;
    align-items: stretch;
    overflow: hidden;
    border: 1px solid #edf0f4;
    border-radius: 10px;
    background: #fff;
}

.product-popup__image {
    width: 100%;
    height: 100%;
    display: block;
    padding: 18px;
    box-sizing: border-box;
    object-fit: contain;
    transition: transform 0.35s ease;
}

.product-popup__image-button {
    flex: 1;
    min-width: 0;
    min-height: inherit;
    display: flex;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: transparent;
    cursor: zoom-in;
}

.product-popup__image-button:hover .product-popup__image,
.product-popup__image-button:focus-visible .product-popup__image {
    transform: scale(1.08);
}

.product-popup__image-button:focus-visible {
    outline: 3px solid rgba(238, 53, 71, 0.35);
    outline-offset: -3px;
}

.product-popup__placeholder {
    width: 100%;
    min-height: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    color: #9aa2ad;
    text-align: center;
}

.product-popup__placeholder i {
    font-size: 54px;
}

.product-popup__availability {
    position: absolute;
    z-index: 1;
    top: 16px;
    left: 16px;
    padding: 9px 16px;
    border-radius: 18px;
    background: #ee3547;
    color: white;
    font-size: 13px;
    font-weight: 700;
}

.product-popup__body {
    display: flex;
    min-width: 0;
    flex-direction: column;
    padding: 2px 0;
}

.product-popup__category {
    margin-bottom: 12px;
    color: #ee3547;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.product-popup__title {
    margin: 0 0 18px;
    color: #172b4d;
    font-size: 32px;
    line-height: 1.15;
}

.product-popup__description {
    color: #6d7078;
    font-size: 16px;
    line-height: 1.6;
}

.product-popup__description p {
    margin: 0 0 10px;
}

.product-popup__specs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 28px;
    margin-top: auto;
    margin-bottom: 24px;
}

.popup-spec {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 12px;
}

.popup-spec__icon {
    margin-top: 2px;
    color: #ee3547;
    font-size: 22px;
    line-height: 1;
}

.popup-spec__name {
    color: #435675;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
}

.popup-spec__value {
    margin-top: 5px;
    color: #6d7078;
    font-size: 15px;
    line-height: 1.4;
}

.product-popup__footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-top: 0;
    padding-top: 26px;
    border-top: 1px solid #eceef1;
}

.product-popup__price-label {
    margin-bottom: 5px;
    color: #90949c;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.product-popup__price {
    color: #ee3547;
    font-size: 30px;
    font-weight: 800;
}

.product-popup__cart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 48px;
    padding: 0 24px;
    border: 0;
    border-radius: 13px;
    background: #ee3547;
    color: white;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(238, 53, 71, 0.2);
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.product-popup__cart:hover {
    background: #d9283b;
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(238, 53, 71, 0.28);
}

/* Полноэкранный просмотр изображения */
.product-image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: rgba(7, 12, 22, 0.88);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.product-image-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.product-image-lightbox__image {
    display: block;
    max-width: min(1100px, calc(100vw - 80px));
    max-height: calc(100vh - 80px);
    object-fit: contain;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
    transform: scale(0.96);
    transition: transform 0.25s ease;
}

.product-image-lightbox.active .product-image-lightbox__image {
    transform: scale(1);
}

.product-image-lightbox__close {
    position: fixed;
    z-index: 1;
    top: 22px;
    right: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #172b4d;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    transition: color 0.2s ease, transform 0.2s ease;
}

.product-image-lightbox__close:hover {
    color: #ee3547;
    transform: rotate(90deg);
}

@media (max-width: 600px) {
    #productModal.modal-overlay {
        align-items: flex-start;
        padding: 10px;
    }

    #productModal .modal-container {
        width: 100%;
        max-height: calc(100vh - 20px);
        border-radius: 13px;
    }

    #productModal .modal-content {
        padding: 18px;
    }

    #productModal .modal-close {
        top: 12px;
        right: 12px;
    }

    .product-popup {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .product-popup__visual,
    .product-popup__placeholder {
        min-height: 280px;
    }

    .product-popup__visual {
        max-height: 420px;
    }

    .product-popup__image {
        max-height: 420px;
    }

    .product-image-lightbox {
        padding: 16px;
    }

    .product-image-lightbox__image {
        max-width: calc(100vw - 32px);
        max-height: calc(100vh - 64px);
    }

    .product-image-lightbox__close {
        top: 12px;
        right: 12px;
    }

    .product-popup__category {
        padding-right: 42px;
        font-size: 11px;
    }

    .product-popup__title {
        margin-bottom: 14px;
        font-size: 26px;
    }

    .product-popup__description {
        font-size: 15px;
    }

    .product-popup__specs {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .product-popup__footer {
        align-items: stretch;
        flex-direction: column;
    }

    .product-popup__cart {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    #productModal.modal-overlay,
    #productModal .modal-container,
    #productModal .modal-close,
    .product-popup__cart,
    .product-popup__image,
    .product-image-lightbox,
    .product-image-lightbox__image,
    .product-image-lightbox__close {
        transition: none;
    }
}