/**
 * Модальное окно быстрого просмотра товара — Дом Рядом
 * Version 3.3.0
 */

/* ============================================================
   ОВЕРЛЕЙ
   ============================================================ */

.domrdm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 99998;
    opacity: 0;
    transition: opacity .25s ease;
    pointer-events: none;
}

.domrdm-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================================
   МОДАЛЬНОЕ ОКНО (общее)
   ============================================================ */

.domrdm-modal {
    position: fixed;
    z-index: 99999;
    background: #fff;
    display: flex;
    flex-direction: column;
    transition: transform .35s cubic-bezier(.32, .72, 0, 1), opacity .25s ease;
    opacity: 0;
    pointer-events: none;
}

.domrdm-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* --- MOBILE: снизу, с прокруткой внутри --- */
@media (max-width: 767px) {
    .domrdm-modal {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 92vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        overflow: hidden;
    }
    .domrdm-modal.is-open {
        transform: translateY(0);
    }
}

/* --- DESKTOP: по центру --- */
@media (min-width: 768px) {
    .domrdm-modal {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -40%);
        width: 90vw;
        max-width: 1000px;
        max-height: 90vh;
        border-radius: 20px;
        overflow: hidden;
    }
    .domrdm-modal.is-open {
        transform: translate(-50%, -50%);
    }
}

/* ============================================================
   КНОПКА ЗАКРЫТИЯ
   ============================================================ */

.domrdm-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(4px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
    transition: background .2s, transform .15s;
}

.domrdm-modal-close:hover {
    background: #fff;
    transform: scale(1.08);
}

/* ============================================================
   ВНУТРЕННЯЯ СТРУКТУРА
   ============================================================ */

.domrdm-modal-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Mobile: вертикально, с прокруткой — похожие оказываются в самом низу */
@media (max-width: 767px) {
    .domrdm-modal-inner {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Desktop: CSS Grid
   col 1 (46%): [галерея] [похожие товары]
   col 2 (1fr): [описание + кнопка, занимает обе строки] */
@media (min-width: 768px) {
    .domrdm-modal-inner {
        display: grid;
        grid-template-columns: 46% 1fr;
        grid-template-rows: auto 1fr;
        overflow-y: auto;
    }
}

/* ===== Анимация плавного появления контента ===== */
.domrdm-modal-left,
.domrdm-modal-right,
.domrdm-modal-related {
    opacity: 0;
    animation: domrdm-modal-fade-in 0.22s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes domrdm-modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================================
   ЛЕВАЯ КОЛОНКА: галерея + похожие
   ============================================================ */

.domrdm-modal-left {
    display: flex;
    flex-direction: column;
    background: #f8f8f8;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .domrdm-modal-left {
        width: 100%;
        flex-shrink: 0;
    }
}

@media (min-width: 768px) {
    .domrdm-modal-left {
        grid-column: 1;
        grid-row: 1;
    }
}

/* ============================================================
   СЛАЙДЕР: фиксированная рамка
   ============================================================ */

.domrdm-gallery-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f2f2f2;
    flex-shrink: 0;
}

.domrdm-gallery-track {
    display: flex;
    height: 100%;
    transition: transform .35s cubic-bezier(.4, 0, .2, 1);
    will-change: transform;
}

.domrdm-gallery-slide {
    min-width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f2f2f2;
}

.domrdm-gallery-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

/* Стрелки слайдера (только десктоп) */
.domrdm-gallery-prev,
.domrdm-gallery-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .9);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
    transition: opacity .2s;
    opacity: 0;
}

.domrdm-gallery-frame:hover .domrdm-gallery-prev,
.domrdm-gallery-frame:hover .domrdm-gallery-next {
    opacity: 1;
}

.domrdm-gallery-prev { left: 10px; }
.domrdm-gallery-next { right: 10px; }

@media (max-width: 767px) {
    .domrdm-gallery-prev,
    .domrdm-gallery-next { display: none; }
}

/* ============================================================
   ТОЧКИ-ИНДИКАТОРЫ
   ============================================================ */

.domrdm-gallery-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 10px 0 6px;
    flex-shrink: 0;
}

.domrdm-gallery-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ccc;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background .2s, transform .2s;
}

.domrdm-gallery-dot.is-active {
    background: #333;
    transform: scale(1.3);
}

