/*
 * Public Consent Banner CSS - Consent Manager - GDPR & CCPA
 * (Versão Responsiva para Textos Longos)
 */

:root {
    --wpcm-bg-color: #ffffff;
    --wpcm-text-color: #404040;
    --wpcm-btn-accept-bg-color: #4f46e5;
    --wpcm-btn-accept-text-color: #ffffff;
    --wpcm-btn-reject-bg-color: transparent;
    --wpcm-btn-reject-text-color: #404040;
    --wpcm-btn-reject-border-color: #cccccc;
    --wpcm-toggle-bg-color: #4f46e5;
}

/* --- BANNER (Fixo) --- */
#wpcm-consent-banner {
    display: flex; padding: 24px; box-sizing: border-box; z-index: 999999;
    background-color: var(--wpcm-bg-color) !important; 
    color: var(--wpcm-text-color) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    position: fixed !important;
    max-width: 100% !important; /* Segurança contra overflow */
}

#wpcm-consent-banner * {
    box-sizing: border-box;
}

.wpcm-banner-position-footer {
    position: fixed; bottom: 0; left: 0; width: 100%;
    align-items: center; justify-content: space-between; flex-direction: row;
    box-shadow: 0 -2px 20px rgba(0,0,0,0.15);
}
.wpcm-banner-position-bottom-left, .wpcm-banner-position-bottom-right {
    position: fixed; bottom: 20px; width: 400px; max-width: calc(100% - 40px);
    border-radius: 10px; flex-direction: column; box-shadow: 0 5px 25px rgba(0,0,0,0.2);
}
.wpcm-banner-position-bottom-left { left: 20px; }
.wpcm-banner-position-bottom-right { right: 20px; }

.wpcm-banner-position-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    max-width: calc(100% - 40px) !important; /* Garante margem em telas pequenas */
    border-radius: 10px;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    max-height: 90vh; /* Evita cortar em telas baixas */
    overflow-y: auto; /* Permite scroll se texto for gigante */
}

.wpcm-banner-position-modal .wpcm-banner-content {
    margin-right: 0; margin-bottom: 15px;
}

#wpcm-consent-banner .wpcm-banner-content { flex: 1; margin-right: 20px; }
.wpcm-banner-position-bottom-left .wpcm-banner-content,
.wpcm-banner-position-bottom-right .wpcm-banner-content { margin-right: 0; margin-bottom: 15px; }

#wpcm-consent-banner .wpcm-banner-text {
    margin: 0; font-size: 14px; line-height: 1.5;
    color: inherit; font-weight: normal;
}
#wpcm-consent-banner .wpcm-policy-link {
    color: inherit; text-decoration: underline; margin-left: 5px;
}

/* --- AÇÕES (CORREÇÃO DO PROBLEMA) --- */
#wpcm-consent-banner .wpcm-banner-actions {
    display: flex; 
    align-items: center; 
    justify-content: flex-end; 
    gap: 10px;
    flex-wrap: wrap !important; /* PERMITE QUEBRA DE LINHA */
    width: 100%;
}

/* --- BOTÕES (BLINDAGEM) --- */
#wpcm-consent-banner .wpcm-btn {
    border-radius: 6px !important; 
    padding: 8px 15px !important; 
    font-size: 13px !important;
    font-weight: 600 !important; 
    cursor: pointer; 
    text-decoration: none !important;
    transition: all 0.2s ease; 
    line-height: 1.2 !important; 
    border: 2px solid transparent !important;
    background-image: none !important; 
    box-shadow: none !important; 
    text-shadow: none !important;
    height: auto !important; 
    min-height: 0 !important;
    display: inline-block !important;
    margin: 0 !important;
    /* Impede que botões com texto gigante vazem */
    max-width: 100%; 
    white-space: normal !important; 
    text-align: center;
}

/* Aceitar */
#wpcm-consent-banner .wpcm-btn-accept {
    background-color: var(--wpcm-btn-accept-bg-color) !important; 
    color: var(--wpcm-btn-accept-text-color) !important;
    border-color: var(--wpcm-btn-accept-bg-color) !important;
    flex-grow: 1; /* Ocupa espaço disponível se quebrar linha */
}

/* Rejeitar */
#wpcm-consent-banner .wpcm-btn-reject {
    background-color: transparent !important; 
    border-color: var(--wpcm-btn-reject-border-color) !important;
    color: var(--wpcm-btn-reject-text-color) !important;
    flex-grow: 1; /* Ocupa espaço disponível se quebrar linha */
}

/* Settings (Link "Gerenciar/Escolher") */
#wpcm-consent-banner .wpcm-btn-settings {
    background: transparent !important; 
    color: var(--wpcm-text-color) !important;
    border: none !important; 
    text-decoration: underline !important; 
    padding: 8px 5px !important;
    /* CORREÇÃO DE POSIÇÃO: Empurra para a esquerda */
    margin-right: auto !important; 
    margin-left: 0 !important;
}

/* --- MODAL DE PREFERÊNCIAS (Reset Agressivo) --- */
#wpcm-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); z-index: 9999999;
    display: flex; align-items: center; justify-content: center; padding: 15px;
    backdrop-filter: blur(2px);
}
#wpcm-modal-wrap {
    background: #fff; width: 600px; max-width: 100%; max-height: 90vh;
    border-radius: 12px; box-shadow: 0 15px 50px rgba(0,0,0,0.3);
    display: flex; flex-direction: column; overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    text-align: left;
}
#wpcm-modal-wrap *, #wpcm-modal-wrap *::before, #wpcm-modal-wrap *::after {
    box-sizing: border-box;
}

