/* ============================================================
   Smakuly_2cherga_8pidiznii — стилі плану
   Базові стилі взяті з прикладу Smakylu2_4cherga.
   Додано: правильне позиціювання оверлеїв (без зміщення),
   підтримка двох веж і однієї спільної вспливайки.
   ============================================================ */

.page-wrapper.smakuly-2-cherga-8 {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center;
    background: unset;
}

.page-wrapper.smakuly-2-cherga-8 .title_h1 {
    text-align: center;
    font-size: 40px;
    margin-top: 50px;
}

/* ============================================================
   ОДНА ВЕЖА
   ============================================================ */

.page-wrapper.smakuly-2-cherga-8 .tower-block {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 40px;
    padding-top: 30px;
}

.page-wrapper.smakuly-2-cherga-8 .tower-block + .tower-block {
    border-top: 1px solid #eee;
}

.page-wrapper.smakuly-2-cherga-8 .tower-title {
    font-size: 28px;
    font-weight: bold;
    margin: 0 0 20px;
    text-align: center;
    color: #333;
}

/* -------------------------------------------------------- */
/* МАПА (план поверху + накладки)                             */
/* -------------------------------------------------------- */

.page-wrapper.smakuly-2-cherga-8 .map-wrapper {
    position: relative;             /* offset parent for overlays */
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;                     /* НЕМАЄ паддінгу — щоб оверлеї точно збігались */
    box-sizing: border-box;
}

.page-wrapper.smakuly-2-cherga-8 .map-wrapper .mapper {
    display: block;
    width: 100%;
    height: auto;
    position: relative;
    z-index: 1;
}

/* Hover поверх квартири — підсвічує floor-flat-X.png */
.page-wrapper.smakuly-2-cherga-8 .map-wrapper .flat-hover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    pointer-events: none;
    z-index: 3;
    display: none;
}

/* Філтр-оверлей (Смарт / Однокімнатні / Двохкімнатні) */
.page-wrapper.smakuly-2-cherga-8 .map-wrapper .filter-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    pointer-events: none;
    z-index: 2;
    display: none;
}

/* -------------------------------------------------------- */
/* КНОПКИ ПІД ПЛАНОМ                                          */
/* -------------------------------------------------------- */

.page-wrapper.smakuly-2-cherga-8 .buttons-wrapp {
    margin-top: 40px;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
}

.page-wrapper.smakuly-2-cherga-8 .buttons-wrapp button {
    display: flex;
    justify-content: center;
    align-items: center;
    grid-column-gap: 12px;
    padding: 18px 36px;
    border-radius: 8px;
    background-color: #394553;
    font-family: Unbounded, sans-serif;
    font-size: 12px;
    font-weight: 300;
    line-height: 1;
    text-transform: uppercase;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: 0.3s;
    box-shadow: -3px 4px 29px 0px rgba(57, 69, 83, 0.3);
}

.page-wrapper.smakuly-2-cherga-8 .buttons-wrapp button:hover {
    background-color: #EC784D;
}

/* ============================================================
   POPUP
   ============================================================ */

.page-wrapper.smakuly-2-cherga-8 .popup-wrapp {
    box-sizing: border-box;
    position: absolute;
    z-index: 10;
    display: none;
    flex-direction: column;
    align-items: center;
    grid-row-gap: 20px;
    width: 90%;
    max-width: 800px;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
}

.page-wrapper.smakuly-2-cherga-8 .popup-wrapp .popup_content {
    background-color: #fff;
    z-index: 1;
    padding: 25px;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    clip-path: polygon(88% 0, 100% 12%, 100% 100%, 0 100%, 0 0);
}

.page-wrapper.smakuly-2-cherga-8 .popup-wrapp:before {
    content: "";
    box-shadow: 0 20px 80px 0 rgba(57, 69, 83, 0.5);
    display: block;
    width: 80%;
    height: 80%;
    position: absolute;
    left: 10%;
    top: 10%;
    z-index: -2;
    transition: 0.3s;
}

/* -------- блоки квартири всередині попапу -------- */

.page-wrapper.smakuly-2-cherga-8 .popup-wrapp .flat {
    display: none;          /* активна стає flex через JS */
    width: 100%;
    flex-wrap: wrap;
}

.page-wrapper.smakuly-2-cherga-8 .popup_content-image {
    width: 55%;
    text-align: center;
    padding-top: 20px;
    box-sizing: border-box;
}

.page-wrapper.smakuly-2-cherga-8 .popup_content-image img {
    max-width: 85%;
    max-height: 430px;
    height: auto;
    display: inline-block;
}

.page-wrapper.smakuly-2-cherga-8 .popup_content-text {
    width: 45%;
    margin-top: 30px;
    box-sizing: border-box;
}

