/*
 * 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);
}

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

.ewconsent__banner {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    max-width: 1180px;
    margin: 0 auto 16px;
    padding: 18px 20px;
    background: var(--ewconsent-bg);
    border-radius: var(--ewconsent-radius);
    box-shadow: 0 8px 32px rgba(15, 23, 42, .18);
}

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

.ewconsent--bottom-left .ewconsent__banner,
.ewconsent--bottom-right .ewconsent__banner {
    max-width: 420px;
    margin-bottom: 16px;
    display: block;
}

.ewconsent--bottom-left .ewconsent__banner { margin-left: 16px; margin-right: auto; }
.ewconsent--bottom-right .ewconsent__banner { margin-right: 16px; margin-left: auto; }

.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 {
    max-width: 560px;
    margin: 16px;
    display: block;
}

.ewconsent__body { flex: 1 1 420px; min-width: 0; }

.ewconsent__title {
    margin: 0 0 6px;
    font-size: 16px;
    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: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.ewconsent--bottom-left .ewconsent__actions,
.ewconsent--bottom-right .ewconsent__actions,
.ewconsent--center .ewconsent__actions {
    margin-top: 14px;
}

.ewconsent__btn {
    -webkit-appearance: none;
    appearance: none;
    display: inline-block;
    padding: 10px 18px;
    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 {
    outline: 2px solid var(--ewconsent-link);
    outline-offset: 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: 22px;
    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;
    padding: 0 4px;
}

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

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

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

.ewconsent__check {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--ewconsent-accept-bg);
    cursor: pointer;
    flex: none;
}

.ewconsent__check[disabled] { cursor: default; opacity: .65; }

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

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

.ewconsent__cat-desc {
    display: block;
    margin: 6px 0 0 28px;
    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__banner {
        display: block;
        margin: 0 8px 8px;
        padding: 16px;
    }

    .ewconsent__actions {
        margin-top: 14px;
        flex-direction: column;
        align-items: stretch;
    }

    .ewconsent__btn { width: 100%; text-align: center; }
    .ewconsent__floating-text { display: none; }
}

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