/*
 * ewshopconsent — витрина.
 *
 * Изоляция от темы держится на трёх вещах: всё внутри .ewconsent, у корня
 * `all: initial`, у каждого класса префикс. Shadow DOM осознанно не используем —
 * он ломает клиентский CSS, которым магазины правят такие окна.
 */

.ewconsent {
    all: initial;
    position: fixed;
    inset: auto 0 0 0;
    display: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ewconsent-text);
    box-sizing: border-box;
}

.ewconsent *,
.ewconsent *::before,
.ewconsent *::after {
    box-sizing: border-box;
}

.ewconsent--visible,
.ewconsent--dialog {
    display: block;
}

/* Блокирующий режим: затемняем страницу и перехватываем клики. */
.ewconsent--blocking::before,
.ewconsent--dialog::before {
    content: "";
    position: fixed;
    inset: 0;
    background: var(--ewconsent-overlay);
}

/* Seller 2 templates used fixed corner utilities before positions were configurable.
   Data attributes keep existing customized templates compatible without replacing them. */
.cookie-consent[data-ewconsent-position] {
    position: fixed;
    width: calc(100% - 32px);
    max-width: 384px;
    margin: 0;
    inset: auto 16px 16px auto;
    inset-inline-start: auto;
    inset-inline-end: 16px;
    transform: none;
}

.cookie-consent[data-ewconsent-position="bottom-left"] {
    left: 16px;
    right: auto;
    inset-inline-start: 16px;
    inset-inline-end: auto;
}

.cookie-consent[data-ewconsent-position="bottom"] {
    left: 16px;
    right: 16px;
    inset-inline-start: 16px;
    inset-inline-end: 16px;
    width: auto;
    max-width: 1180px;
    margin-inline: auto;
}

.cookie-consent[data-ewconsent-position="center"] {
    inset: 50% auto auto 50%;
    inset-inline-start: 50%;
    inset-inline-end: auto;
    max-width: 560px;
    transform: translate(-50%, -50%);
}

/* ------------------------------------------------------------------ баннер */

/*
 * Вид баннера задаёт настройка «Вид» — класс ewconsent--layout-* на корне:
 *   card   — угловая карточка, угол — от позиции (bottom-left | bottom-right);
 *   island — островок по центру снизу;
 *   bar    — тонкая полоса во всю ширину;
 *   sheet  — карточка с иконкой, на телефоне — лист снизу;
 *   center — окно по центру экрана.
 * Корень растянут по низу экрана, но клики пропускает: иначе пустое место
 * рядом с карточкой перекрывало бы страницу. Перехватывают клики только сам
 * баннер, окно настроек и затемнение блокирующего режима.
 */
.ewconsent { pointer-events: none; }
.ewconsent > *,
.ewconsent--blocking,
.ewconsent--dialog { pointer-events: auto; }

.ewconsent__banner {
    position: relative;
    max-width: calc(100vw - 32px);
    margin: 0 auto 16px;
    padding: 18px;
    background: var(--ewconsent-bg);
    border-radius: var(--ewconsent-radius);
    box-shadow: 0 12px 40px rgba(15, 23, 42, .16), 0 0 0 1px rgba(15, 23, 42, .06);
}

.ewconsent--dialog .ewconsent__banner {
    display: none;
}

/* По контракту, а не по классу: баннер темы (у seller2 свои классы и z-index
   поверх окна) тоже прячется, пока открыто окно настроек. Иначе на телефоне он
   закрывал категории и кнопки окна (OnProfi, 26.10.2026). important — потому что
   CSS темы грузится позже и показывает свой баннер правилом той же силы; это
   состояние плагина, тема его переопределять не должна. */
.ewconsent--dialog [data-ewconsent-block="banner"] {
    display: none !important;
}

/* Иконка, ручка листа и значок кнопки «Настройки» нужны не каждому виду. */
.ewconsent__icon,
.ewconsent__grab,
.ewconsent__btn-icon { display: none; }

.ewconsent__banner .ewconsent__actions { margin-top: 14px; }
.ewconsent__banner .ewconsent__btn--accept,
.ewconsent__banner .ewconsent__btn--decline {
    min-height: 40px;
    padding: 9px 16px;
}
.ewconsent__banner .ewconsent__btn--settings {
    grid-column: 1 / -1;
    justify-self: center;
    min-height: 0;
    padding: 4px 8px;
    font-weight: 500;
}