.page-wrapper.smakuly-2-cherga-8 .popup_content-text h2 {
    margin: 10px 0 15px;
}

.page-wrapper.smakuly-2-cherga-8 .popup_content-text h3 {
    margin: 0 0 15px;
}

.page-wrapper.smakuly-2-cherga-8 .popup_content-text-list {
    font-size: 16px;
    display: flex;
    flex-direction: column;
    row-gap: 5px;
}

/* -------- схема поверху під квартирою -------- */

.page-wrapper.smakuly-2-cherga-8 .popup-wrapp h3.plan-title {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 40px;
}

.page-wrapper.smakuly-2-cherga-8 .popup_content-plan {
    width: 100%;
    position: relative;
    text-align: center;
}

.page-wrapper.smakuly-2-cherga-8 .popup_content-plan .floor-preview {
    width: 100%;
    max-width: 100%;
    max-height: 250px;
    height: auto;
    margin: 20px 0;
    object-fit: contain;
}

.page-wrapper.smakuly-2-cherga-8 #popup-flat-overlay {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    margin: 20px 0;
    width: auto;
    max-height: 250px;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* -------- кнопки під попапом -------- */

.page-wrapper.smakuly-2-cherga-8 .popup_content-btns {
    display: flex;
    grid-column-gap: 30px;
    width: 100%;
    justify-content: center;
    align-items: center;
    z-index: 1;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
}

.page-wrapper.smakuly-2-cherga-8 .popup_content-btns .print-btn,
.page-wrapper.smakuly-2-cherga-8 .popup_content-btns .btn-detail,
.page-wrapper.smakuly-2-cherga-8 .popup_content-btns .button-close {
    display: flex;
    justify-content: center;
    align-items: center;
    grid-column-gap: 12px;
    padding: 18px 36px;
    border-radius: 8px;
    font-family: Unbounded, sans-serif;
    font-size: 12px;
    font-weight: 300;
    line-height: 1;
    text-transform: uppercase;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: 0.3s;
    text-decoration: none;
    box-shadow: -3px 4px 29px 0px rgba(57, 69, 83, 0.3);
    background-color: #394553;
}