/* ============================================================
   ПОХОЖИЕ ТОВАРЫ — всегда последний блок
   ============================================================ */

/* Mobile: полная ширина, в самом низу */
@media (max-width: 767px) {
    .domrdm-modal-related {
        width: 100%;
        flex-shrink: 0;
        padding: 16px 16px 24px;
        border-top: 1px solid #f0f0f0;
        background: #fff;
    }
}

/* Desktop: под галереей (колонка 1, строка 2) */
@media (min-width: 768px) {
    .domrdm-modal-related {
        grid-column: 1;
        grid-row: 2;
        padding: 16px;
        background: #f8f8f8;
        border-top: 1px solid #f0f0f0;
        overflow-y: auto;
    }
}

.domrdm-modal-related-heading {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin: 0 0 12px;
}

.domrdm-modal-related-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

/* ============================================================
   ПРАВАЯ КОЛОНКА: информация о товаре
   ============================================================ */

.domrdm-modal-right {
    display: flex;
    flex-direction: column;
}

/* Mobile: не схлопываться, занимать столько сколько надо */
@media (max-width: 767px) {
    .domrdm-modal-right {
        flex-shrink: 0;
        width: 100%;
    }
}

/* Desktop: CSS Grid — правая колонка на обе строки */
@media (min-width: 768px) {
    .domrdm-modal-right {
        grid-column: 2;
        grid-row: 1 / 3;
        border-left: 1px solid #f0f0f0;
        min-height: 0;
    }
}

.domrdm-modal-summary {
    padding: 20px 20px 8px;
    flex: 1;
}

@media (max-width: 767px) {
    .domrdm-modal-summary {
        padding: 16px 16px 8px;
    }
}

/* --- Заголовок --- */
.domrdm-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.25;
    margin: 0 0 6px;
}

@media (max-width: 767px) {
    .domrdm-modal-title { font-size: 18px; }
}

/* --- Вес --- */
.domrdm-modal-weight {
    font-size: 13px;
    color: #888;
    margin-bottom: 12px;
}

/* --- Вариации --- */
.domrdm-modal-variations {
    margin-bottom: 14px;
}

.domrdm-modal-variations .single_variation_wrap {
    display: none !important;
}

.domrdm-modal-variations .variations select {
    font-size: 13px;
    border-radius: 24px;
    border: 1.5px solid #e0e0e0;
    padding: 6px 28px 6px 12px;
    background: #fff;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23555' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

/* --- Краткое описание --- */
.domrdm-modal-short-desc {
    font-size: 14px;
    color: #555;
    line-height: 1.65;
    margin-bottom: 16px;
}

/* --- Атрибуты --- */
.domrdm-modal-attributes {
    margin: 16px 0;
    background: #f7f8f9;
    border-radius: 14px;
    overflow: hidden;
}

.domrdm-modal-attr-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    font-size: 13.5px;
    border-bottom: 1px solid #efefef;
    gap: 16px;
}

.domrdm-modal-attr-row:last-child {
    border-bottom: none;
}

.domrdm-modal-attr-label {
    color: #777;
    flex-shrink: 0;
    max-width: 48%;
}

.domrdm-modal-attr-value {
    color: #1a1a1a;
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}

/* --- Полное описание --- */
.domrdm-modal-full-desc {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
}

.domrdm-modal-full-desc h2,
.domrdm-modal-full-desc h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 8px;
    color: #1a1a1a;
}

.domrdm-modal-full-desc p {
    font-size: 13.5px;
    color: #555;
    line-height: 1.65;
    margin-bottom: 8px;
}

/* ============================================================
   ФИКСИРОВАННАЯ КНОПКА «В КОРЗИНУ»
   ============================================================ */

.domrdm-modal-footer {
    background: #fff;
    border-top: 1px solid #f0f0f0;
    padding: 12px 16px;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
    width: 100%;
}

.domrdm-modal-footer.is-in-cart {
    padding: 10px 16px;
}

/* Sticky внутри прокручиваемого контейнера — мобайл и десктоп */
.domrdm-modal-footer {
    position: sticky;
    bottom: 0;
}

@media (min-width: 768px) {
    .domrdm-modal-footer {
        border-radius: 0 0 20px 0;
    }
}

