/**
 * Transcend Consent Manager — KFC skin
 *
 * Transcend renders its UI into #transcend-consent-ui in the light DOM, with
 * CSS-module class names (._container_maecs_1, ._text_1z0so_1, …). Those hashes
 * are regenerated on every Transcend release, so nothing here targets them.
 * Only stable hooks are used: the button IDs, the unhashed BEM classes
 * (banner__container, banner__description, banner__button-group, header, footer)
 * and the data-layer attribute.
 *
 * The #transcend-consent-ui prefix gives every rule ID-level specificity, which
 * beats Transcend's own class-based styles no matter which stylesheet loads last.
 */

#transcend-consent-ui {
    --kfc-red: #e4002b;
    --kfc-red-hover: #b80022;
    --kfc-banner-bg: #f2f2f2;
    --kfc-text: #2b2b2b;
    --kfc-font: "National2", Arial, Verdana, sans-serif;
}

/* ---------------------------------------------------------------- banner bar */

#transcend-consent-ui dialog[data-layer="banner"] {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: var(--kfc-banner-bg);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, .12);
    color: var(--kfc-text);
    font-family: var(--kfc-font);
}

/*
 * Two hashed wrapper divs sit between the dialog and .banner__container and
 * carry Transcend's own padding. They have no stable class, so they are matched
 * structurally and flattened — the padding is re-applied on .banner__container.
 */
#transcend-consent-ui dialog[data-layer="banner"] > div,
#transcend-consent-ui dialog[data-layer="banner"] > div > div {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
}

#transcend-consent-ui .banner__container {
    box-sizing: border-box;
    width: 100%;
    max-width: 1250px;
    margin: 0 auto;
    padding: 26px 20px 30px;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

#transcend-consent-ui .banner__content-wrapper {
    display: block;
    width: 100%;
}

/* Placeholder first-layer heading — the design has no title. */
#transcend-consent-ui dialog[data-layer="banner"] .header {
    display: none;
}

/* --------------------------------------------------------------------- copy */

#transcend-consent-ui .banner__description {
    margin: 0;
    max-width: 66%;
    color: var(--kfc-text);
    font-family: var(--kfc-font);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.65;
    text-align: left;
}

/* ------------------------------------------------------------------ buttons */

#transcend-consent-ui .banner__button-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    width: 100%;
}

/*
 * DOM order is Saber Mais (0), Aceitar (1), Rejeitar (2). The design puts the
 * link hard left and reject before accept on the right, so the two solid
 * buttons are reordered rather than relying on source order.
 */
#transcend-consent-ui dialog[data-layer="banner"] #OpenModal {
    order: 0;
    margin-right: auto;
}

#transcend-consent-ui dialog[data-layer="banner"] #RejectAllAndClose {
    order: 1;
}

#transcend-consent-ui dialog[data-layer="banner"] #AcceptAllAndClose {
    order: 2;
}

/* Solid red — also picks up the second-layer (modal) buttons. */
#transcend-consent-ui .button {
    box-sizing: border-box;
    min-width: 170px;
    padding: 15px 28px;
    background: var(--kfc-red);
    border: 1px solid var(--kfc-red);
    border-radius: 0;
    box-shadow: none;
    color: #fff;
    font-family: var(--kfc-font);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .25s ease, border-color .25s ease;
}

#transcend-consent-ui .button:hover,
#transcend-consent-ui .button:focus-visible {
    background: var(--kfc-red-hover);
    border-color: var(--kfc-red-hover);
    color: #fff;
}

#transcend-consent-ui .button:focus-visible {
    outline: 2px solid var(--kfc-text);
    outline-offset: 2px;
}

/* "Saber Mais" is a text link, not a button. */
#transcend-consent-ui #OpenModal {
    min-width: 0;
    padding: 0;
    background: none;
    border: 0;
    color: var(--kfc-red);
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 3px;
}

#transcend-consent-ui #OpenModal:hover,
#transcend-consent-ui #OpenModal:focus-visible {
    background: none;
    color: var(--kfc-red-hover);
}

/* ------------------------------------------------------- Transcend footer */

/*
 * Badge + locale picker are not part of the design. Removing the "Desenvolvido
 * por Transcend" badge is a dashboard setting on paid plans — hiding it here is
 * cosmetic only; see the note in the commit.
 */