.page-wrapper.smakuly-2-cherga-8 .popup_content-btns .print-btn {
    background-image: linear-gradient(to right, #EC784D 0%, #e74c3c 50%, #EC784D 100%);
    background-size: 200% auto;
}

.page-wrapper.smakuly-2-cherga-8 .popup_content-btns .print-btn:hover {
    background-position: right center;
}

.page-wrapper.smakuly-2-cherga-8 .popup_content-btns .btn-detail:hover,
.page-wrapper.smakuly-2-cherga-8 .popup_content-btns .button-close:hover {
    background-color: #EC784D;
}

/* ============================================================
   PRINT
   ============================================================ */

@page {
    size: A4 portrait;
    margin: 10mm 12mm;
}

@media print {
    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        font-family: Arial, sans-serif !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    body > *:not(.print-area) {
        display: none !important;
    }

    .print-area {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        color: #243b5a !important;
    }

    .print-sheet {
        position: relative !important;
        width: 100% !important;
        box-sizing: border-box !important;
        background: #fff !important;
        page-break-after: avoid !important;
        break-after: avoid-page !important;
        overflow: hidden !important;
    }

    .print-main {
        display: grid !important;
        grid-template-columns: 80mm 1fr !important;
        gap: 14mm !important;
        align-items: start !important;
        width: 100% !important;
        margin: 0 0 8mm 0 !important;
        padding: 0 !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .print-flat-image {
        width: 80mm !important;
        text-align: center !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .print-flat-image img {
        display: block !important;
        width: auto !important;
        max-width: 80mm !important;
        max-height: 112mm !important;
        height: auto !important;
        margin: 0 auto !important;
        object-fit: contain !important;
    }

    .print-flat-info {
        margin: 0 !important;
        padding: 4mm 0 0 0 !important;
        color: #243b5a !important;
        box-sizing: border-box !important;
    }

    .print-flat-info .popup_content-text {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        color: #243b5a !important;
    }

    .print-flat-info h2 {
        margin: 0 0 4mm 0 !important;
        padding: 0 !important;
        font-size: 23pt !important;
        line-height: 1.1 !important;
        font-weight: 700 !important;
        color: #243b5a !important;
    }

    .print-flat-info h3 {
        margin: 0 0 4mm 0 !important;
        padding: 0 !important;
        font-size: 15pt !important;
        line-height: 1.2 !important;
        font-weight: 700 !important;
        color: #243b5a !important;
    }

    .print-flat-info .popup_content-text-list {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 12pt !important;
        line-height: 1.55 !important;
        font-weight: 400 !important;
        color: #243b5a !important;
    }

    .print-flat-info .popup_content-text-list-item {
        display: block !important;
        margin: 0 0 1mm 0 !important;
        padding: 0 !important;
    }

    .print-plan-title {
        display: block !important;
        width: 100% !important;
        margin: 5mm 0 6mm 0 !important;
        padding: 0 !important;
        text-align: center !important;
        font-size: 21pt !important;
        line-height: 1.2 !important;
        font-weight: 700 !important;
        color: #243b5a !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    .print-plan {
        position: relative !important;
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: 72mm !important;
        margin: 0 auto !important;
        padding: 0 !important;
        text-align: center !important;
        overflow: visible !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    /* За замовчуванням / Секція А: план має влазити у PDF */
    .print-plan .floor-preview {
        display: block !important;
        width: 100% !important;
        max-width: 180mm !important;
        max-height: 82mm !important;
        height: auto !important;
        margin: 0 auto !important;
        padding: 0 !important;
        object-fit: contain !important;
    }

    .print-plan #popup-flat-overlay {
        display: block !important;
        position: absolute !important;
        top: 0 !important;
        left: 50% !important;
        right: auto !important;
        bottom: auto !important;
        width: 100% !important;
        max-width: 180mm !important;
        max-height: 82mm !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        object-fit: contain !important;
        pointer-events: none !important;
        z-index: 5 !important;
        transform: translateX(-50%) !important;
    }

    /* Секція Б: окремо збільшуємо план поверху */
    .print-area.print-section-b .print-plan .floor-preview {
        width: 135% !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 0 0 -17.5% !important;
    }

    .print-area.print-section-b .print-plan #popup-flat-overlay {
        width: 135% !important;
        max-width: none !important;
        max-height: none !important;
        left: -17.5% !important;
        transform: none !important;
    }

    /* Секція А: примусово залишаємо нормальний розмір */
    .print-area.print-section-a .print-plan .floor-preview {
        width: 100% !important;
        max-width: 180mm !important;
        max-height: 82mm !important;
        margin: 0 auto !important;
    }

    .print-area.print-section-a .print-plan #popup-flat-overlay {
        width: 100% !important;
        max-width: 180mm !important;
        max-height: 82mm !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    .print-plan img {
        max-height: none !important;
    }

    .print-area .flat,
    .print-area .popup_content,
    .print-area .popup_content-image,
    .print-area .popup_content-text,
    .print-area .popup_content-plan,
    .print-area .popup_content-btns,
    .print-area .flat-detail-link,
    .print-area .button-close,
    .print-area .btn-detail,
    .print-area .print-btn {
        box-shadow: none !important;
        clip-path: none !important;
    }

    .print-area .popup_content-btns,
    .print-area .flat-detail-link,
    .print-area .button-close,
    .print-area .btn-detail,
    .print-area .print-btn {
        display: none !important;
    }
}

/* ============================================================
   АДАПТИВ
   ============================================================ */

@media (max-width: 1024px) {
    .page-wrapper.smakuly-2-cherga-8 .popup-wrapp {
        width: 95%;
    }
}

@media (max-width: 768px) {
    .page-wrapper.smakuly-2-cherga-8 .title_h1 {
        font-size: 26px;
    }
    .page-wrapper.smakuly-2-cherga-8 .tower-title {
        font-size: 22px;
    }
    .page-wrapper.smakuly-2-cherga-8 .popup_content-image,
    .page-wrapper.smakuly-2-cherga-8 .popup_content-text {
        width: 50%;
    }
    .page-wrapper.smakuly-2-cherga-8 .popup_content-text h2 {
        font-size: 22px;
    }
    .page-wrapper.smakuly-2-cherga-8 .popup_content-text h3 {
        font-size: 16px;
    }
    .page-wrapper.smakuly-2-cherga-8 .popup_content-btns {
        flex-wrap: wrap;
        gap: 10px;
    }
    .page-wrapper.smakuly-2-cherga-8 .popup_content-btns .print-btn,
    .page-wrapper.smakuly-2-cherga-8 .popup_content-btns .btn-detail,
    .page-wrapper.smakuly-2-cherga-8 .popup_content-btns .button-close {
        padding: 14px 18px;
        font-size: 11px;
    }
    .page-wrapper.smakuly-2-cherga-8 .buttons-wrapp {
        flex-direction: column;
        gap: 12px;
    }
}

@media (max-width: 600px) {
    .page-wrapper.smakuly-2-cherga-8 .popup_content-image,
    .page-wrapper.smakuly-2-cherga-8 .popup_content-text {
        width: 100%;
    }
    .page-wrapper.smakuly-2-cherga-8 .popup_content {
        padding: 18px;
    }
    .page-wrapper.smakuly-2-cherga-8 .buttons-wrapp button {
        padding: 14px 22px;
    }
}