.domrdm-modal-footer-price {
    display: flex;
    flex-direction: column;
    justify-content: center;
    white-space: nowrap;
}

.domrdm-modal-footer-price .price-sale {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
}

.domrdm-modal-footer-price .price-old {
    font-size: 13px;
    color: #aaa;
    text-decoration: line-through;
    margin-bottom: 2px;
}

.domrdm-modal-footer-price .price-regular {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
}

.domrdm-modal-footer .product-card-cart-pill {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: 16px 24px;
    font-size: 18px; /* Slightly larger text for the modal */
}

.domrdm-modal-footer .cart-qty-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 54px; /* Slightly taller for the modal */
    background: var(--color-primary, #1F9356);
    border-radius: 50px;
}

.domrdm-modal-footer .cart-qty-btn {
    width: 54px;
    height: 54px;
    font-size: 26px;
    color: #fff;
    background: transparent;
    border: none;
    cursor: pointer;
}

.domrdm-modal-footer .cart-qty-value {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
}

/* WooCommerce hidden qty/button */
.domrdm-modal-summary .cart .qty { display: none !important; }
.domrdm-modal-summary .cart .single_add_to_cart_button { display: none !important; }

/* ============================================================
   SKELETON
   ============================================================ */

@keyframes domrdm-shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.domrdm-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e4e4e4 50%, #f0f0f0 75%);
    background-size: 800px 100%;
    animation: domrdm-shimmer 1.4s infinite linear;
    border-radius: 8px;
}

.domrdm-skeleton-gallery {
    width: 100%;
    aspect-ratio: 1 / 1;
}

.domrdm-skeleton-line {
    height: 16px;
    margin-bottom: 10px;
    border-radius: 6px;
}

.domrdm-skeleton-line.wide   { width: 75%; }
.domrdm-skeleton-line.medium { width: 50%; }
.domrdm-skeleton-line.short  { width: 30%; }
.domrdm-skeleton-line.tall   { height: 24px; }
.domrdm-skeleton-line.price  { height: 28px; width: 40%; }

.domrdm-modal-skeleton {
    display: flex;
    flex: 1;
    overflow: hidden;
}

@media (max-width: 767px) { .domrdm-modal-skeleton { flex-direction: column; } }
@media (min-width: 768px) {
    .domrdm-modal-skeleton {
        flex-direction: row;
        grid-column: 1 / 3;
        grid-row: 1 / 3;
    }
}

.domrdm-skeleton-left {
    flex-shrink: 0;
    padding: 0;
    background: #f8f8f8;
}

@media (max-width: 767px) { .domrdm-skeleton-left { width: 100%; } }
@media (min-width: 768px) { .domrdm-skeleton-left { width: 46%; } }

.domrdm-skeleton-right {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

@media (max-width: 767px) {
    .domrdm-skeleton-right {
        padding: 16px;
    }
}

/* ============================================================
   СТРАНИЦА ТОВАРА (вне модала)
   ============================================================ */

.domrdm-single-product {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.domrdm-extract-gallery { display: none; }

.domrdm-extract-summary { padding: 16px 0; }

.domrdm-product-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.domrdm-product-weight {
    font-size: 14px;
    color: #888;
    margin-bottom: 14px;
}

.domrdm-product-price { margin-bottom: 20px; }

.domrdm-price-sale {
    font-size: 28px;
    font-weight: 700;
    color: #1F9356;
    margin-right: 10px;
}

.domrdm-price-old {
    font-size: 16px;
    color: #aaa;
    text-decoration: line-through;
}

.domrdm-price-regular {
    font-size: 28px;
    font-weight: 700;
}

.domrdm-product-short-desc {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 16px;
}

.domrdm-product-attributes {
    border-top: 1px solid #f0f0f0;
    padding-top: 14px;
}

.domrdm-attr-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    padding: 5px 0;
    gap: 12px;
}

.domrdm-attr-label { color: #888; flex-shrink: 0; }
.domrdm-attr-value { text-align: right; color: #1a1a1a; }

.domrdm-product-full-desc { margin-top: 32px; }

.domrdm-extract-related .products-grid { margin-top: 12px; }

.domrdm-related-heading {
    font-size: 18px;
    font-weight: 700;
    margin-top: 32px;
    margin-bottom: 12px;
}

body.domrdm-modal-open { overflow: hidden; }