/* ---- угловая карточка */
.ewconsent--layout-card .ewconsent__banner {
    width: 380px;
    margin: 0 auto 20px 20px;
}
.ewconsent--layout-card.ewconsent--bottom-right .ewconsent__banner { margin: 0 20px 20px auto; }
.ewconsent--layout-card .ewconsent__title { display: none; }
.ewconsent--layout-card .ewconsent__text { color: var(--ewconsent-text); }

/* ---- островок */
.ewconsent--layout-island .ewconsent__banner {
    display: flex;
    align-items: center;
    gap: 18px;
    width: 760px;
    margin-bottom: 24px;
    padding: 14px 14px 14px 22px;
    /* Макет C, который понравился владельцу 25.11.2026: стекло поверх страницы
       и мягкие скругления — у карточки на 6px больше, чем у кнопок. */
    border-radius: calc(var(--ewconsent-radius) + 6px);
    background: color-mix(in srgb, var(--ewconsent-bg) 90%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    backdrop-filter: blur(14px) saturate(1.4);
    box-shadow: 0 18px 50px rgba(15, 23, 42, .18), 0 0 0 1px rgba(15, 23, 42, .07);
}
.ewconsent--layout-island .ewconsent__banner .ewconsent__btn { border-radius: var(--ewconsent-radius); }
.ewconsent--layout-island .ewconsent__body { flex: 1 1 auto; min-width: 0; }
.ewconsent--layout-island .ewconsent__title { margin: 0 0 2px; font-size: 15px; }
.ewconsent--layout-island .ewconsent__text,
.ewconsent--layout-island .ewconsent__links { font-size: 13px; }
/* Основным цветом, а не приглушённым: на полупрозрачном фоне серый текст
   проседает ниже AA (4,32 при норме 4,5). */
.ewconsent--layout-island .ewconsent__text { color: var(--ewconsent-text); }
.ewconsent--layout-island .ewconsent__links { margin-top: 8px; gap: 4px 12px; }
.ewconsent--layout-island .ewconsent__actions {
    flex: none;
    margin-top: 0;
    /* Равные доли, а не по содержимому: «Принять» и «Отказаться» одной ширины
       при любой длине подписей и на любом языке. */
    grid-template-columns: 1fr 1fr 40px;
}
.ewconsent--layout-island .ewconsent__banner .ewconsent__btn--accept,
.ewconsent--layout-island .ewconsent__banner .ewconsent__btn--decline { min-width: 120px; }

/* «Настройки» значком: островок узкий, третья текстовая кнопка его ломает.
   Подпись остаётся для чтения с экрана. */
.ewconsent--layout-island .ewconsent__banner .ewconsent__btn--settings {
    grid-column: auto;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--ewconsent-text);
    text-decoration: none;
    border: 1px solid rgba(15, 23, 42, .14);
    border: 1px solid color-mix(in srgb, var(--ewconsent-text) 16%, transparent);
    border-radius: var(--ewconsent-radius);
    background: transparent;
}
.ewconsent--layout-island .ewconsent__btn-icon { display: block; }
.ewconsent--layout-island .ewconsent__btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---- тонкая полоса */
.ewconsent--layout-bar .ewconsent__banner {
    display: flex;
    align-items: center;
    gap: 24px;
    max-width: none;
    margin: 0;
    padding: 10px max(24px, calc((100vw - 1200px) / 2));
    border-radius: 0;
    box-shadow: 0 -1px 0 rgba(15, 23, 42, .08), 0 -8px 24px rgba(15, 23, 42, .08);
}
.ewconsent--layout-bar .ewconsent__body { flex: 1 1 auto; min-width: 0; font-size: 13.5px; }
.ewconsent--layout-bar .ewconsent__title { display: none; }
.ewconsent--layout-bar .ewconsent__text { display: inline; color: var(--ewconsent-text); }
.ewconsent--layout-bar .ewconsent__links { display: inline-flex; margin: 0 0 0 10px; gap: 4px 12px; }
.ewconsent--layout-bar .ewconsent__actions {
    flex: none;
    align-items: center;
    margin-top: 0;
    /* «Настройки» ссылкой слева, затем две равные кнопки (см. островок). */
    grid-template-columns: auto 1fr 1fr;
}
.ewconsent--layout-bar .ewconsent__banner .ewconsent__btn--settings {
    grid-column: 1;
    grid-row: 1;
    margin-right: 4px;
}
.ewconsent--layout-bar .ewconsent__banner .ewconsent__btn--accept,
.ewconsent--layout-bar .ewconsent__banner .ewconsent__btn--decline {
    min-width: 112px;
    min-height: 34px;
    padding: 7px 16px;
    font-size: 13.5px;
}

