/* =====================================================================
   CBridge Smart Popup — стилі на сайті
   ---------------------------------------------------------------------
   Розмітка (includes/frontend.php):
     .cbsp.cbsp--tpl-{bar|card|modal|custom}.cbsp--pos-{bottom-left|bottom-right|bottom-center|top|center}
       .cbsp__overlay            (лише modal)
       .cbsp__box
         .cbsp__icon  .cbsp__body(.cbsp__title + .cbsp__text)  .cbsp__btn  .cbsp__close
   Кольори приходять inline-змінними з налаштувань попапа:
     --cbsp-bg, --cbsp-text, --cbsp-btn-bg, --cbsp-btn-text.
   Шари сайту: шапка 4, Contactwijzer 7, меню 8–9 → звичайний попап 6
   (не перекриває меню й Contactwijzer), вікно (modal) — 10, над усім.
   ===================================================================== */

.cbsp {
    --cbsp-gap: 32px;                 /* відступ від краю екрана (як у Contactwijzer) */
    --cbsp-ease: cubic-bezier(.16, .84, .44, 1);
    position: fixed;
    z-index: 6;
    font-family: "Montserrat", sans-serif;
    line-height: 1.4;
    color: var(--cbsp-text, #fff);
    opacity: 0;
    transform: translateY(18px);
    pointer-events: none;
    transition: opacity .45s ease, transform .55s var(--cbsp-ease);
}
.cbsp[hidden] { display: none !important; }
.cbsp.is-open { opacity: 1; transform: none; pointer-events: auto; }
.cbsp *, .cbsp *::before, .cbsp *::after { box-sizing: border-box; }
.cbsp p { margin: 0; }

.cbsp__box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--cbsp-bg, #065AA7);
    color: var(--cbsp-text, #fff);
    box-shadow: 0 18px 60px rgba(0, 0, 0, .28);
}

/* ── Спільні елементи ─────────────────────────────────────────────── */
.cbsp__icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .35);
    color: var(--cbsp-btn-bg, #EDCC19);
}
.cbsp__icon svg { width: 20px; height: 20px; }
.cbsp__icon--image { border: 0; overflow: hidden; }
.cbsp__icon--image img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cbsp__title { font-weight: 700; font-size: 15px; color: inherit; }
.cbsp__text  { font-weight: 400; font-size: 13px; color: inherit; opacity: .88; }

.cbsp__btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px 12px 22px;
    border-radius: 40px;
    background: var(--cbsp-btn-bg, #EDCC19);
    color: var(--cbsp-btn-text, #000) !important;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    text-decoration: none !important;
    white-space: nowrap;
    transition: filter .3s ease, transform .3s ease;
}
.cbsp__btn:hover, .cbsp__btn:focus-visible { filter: brightness(.92); }
.cbsp__arrow { width: 16px; height: 16px; transition: transform .3s ease; }
.cbsp__btn:hover .cbsp__arrow { transform: translateX(4px); }

.cbsp__close {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: .8;
    transition: background-color .3s ease, opacity .3s ease;
}
.cbsp__close svg { width: 16px; height: 16px; }
.cbsp__close:hover, .cbsp__close:focus-visible { background: rgba(255, 255, 255, .16); opacity: 1; }
.cbsp__btn:focus-visible, .cbsp__close:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* ── Позиції ──────────────────────────────────────────────────────── */
.cbsp--pos-bottom-left  { left: var(--cbsp-gap); bottom: var(--cbsp-gap); }
/* праворуч унизу стоїть кнопка Contactwijzer (64px) → попап над нею */
.cbsp--pos-bottom-right { right: var(--cbsp-gap); bottom: calc(var(--cbsp-gap) + 64px + 18px); }
.cbsp--pos-bottom-center { left: 0; right: 0; bottom: 0; }
.cbsp--pos-top { left: 0; right: 0; top: 0; transform: translateY(-18px); }
.admin-bar .cbsp--pos-top { top: 32px; }
.cbsp--pos-center { left: 50%; top: 50%; transform: translate(-50%, calc(-50% + 18px)); }
.cbsp--pos-center.is-open { transform: translate(-50%, -50%); }

/* ── Шаблон 1: смужка (slim) ──────────────────────────────────────── */
.cbsp--tpl-bar .cbsp__box {
    gap: 16px;
    padding: 10px 12px 10px 14px;
    max-width: min(760px, calc(100vw - 2 * var(--cbsp-gap) - 100px));
    border-radius: 40px;
}
.cbsp--tpl-bar .cbsp__body {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 10px;
    min-width: 0;
}
/* один "гострий" кут — як у панелей сайту */
.cbsp--tpl-bar.cbsp--pos-bottom-left  .cbsp__box { border-radius: 40px 40px 40px 0; }
.cbsp--tpl-bar.cbsp--pos-bottom-right .cbsp__box { border-radius: 40px 40px 0 40px; }
.cbsp--tpl-bar.cbsp--pos-bottom-center .cbsp__box,
.cbsp--tpl-bar.cbsp--pos-top .cbsp__box {
    max-width: none;
    justify-content: center;
    border-radius: 0;
    padding: 12px 24px;
}
.cbsp--tpl-bar.cbsp--pos-bottom-center .cbsp__box { padding-right: 120px; } /* місце під Contactwijzer */

/* ── Шаблон 2: картка ─────────────────────────────────────────────── */
.cbsp--tpl-card .cbsp__box {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    width: 340px;
    max-width: calc(100vw - 2 * var(--cbsp-gap));
    padding: 28px 28px 26px;
    border-radius: 32px;
}
.cbsp--tpl-card.cbsp--pos-bottom-left  .cbsp__box { border-radius: 32px 32px 32px 0; }
.cbsp--tpl-card.cbsp--pos-bottom-right .cbsp__box { border-radius: 32px 32px 0 32px; }
.cbsp--tpl-card.cbsp--pos-bottom-center .cbsp__box,
.cbsp--tpl-card.cbsp--pos-top .cbsp__box { margin: 0 auto var(--cbsp-gap); }
.cbsp--tpl-card.cbsp--pos-top .cbsp__box { margin: var(--cbsp-gap) auto 0; }
.cbsp--tpl-card .cbsp__icon { width: 48px; height: 48px; }
.cbsp--tpl-card .cbsp__icon svg { width: 22px; height: 22px; }
.cbsp--tpl-card .cbsp__body { display: flex; flex-direction: column; gap: 8px; padding-right: 20px; }
.cbsp--tpl-card .cbsp__title { font-size: 20px; line-height: 1.25; }
.cbsp--tpl-card .cbsp__text { font-size: 14px; line-height: 1.55; }
.cbsp--tpl-card .cbsp__close,
.cbsp--tpl-modal .cbsp__close,
.cbsp--tpl-custom .cbsp__close { position: absolute; top: 14px; right: 14px; }

/* ── Шаблон 3: вікно в центрі ─────────────────────────────────────── */
.cbsp--tpl-modal {
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    transform: none;
}
.cbsp--tpl-modal.is-open { transform: none; }
.cbsp__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(3px);
}
.cbsp--tpl-modal .cbsp__box {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
    width: 520px;
    max-width: 100%;
    max-height: calc(100dvh - 32px);
    overflow: auto;
    padding: 46px 42px 40px;
    border-radius: 32px 32px 0 32px;
    transform: translateY(18px) scale(.98);
    transition: transform .55s var(--cbsp-ease);
}
.cbsp--tpl-modal.is-open .cbsp__box { transform: none; }
.cbsp--tpl-modal .cbsp__icon { width: 56px; height: 56px; }
.cbsp--tpl-modal .cbsp__icon svg { width: 26px; height: 26px; }
.cbsp--tpl-modal .cbsp__body { display: flex; flex-direction: column; gap: 12px; }
.cbsp--tpl-modal .cbsp__title { font-size: 28px; line-height: 1.2; }
.cbsp--tpl-modal .cbsp__text { font-size: 16px; line-height: 1.6; }
.cbsp--tpl-modal .cbsp__btn { padding: 16px 24px 16px 30px; }

