/* AE Consent — Banner, modal e botao flutuante (visual neutro, configuravel via CSS vars) */

.ae-consent-root {
    --aec-bg: #ffffff;
    --aec-text: #1f2937;
    --aec-primary: #2563eb;
    --aec-primary-text: #ffffff;
    --aec-secondary: #e5e7eb;
    --aec-secondary-text: #1f2937;
    --aec-radius: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
}

/* Tudo oculto por padrao; revelado por JS/anti-flash conforme o estado */
.aec-banner,
.aec-modal-overlay,
.aec-float-btn {
    display: none;
}

/* ── Banner ── */
.aec-banner {
    position: fixed;
    z-index: 999999;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    width: min(960px, calc(100% - 32px));
    background: var(--aec-bg);
    color: var(--aec-text);
    border-radius: var(--aec-radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    padding: 22px 24px;
    flex-direction: column;
    gap: 16px;
}

/* Anti-flash: o banner so aparece quando o documento esta marcado como "sem consentimento" */
html.ae-needs-consent .aec-banner {
    display: flex;
}

/* Posicoes alternativas */
.aec-pos-bottom-left .aec-banner {
    left: 24px;
    transform: none;
    width: min(440px, calc(100% - 32px));
}
.aec-pos-bottom-right .aec-banner {
    left: auto;
    right: 24px;
    transform: none;
    width: min(440px, calc(100% - 32px));
}

.aec-banner-title {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 700;
    color: var(--aec-text);
}

.aec-banner-text {
    margin: 0;
    font-size: 14px;
    color: var(--aec-text);
    opacity: 0.92;
}

.aec-policy-link {
    color: var(--aec-primary);
    text-decoration: underline;
}

.aec-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

/* ── Botoes ── */
.aec-btn {
    appearance: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 100px;
    transition: filter 0.15s ease, background 0.15s ease;
    line-height: 1;
}
.aec-btn:hover {
    filter: brightness(0.95);
}
.aec-btn-primary {
    background: var(--aec-primary);
    color: var(--aec-primary-text);
}
.aec-btn-secondary {
    background: var(--aec-secondary);
    color: var(--aec-secondary-text);
}

/* ── Modal ── */
.aec-modal-overlay {
    position: fixed;
    z-index: 1000000;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ae-consent-root.aec-modal-open .aec-modal-overlay {
    display: flex;
}

.aec-modal {
    background: var(--aec-bg);
    color: var(--aec-text);
    border-radius: var(--aec-radius);
    width: min(560px, 100%);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.aec-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 22px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.aec-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.aec-modal-close {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: var(--aec-text);
    opacity: 0.6;
}
.aec-modal-close:hover {
    opacity: 1;
}

.aec-modal-body {
    padding: 8px 22px;
    overflow-y: auto;
}

.aec-modal-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    padding: 18px 22px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* ── Categorias ── */
.aec-cat {
    padding: 16px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.aec-cat:last-child {
    border-bottom: none;
}

.aec-cat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.aec-cat-name {
    font-size: 15px;
    font-weight: 700;
}

.aec-cat-always {
    font-size: 12px;
    font-weight: 600;
    color: var(--aec-primary);
    opacity: 0.8;
}

.aec-cat-desc {
    margin: 6px 0 0;
    font-size: 13px;
    opacity: 0.8;
}

/* Switch */
.aec-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.aec-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.aec-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--aec-secondary);
    border-radius: 100px;
    transition: background 0.2s;
}
.aec-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.aec-switch input:checked + .aec-slider {
    background: var(--aec-primary);
}
.aec-switch input:checked + .aec-slider::before {
    transform: translateX(20px);
}

/* ── Botao flutuante ── */
.aec-float-btn {
    position: fixed;
    z-index: 999998;
    left: 20px;
    bottom: 20px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: var(--aec-primary);
    color: var(--aec-primary-text);
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    padding: 0;
}
.aec-float-btn svg {
    width: 24px;
    height: 24px;
}

/* Mostra o botao flutuante apenas quando JA consentiu (sem banner aberto) e o modal esta fechado */
html:not(.ae-needs-consent) .ae-consent-root:not(.aec-modal-open) .aec-float-btn {
    display: flex;
}

/* ── Desktop: modal vira painel lateral (slide) no canto inferior esquerdo ── */
@media (min-width: 601px) {
    .ae-consent-root .aec-modal-overlay {
        justify-content: flex-start;
        align-items: flex-end;
        padding: 24px;
    }
    .ae-consent-root .aec-modal {
        width: min(440px, 100%);
        max-height: 88vh;
    }
    .ae-consent-root.aec-modal-open .aec-modal {
        animation: aec-slide-in 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
    }
    /* Botoes do rodape lado a lado (sem empilhar) */
    .ae-consent-root .aec-modal-foot {
        flex-wrap: nowrap;
        gap: 8px;
    }
    .ae-consent-root .aec-modal-foot .aec-btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 10px 8px;
        font-size: 13px;
        text-align: center;
        white-space: nowrap;
    }
}

@keyframes aec-slide-in {
    from { transform: translateX(-120%); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
}

/* ── Mobile (compacto) ── */
@media (max-width: 600px) {
    .aec-banner {
        left: 0;
        right: 0;
        bottom: 0;
        transform: none;
        width: 100%;
        border-radius: var(--aec-radius) var(--aec-radius) 0 0;
        padding: 12px 14px;
        gap: 10px;
    }
    .aec-pos-bottom-left .aec-banner,
    .aec-pos-bottom-right .aec-banner {
        left: 0;
        right: 0;
        width: 100%;
    }
    .aec-banner-title {
        font-size: 15px;
        margin: 0 0 2px;
    }
    .aec-banner-text {
        font-size: 12.5px;
        line-height: 1.4;
    }
    .aec-banner-actions {
        gap: 8px;
    }
    .aec-banner-actions .aec-btn {
        flex: 1 1 auto;
        text-align: center;
        padding: 9px 12px;
        font-size: 13px;
    }

    /* Modal e botao flutuante tambem mais enxutos */
    .aec-modal-body { padding: 4px 16px; }
    .aec-modal-head { padding: 14px 16px; }
    .aec-cat { padding: 12px 0; }

    /* Botoes do modal lado a lado no mobile */
    .aec-modal-foot {
        flex-wrap: nowrap;
        gap: 6px;
        padding: 12px;
    }
    .aec-modal-foot .aec-btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 9px 6px;
        font-size: 12px;
        text-align: center;
    }
    .aec-float-btn {
        width: 40px;
        height: 40px;
        left: 14px;
        bottom: 14px;
    }
    .aec-float-btn svg { width: 20px; height: 20px; }
}