/* ---- карточка с иконкой */
.ewconsent--layout-sheet .ewconsent__banner {
    width: 400px;
    margin: 0 24px 24px auto;
    padding: 20px;
    border-radius: calc(var(--ewconsent-radius) + 8px);
}
.ewconsent--layout-sheet.ewconsent--bottom-left .ewconsent__banner { margin: 0 auto 24px 24px; }
.ewconsent--layout-sheet .ewconsent__body {
    display: grid;
    grid-template-columns: 40px 1fr;
    column-gap: 12px;
    align-items: center;
}
.ewconsent--layout-sheet .ewconsent__body > :not(.ewconsent__icon):not(.ewconsent__title) { grid-column: 1 / -1; }
.ewconsent--layout-sheet .ewconsent__icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: var(--ewconsent-accept-bg);
    background: rgba(29, 78, 216, .1);
    background: color-mix(in srgb, var(--ewconsent-accept-bg) 12%, var(--ewconsent-bg));
}
.ewconsent--layout-sheet .ewconsent__title { margin: 0; font-size: 16px; }
.ewconsent--layout-sheet .ewconsent__text { margin-top: 8px; }
.ewconsent--layout-sheet .ewconsent__actions { margin-top: 16px; }
.ewconsent--layout-sheet .ewconsent__banner .ewconsent__btn--accept,
.ewconsent--layout-sheet .ewconsent__banner .ewconsent__btn--decline { min-height: 42px; }
.ewconsent--layout-sheet .ewconsent__banner .ewconsent__btn--settings {
    justify-self: stretch;
    min-height: 38px;
    color: var(--ewconsent-text);
    text-decoration: none;
    border: 1px solid rgba(15, 23, 42, .14);
    border: 1px solid color-mix(in srgb, var(--ewconsent-text) 16%, transparent);
    border-radius: calc(var(--ewconsent-radius) / 1.6);
}

/* ---- по центру экрана */
.ewconsent--center {
    inset: 0;
    display: none;
}

.ewconsent--center.ewconsent--visible,
.ewconsent--center.ewconsent--dialog {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ewconsent--center .ewconsent__banner {
    width: 560px;
    margin: 16px;
    padding: 24px;
}


.ewconsent__title {
    margin: 0 0 6px;
    font-size: 18px;
    line-height: 1.35;
    font-weight: 700;
    color: var(--ewconsent-text);
}

.ewconsent__text {
    margin: 0;
    color: var(--ewconsent-muted);
}

.ewconsent__link {
    color: var(--ewconsent-link);
    text-decoration: underline;
}

.ewconsent__actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    align-items: center;
}



.ewconsent__btn {
    -webkit-appearance: none;
    appearance: none;
    display: inline-block;
    min-height: 44px;
    padding: 12px 18px;
    text-align: center;
    transition: filter .15s ease;
    border: 0;
    border-radius: calc(var(--ewconsent-radius) / 1.6);
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
}

.ewconsent__btn:focus-visible,
.ewconsent__link:focus-visible,
.ewconsent__close:focus-visible,
.ewconsent__floating:focus-visible {
    outline: 2px solid var(--ewconsent-link);
    outline-offset: 2px;
}

.ewconsent__btn:hover { filter: brightness(.9); }
.ewconsent__link:hover { text-decoration-thickness: 2px; }

.ewconsent__btn--accept {
    background: var(--ewconsent-accept-bg);
    color: var(--ewconsent-accept-text);
}

.ewconsent__btn--decline {
    background: var(--ewconsent-decline-bg);
    color: var(--ewconsent-decline-text);
}