/* ── Шаблон 4: власний HTML ───────────────────────────────────────── */
.cbsp--tpl-custom .cbsp__box {
    display: block;
    max-width: min(440px, calc(100vw - 2 * var(--cbsp-gap)));
    padding: 24px 52px 24px 24px;
    border-radius: 24px;
}
.cbsp--tpl-custom.cbsp--pos-bottom-center .cbsp__box,
.cbsp--tpl-custom.cbsp--pos-top .cbsp__box { max-width: none; border-radius: 0; }

/* ── Мобільний ────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .cbsp { --cbsp-gap: 16px; }

    /* знизу праворуч — кнопка Contactwijzer (58px): нижні попапи стають над нею на всю ширину */
    .cbsp--pos-bottom-left,
    .cbsp--pos-bottom-right {
        left: var(--cbsp-gap);
        right: var(--cbsp-gap);
        bottom: calc(var(--cbsp-gap) + 58px + 12px);
    }
    .cbsp--tpl-bar .cbsp__box {
        flex-wrap: wrap;
        gap: 10px 12px;
        max-width: none;
        padding: 14px;
        border-radius: 24px 24px 24px 0 !important;
    }
    .cbsp--tpl-bar .cbsp__body { flex: 1 1 0; padding-right: 30px; } /* місце під хрестик */
    .cbsp--tpl-bar .cbsp__btn { flex: 1 1 100%; justify-content: space-between; }
    .cbsp--tpl-bar .cbsp__close { position: absolute; top: 8px; right: 8px; }
    .cbsp--tpl-bar.cbsp--pos-bottom-center .cbsp__box,
    .cbsp--tpl-bar.cbsp--pos-top .cbsp__box { border-radius: 0 !important; padding: 12px 44px 12px 14px; }
    .cbsp--tpl-bar.cbsp--pos-bottom-center .cbsp__box { padding-bottom: 86px; }

    .cbsp--tpl-card .cbsp__box { width: auto; max-width: none; padding: 24px 22px 22px; }
    .cbsp--tpl-card .cbsp__btn { width: 100%; justify-content: space-between; }

    .cbsp--tpl-modal .cbsp__box { padding: 40px 24px 28px; border-radius: 28px 28px 0 28px; }
    .cbsp--tpl-modal .cbsp__title { font-size: 22px; }
    .cbsp--tpl-modal .cbsp__text { font-size: 15px; }
    .cbsp--tpl-modal .cbsp__btn { width: 100%; justify-content: space-between; white-space: normal; }

    .cbsp--tpl-custom .cbsp__box { max-width: none; }
    .admin-bar .cbsp--pos-top { top: 46px; }
}

/* Відкрите меню сайту / Popup Maker — ховаємо звичайні попапи, щоб не заважали */
body.pum-open .cbsp:not(.cbsp--tpl-modal) { opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
    .cbsp, .cbsp--tpl-modal .cbsp__box, .cbsp__arrow { transition: none !important; }
}