#wpcm-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 15px 25px; border-bottom: 1px solid #eee;
    background: #fff; flex-shrink: 0;
}
#wpcm-modal-title {
    font-size: 18px; font-weight: 700; color: #222;
    margin: 0; line-height: 1.2; padding: 0;
}
#wpcm-modal-close {
    background: transparent; border: none; font-size: 24px;
    line-height: 1; color: #999; cursor: pointer;
    padding: 0; width: auto; height: auto;
}

#wpcm-modal-body { padding: 0; overflow-y: auto; flex: 1; }
#wpcm-modal-wrap .wpcm-category-row { padding: 20px 25px; border-bottom: 1px solid #f0f0f0; }

#wpcm-modal-wrap .wpcm-category-header { display: flex; align-items: center; margin-bottom: 10px; }
#wpcm-modal-wrap .wpcm-category-expand {
    appearance: none; -webkit-appearance: none;
    background: transparent; border: none; border-radius: 4px;
    box-shadow: none; text-shadow: none;
    padding: 4px; margin: 0 10px 0 -5px;
    width: 24px; height: 24px; min-width: 0; min-height: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--wpcm-btn-accept-bg-color);
    font-size: 12px; line-height: 1;
    cursor: pointer; transition: transform 0.25s ease;
}
#wpcm-modal-wrap .wpcm-category-expand[aria-expanded="true"] { transform: rotate(90deg); }

#wpcm-modal-wrap .wpcm-category-title {
    font-size: 16px; font-weight: 600; color: #222;
    margin: 0; line-height: 1.3;
}
#wpcm-modal-wrap .wpcm-category-description {
    font-size: 13px; color: #666; margin: 0;
    line-height: 1.5; padding-left: 28px;
}

#wpcm-modal-wrap .wpcm-category-toggle { margin-left: auto; padding-left: 15px; }
#wpcm-modal-wrap .wpcm-toggle-switch {
    position: relative; width: 44px; height: 24px; flex-shrink: 0;
    min-width: 44px; display: inline-block;
}
#wpcm-modal-wrap .wpcm-toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
#wpcm-modal-wrap .wpcm-toggle-slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc; transition: .3s; border-radius: 34px;
}
#wpcm-modal-wrap .wpcm-toggle-slider:before {
    position: absolute; content: ""; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background-color: white;
    transition: .3s; border-radius: 50%;
}
#wpcm-modal-wrap input:checked + .wpcm-toggle-slider { background-color: var(--wpcm-btn-accept-bg-color); }
#wpcm-modal-wrap input:checked + .wpcm-toggle-slider:before { transform: translateX(20px); }

#wpcm-modal-wrap .wpcm-services-list { margin-top: 15px; padding: 0 0 0 30px; display: none; }
#wpcm-modal-wrap .wpcm-service-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 15px; margin-bottom: 8px;
    background: #f7f7f7; border-radius: 8px; border: 1px solid #eee;
}
#wpcm-modal-wrap .wpcm-service-title { font-size: 14px; font-weight: 600; color: #333; margin: 0 0 3px 0; line-height: 1.2; }
#wpcm-modal-wrap .wpcm-service-desc { font-size: 12px; color: #777; margin: 0; line-height: 1.4; }
#wpcm-modal-wrap .wpcm-toggle-sm { width: 36px; height: 20px; min-width: 36px; }
#wpcm-modal-wrap .wpcm-toggle-sm .wpcm-toggle-slider:before { height: 14px; width: 14px; left: 3px; bottom: 3px; }
#wpcm-modal-wrap .wpcm-toggle-sm input:checked + .wpcm-toggle-slider:before { transform: translateX(16px); }

#wpcm-modal-footer {
    padding: 15px 25px; border-top: 1px solid #eee;
    background: #fff; text-align: right; flex-shrink: 0;
}
#wpcm-modal-footer .wpcm-btn {
    margin: 0; padding: 10px 25px; font-size: 14px;
    background-color: var(--wpcm-btn-accept-bg-color);
    color: var(--wpcm-btn-accept-text-color);
    border-radius: 6px; font-weight: 600;
    border: none; box-shadow: none; cursor: pointer;
}

/* --- RESPONSIVO --- */
@media (max-width: 768px) {
    #wpcm-consent-banner { flex-direction: column; }
    .wpcm-banner-position-footer .wpcm-banner-actions { margin-top: 15px; width: 100%; }
    .wpcm-banner-position-footer .wpcm-btn { flex: 1; text-align: center; }
    #wpcm-consent-banner .wpcm-banner-content { margin-right: 0; }
    .wpcm-banner-position-bottom-left, .wpcm-banner-position-bottom-right {
        width: auto; left: 15px; right: 15px; bottom: 15px;
    }
    /* Regra para modal responsivo */
    .wpcm-banner-position-modal { width: auto; left: 15px; right: 15px; }
    #wpcm-modal-wrap { height: 100%; max-height: 100%; border-radius: 0; }
}

/* --- Branding --- */
.wpcm-branding {
    text-align: center; margin: 12px 10px 0 10px; padding-top: 10px;
    border-top: 1px solid rgba(128, 128, 128, 0.2);
}
.wpcm-branding a {
    font-size: 12px; color: var(--wpcm-text-color) !important; opacity: 0.7;
    text-decoration: none; transition: opacity 0.2s ease;
}
.wpcm-branding a:hover { opacity: 1; text-decoration: underline; }

.wpcm-banner-position-footer .wpcm-branding {
    margin-top: 0; margin-left: 20px; padding-top: 0; border-top: 0; text-align: left;
}