.ewconsent__btn--settings {
    background: transparent;
    color: var(--ewconsent-settings-text);
    text-decoration: underline;
    padding-left: 8px;
    padding-right: 8px;
}

/* ------------------------------------------------------- окно настроек */

.ewconsent__dialog {
    display: none;
    position: fixed;
    inset: 0;
    padding: 16px;
    overflow: auto;
}

.ewconsent--dialog .ewconsent__dialog {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ewconsent__dialog-inner {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 24px;
    background: var(--ewconsent-bg);
    border-radius: var(--ewconsent-radius);
    box-shadow: 0 16px 48px rgba(15, 23, 42, .28);
}

.ewconsent__dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.ewconsent__close {
    -webkit-appearance: none;
    appearance: none;
    border: 0;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    color: var(--ewconsent-muted);
    cursor: pointer;
    display: grid;
    place-items: center;
    flex: none;
    width: 44px;
    height: 44px;
    margin: -10px -10px 0 0;
    border-radius: 50%;
}

.ewconsent__cats {
    margin: 16px 0;
    display: block;
}

.ewconsent__cat {
    position: relative;
    display: block;
    padding: 16px 0;
    border-top: 1px solid rgba(100, 116, 139, .22);
    cursor: pointer;
}

.ewconsent__cat-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ewconsent__check {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.ewconsent__toggle {
    position: relative;
    flex: none;
    width: 42px;
    height: 24px;
    border: 2px solid var(--ewconsent-muted);
    border-radius: 999px;
    background: var(--ewconsent-bg);
}

.ewconsent__toggle::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--ewconsent-muted);
    transition: transform .15s ease;
}

.ewconsent__check:checked + .ewconsent__toggle {
    border-color: var(--ewconsent-accept-bg);
    background: var(--ewconsent-accept-bg);
}

.ewconsent__check:checked + .ewconsent__toggle::after {
    background: var(--ewconsent-accept-text);
    transform: translateX(18px);
}

.ewconsent__check:focus-visible + .ewconsent__toggle {
    outline: 2px solid var(--ewconsent-link);
    outline-offset: 3px;
}

.ewconsent__cat:has(.ewconsent__check[disabled]) { cursor: default; }

.ewconsent__cat-name { font-weight: 600; }

.ewconsent__badge {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--ewconsent-muted);
    color: var(--ewconsent-text);
    font-size: 12px;
    white-space: nowrap;
}

.ewconsent__cat-desc {
    display: block;
    margin: 8px 0 0 52px;
    color: var(--ewconsent-muted);
    font-size: 13px;
}

/* --------------------------------------------------- плавающая кнопка */

/* Кнопка стоит на body отдельно от корня, поэтому изолируется сама:
   `all: initial` первой строкой, дальше — только своё. */
.ewconsent__floating {
    all: initial;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    position: fixed;
    bottom: 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border: 0;
    border-radius: 999px;
    background: var(--ewconsent-bg);
    color: var(--ewconsent-settings-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .2);
}

.ewconsent__floating * { box-sizing: border-box; }

.ewconsent__floating--left { left: 16px; }
.ewconsent__floating--right { right: 16px; }
.ewconsent__floating-icon { font-size: 15px; }

/* Пока показан баннер или окно, плавающая кнопка не нужна.
   Класс ставит JS: сама кнопка живёт на body, а не внутри .ewconsent, потому что
   корень скрыт всё время, пока баннер не показан. */
.ewconsent__floating--hidden { display: none; }

/* ------------------------------------------- заглушка вместо iframe */

.ewconsent-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    padding: 20px;
    text-align: center;
    background: #f1f5f9;
    border: 1px dashed #94a3b8;
    border-radius: 8px;
    color: #475569;
    cursor: pointer;
    font-size: 14px;
}

/* -------------------------------------------------------- мобильные */