#transcend-consent-ui dialog[data-layer="banner"] .footer,
#transcend-consent-ui #locale-picker {
    display: none;
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 760px) {
    #transcend-consent-ui .banner__container {
        padding: 22px 18px 24px;
    }

    #transcend-consent-ui .banner__description {
        max-width: 100%;
        font-size: 13px;
    }

    #transcend-consent-ui .banner__button-group {
        margin-top: 20px;
        gap: 10px;
    }

    #transcend-consent-ui dialog[data-layer="banner"] #OpenModal {
        order: 2;
        margin-right: 0;
        width: 100%;
        text-align: center;
    }

    #transcend-consent-ui dialog[data-layer="banner"] #RejectAllAndClose,
    #transcend-consent-ui dialog[data-layer="banner"] #AcceptAllAndClose {
        flex: 1 1 100%;
        min-width: 0;
    }

    #transcend-consent-ui dialog[data-layer="banner"] #RejectAllAndClose {
        order: 0;
    }

    #transcend-consent-ui dialog[data-layer="banner"] #AcceptAllAndClose {
        order: 1;
    }
}

/* ============================================================================
 * Second layer — preferences modal (data-layer="modal")
 *
 * Same rule as above: only stable hooks. The accordion internals have no
 * unhashed class names, so they are reached through the attributes Transcend
 * drives them with ([aria-expanded], [data-open], :checked) rather than through
 * the hashed classes, which change on every release.
 * ========================================================================= */

#transcend-consent-ui dialog[data-layer="modal"] {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    padding: 20px;
    border: 0;
    box-sizing: border-box;
    /* Transcend ships data-alpha-mask="false" (no dim). Drop this line to restore. */
    background: rgba(0, 0, 0, .55);
    font-family: var(--kfc-font);
    color: var(--kfc-text);
}

#transcend-consent-ui .modal__container {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    margin: 0;
    padding: 0;
    background: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
    overflow: hidden;
}

/* ------------------------------------------------------------ modal header */

#transcend-consent-ui dialog[data-layer="modal"] .header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex: 0 0 auto;
    padding: 22px 28px;
    border-bottom: 1px solid #e2e2e2;
}

#transcend-consent-ui dialog[data-layer="modal"] .header__title {
    margin: 0;
    color: var(--kfc-text);
    font-family: var(--kfc-font);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
}

#transcend-consent-ui .header__close-button {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
    color: var(--kfc-text);
    cursor: pointer;
    transition: color .2s ease;
}

#transcend-consent-ui .header__close-button:hover,
#transcend-consent-ui .header__close-button:focus-visible {
    background: none;
    color: var(--kfc-red);
}

/* --------------------------------------------------------- scrollable body */

#transcend-consent-ui .modal__scrollable-area {
    flex: 1 1 auto;
    padding: 24px 28px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

#transcend-consent-ui .header__subtitle {
    margin: 0 0 10px;
    color: var(--kfc-text);
    font-family: var(--kfc-font);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
}

#transcend-consent-ui .modal__description {
    margin: 0;
    color: var(--kfc-text);
    font-family: var(--kfc-font);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.65;
}

/* ------------------------------------------------- "Objectivos" header row */

#transcend-consent-ui .purposes__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 26px 0 0;
    padding: 0 0 14px;
    border-bottom: 2px solid var(--kfc-text);
}

#transcend-consent-ui .purposes__title {
    margin: 0;
    color: var(--kfc-text);
    font-family: var(--kfc-font);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
}

#transcend-consent-ui .purposes__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

/* Secondary scale — the primary action in this layer is Salvar. */
#transcend-consent-ui .purposes__actions .button {
    min-width: 0;
    padding: 10px 18px;
    font-size: 12px;
}

/* Reject before accept, matching the banner (DOM order here is the reverse). */
#transcend-consent-ui .purposes__actions #RejectAllAndClose {
    order: 0;
}

#transcend-consent-ui .purposes__actions #AcceptAllAndClose {
    order: 1;
}

/* -------------------------------------------------------- purpose accordion */

#transcend-consent-ui .purposes__list {
    display: block;
}

#transcend-consent-ui .purpose-card {
    border-bottom: 1px solid #e2e2e2;
}

/*
 * The accordion header has no stable class. It is the only direct child of the
 * card that is NOT the [data-open] content panel, so it is matched by exclusion
 * rather than by position or hash.
 */
#transcend-consent-ui .purpose-card > div:not([data-open]) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 0;
}

#transcend-consent-ui .purpose-card button[aria-expanded] {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    padding: 14px 0;
    background: none;
    border: 0;
    border-radius: 0;
    color: var(--kfc-text);
    font-family: var(--kfc-font);
    font-size: 14px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

#transcend-consent-ui .purpose-card button[aria-expanded]:hover,
#transcend-consent-ui .purpose-card button[aria-expanded]:focus-visible {
    background: none;
    color: var(--kfc-red);
}