@media (max-width: 640px) {
    /* Общее для всех видов: баннер не выше двух третей экрана, прокручивается
       только текст — ссылки на документы и кнопки остаются на виду. */
    .ewconsent .ewconsent__banner {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        width: auto;
        max-width: none;
        max-height: 65vh;
        max-height: 65dvh;
        overflow: hidden;
        margin: 0 10px 10px;
        padding: 16px;
    }
    .ewconsent__body {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }
    .ewconsent__body .ewconsent__text {
        flex: 1 1 auto;
        min-height: 3em;
        overflow: auto;
    }
    .ewconsent__body .ewconsent__links { flex: none; }
    .ewconsent__banner .ewconsent__actions { margin-top: 0; flex: none; }
    .ewconsent .ewconsent__banner .ewconsent__btn {
        min-width: 0;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    .ewconsent__banner .ewconsent__btn--accept,
    .ewconsent__banner .ewconsent__btn--decline { align-self: stretch; }

    /* Островок: кнопки в ряд, «Настройки» значком справа. */
    .ewconsent--layout-island .ewconsent__banner { margin: 0 12px 12px; padding: 14px; }
    .ewconsent--layout-island .ewconsent__body { display: block; overflow: auto; }
    .ewconsent--layout-island .ewconsent__actions { grid-template-columns: repeat(2, minmax(0, 1fr)) 40px; }

    /* Полоса: текст сверху, «Настройки» слева от равных кнопок. */
    .ewconsent--layout-bar .ewconsent__banner { margin: 0; padding: 12px 14px 14px; gap: 10px; }
    .ewconsent--layout-bar .ewconsent__body { display: block; overflow: auto; }
    .ewconsent--layout-bar .ewconsent__actions { grid-template-columns: auto repeat(2, minmax(0, 1fr)); }
    .ewconsent--layout-bar .ewconsent__links { display: inline; margin-left: 6px; }
    .ewconsent--layout-bar .ewconsent__links .ewconsent__link + .ewconsent__link { margin-left: 10px; }
    .ewconsent--layout-bar .ewconsent__banner .ewconsent__btn--accept,
    .ewconsent--layout-bar .ewconsent__banner .ewconsent__btn--decline { min-width: 0; min-height: 40px; }

    /* Карточка с иконкой становится листом снизу. */
    .ewconsent--layout-sheet .ewconsent__banner,
    .ewconsent--layout-sheet.ewconsent--bottom-left .ewconsent__banner {
        margin: 0;
        padding: 10px 16px 18px;
        border-radius: calc(var(--ewconsent-radius) + 10px) calc(var(--ewconsent-radius) + 10px) 0 0;
    }
    .ewconsent--layout-sheet .ewconsent__body { display: grid; }
    .ewconsent--layout-sheet .ewconsent__grab {
        display: block;
        width: 40px;
        height: 4px;
        margin: 0 auto 2px;
        border-radius: 2px;
        background: rgba(15, 23, 42, .18);
    }

    /* Угловая карточка и окно по центру: «Принять» и «Отказаться» в один ряд и
       одной ширины — оба решения равноправны; «Настройки» строкой ниже. */
    .ewconsent--center .ewconsent__banner { margin: 16px; }

    .ewconsent__cat-head { flex-wrap: wrap; }
    .ewconsent__cat-name { flex: 1; }
    .ewconsent__badge { margin-left: 52px; }
    .ewconsent__dialog-inner { padding: 20px; max-height: calc(100dvh - 32px); }

    .ewconsent__dialog .ewconsent__actions { grid-template-columns: 1fr 1fr; align-items: stretch; }
    .ewconsent__dialog .ewconsent__actions > :nth-child(n+3) { grid-column: 1 / -1; }
    .ewconsent__btn { text-align: center; }
    .ewconsent__dialog .ewconsent__btn,
    .ewconsent--layout-card .ewconsent__banner .ewconsent__btn--accept,
    .ewconsent--layout-card .ewconsent__banner .ewconsent__btn--decline,
    .ewconsent--center .ewconsent__banner .ewconsent__btn--accept,
    .ewconsent--center .ewconsent__banner .ewconsent__btn--decline { width: 100%; }
    .ewconsent__floating-text { display: none; }
}

@media (max-width: 360px) {
    .ewconsent--layout-bar .ewconsent__actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ewconsent--layout-bar .ewconsent__banner .ewconsent__btn--settings {
        grid-column: 1 / -1;
        grid-row: 2;
        margin-right: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ewconsent * { transition: none !important; animation: none !important; }
}

.ewconsent__links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-top: 12px;
}

.ewconsent__link { text-underline-offset: 3px; overflow-wrap: anywhere; }
.ewconsent__close:hover { background: color-mix(in srgb, var(--ewconsent-text) 8%, transparent); }