#transcend-consent-ui .purpose-card__title {
    font-family: var(--kfc-font);
    font-size: 14px;
    font-weight: 700;
    color: inherit;
}

/*
 * Both rotation states are declared so the chevron is deterministic even if
 * Transcend rotates it too. The source SVG points up; closed shows it down.
 */
#transcend-consent-ui .purpose-card .icon {
    display: flex;
    align-items: center;
    color: var(--kfc-red);
    transform: rotate(180deg);
    transition: transform .2s ease;
}

#transcend-consent-ui .purpose-card button[aria-expanded="true"] .icon {
    transform: rotate(0deg);
}

#transcend-consent-ui .purpose-card__description {
    margin: 0;
    padding: 0 0 16px 20px;
    color: #555;
    font-family: var(--kfc-font);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.6;
}

/* "Sempre Ativo" on the essential purpose, and the on/off label on the rest. */
#transcend-consent-ui .purpose-card__state-text {
    flex: 0 0 auto;
    color: #666;
    font-family: var(--kfc-font);
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
}

/* ------------------------------------------------------------------ toggle */

#transcend-consent-ui .toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

#transcend-consent-ui .toggle input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    margin: 0;
}

#transcend-consent-ui .toggle__slider {
    position: relative;
    display: block;
    width: 44px;
    height: 24px;
    background: #bdbdbd;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color .2s ease;
}

#transcend-consent-ui .toggle__slider-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
    color: #bdbdbd;
    transition: transform .2s ease, color .2s ease;
}

/*
 * Driven off the checkbox itself rather than a class modifier: the input is the
 * slider's previous sibling, and :checked is the real state.
 */
#transcend-consent-ui .toggle input[type="checkbox"]:checked + .toggle__slider {
    background: var(--kfc-red);
}

#transcend-consent-ui .toggle input[type="checkbox"]:checked + .toggle__slider .toggle__slider-knob {
    transform: translateX(20px);
    color: var(--kfc-red);
}

#transcend-consent-ui .toggle input[type="checkbox"]:focus-visible + .toggle__slider {
    outline: 2px solid var(--kfc-text);
    outline-offset: 2px;
}

/* Always-on purposes are locked, not merely off. */
#transcend-consent-ui .toggle input[type="checkbox"]:disabled + .toggle__slider {
    opacity: .5;
    cursor: not-allowed;
}

/* ------------------------------------------------------------ save / footer */

#transcend-consent-ui .modal__action-group {
    display: flex;
    justify-content: flex-end;
    flex: 0 0 auto;
    gap: 12px;
    padding: 18px 28px;
    border-top: 1px solid #e2e2e2;
}

#transcend-consent-ui dialog[data-layer="modal"] .footer {
    flex: 0 0 auto;
    padding: 0 28px 20px;
    background: none;
}

#transcend-consent-ui .footer__link-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
}

#transcend-consent-ui .footer__link-group a {
    color: var(--kfc-red);
    font-family: var(--kfc-font);
    font-size: 12px;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    /* Policy link text comes from the dashboard and is currently a raw URL. */
    overflow-wrap: anywhere;
}

#transcend-consent-ui .footer__link-group a:hover,
#transcend-consent-ui .footer__link-group a:focus-visible {
    color: var(--kfc-red-hover);
}

/* Badge + locale picker, as on the banner. */
#transcend-consent-ui dialog[data-layer="modal"] .footer__powered-by,
#transcend-consent-ui dialog[data-layer="modal"] .footer__locale-picker {
    display: none;
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 760px) {
    #transcend-consent-ui dialog[data-layer="modal"] {
        padding: 0;
    }

    #transcend-consent-ui .modal__container {
        max-width: 100%;
        height: 100%;
        max-height: 100%;
    }

    #transcend-consent-ui dialog[data-layer="modal"] .header,
    #transcend-consent-ui .modal__scrollable-area,
    #transcend-consent-ui .modal__action-group {
        padding-right: 18px;
        padding-left: 18px;
    }

    #transcend-consent-ui dialog[data-layer="modal"] .footer {
        padding: 0 18px 16px;
    }

    #transcend-consent-ui .purposes__header {
        align-items: flex-start;
        flex-direction: column;
    }

    #transcend-consent-ui .purposes__actions {
        width: 100%;
    }

    #transcend-consent-ui .purposes__actions .button {
        flex: 1 1 0;
    }

    #transcend-consent-ui .modal__action-group #SaveAndClose {
        width: 100%;
    }
}
