/* Widget de Código Personalizado */
.custom-code-widget {
    position: relative;
    margin: 20px 0;
    padding: 15px;
    width: 100%;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Ocultar apenas códigos de rastreamento específicos */
.custom-code-widget script[src*="google-analytics"],
.custom-code-widget script[src*="googletagmanager"],
.custom-code-widget script[src*="facebook.net"],
.custom-code-widget .tracking-code,
.custom-code-widget [style*="display: none"][style*="tracking"],
.custom-code-widget [style*="visibility: hidden"][style*="tracking"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
}

/* Garantir que conteúdo visual seja exibido */
.custom-code-widget.content-type-code {
    position: relative;
}

/* Permitir elementos visuais */
.custom-code-widget.content-type-code img,
.custom-code-widget.content-type-code iframe,
.custom-code-widget.content-type-code div[style*="background"],
.custom-code-widget.content-type-code a,
.custom-code-widget.content-type-code span[style*="background"],
.custom-code-widget.content-type-code div[id*="banner"],
.custom-code-widget.content-type-code div[class*="ad"],
.custom-code-widget.content-type-code script[src*="banner"],
.custom-code-widget.content-type-code script[src*="ad"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    left: auto !important;
    top: auto !important;
}

/* Centralização quando ativada */
.custom-code-widget.centered {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    min-height: 200px;
}

/* Estilos específicos para imagens */
.custom-code-widget.content-type-image {
    text-align: center;
}

.custom-code-widget .widget-banner-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    border: none;
    border-radius: 4px;
    transition: transform 0.3s ease;
}

.custom-code-widget .widget-banner-image:hover {
    transform: scale(1.02);
}

.custom-code-widget.centered .widget-banner-image {
    margin: 0 auto;
}

/* Estilos específicos para links */
.custom-code-widget.content-type-link {
    text-align: center;
    padding: 15px;
}

.custom-code-widget .widget-banner-link {
    display: inline-block;
    padding: 12px 24px;
    background-color: #d32f2f;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.custom-code-widget .widget-banner-link:hover {
    background-color: #b71c1c;
    color: white;
    text-decoration: none;
}

.custom-code-widget.centered .widget-banner-link {
    margin: 0 auto;
}

/* Estilos para banners */
.custom-code-widget iframe {
    max-width: 100%;
    height: auto;
    border: none;
    display: block;
    border-radius: 4px;
    margin: 0 auto;
}

.custom-code-widget.centered iframe {
    margin: 0 auto;
}

/* Estilos para divs de placement */
.custom-code-widget div[id*="placement"] {
    margin: 0 auto;
    text-align: center;
}

/* Responsividade */
@media (max-width: 768px) {
    .custom-code-widget {
        padding: 10px 0;
    }
    
    .custom-code-widget iframe {
        max-width: 100%;
        width: 100% !important;
        height: auto;
    }
    
    /* Ajuste para banners 468x60 em mobile */
    .custom-code-widget iframe[width="468"][height="60"] {
        width: 100% !important;
        max-width: 468px;
        height: 60px;
    }
}

@media (max-width: 480px) {
    .custom-code-widget iframe[width="468"][height="60"] {
        width: 100% !important;
        max-width: 320px;
        height: 42px; /* Proporção mantida */
    }
}

/* Estilos para scripts de anúncios */
.custom-code-widget script {
    display: block;
}

/* Container para anúncios */
.custom-code-widget .ad-container {
    width: 100%;
    text-align: center;
    margin: 0 auto;
    padding: 10px 0;
}

/* Publicidade label */
.custom-code-widget::before {
    content: "PUBLICIDADE";
    position: absolute;
    top: -1px;
    right: 15px;
    background: #dc3545;
    color: white;
    padding: 4px 12px;
    font-size: 10px;
    font-family: 'Inter', Arial, sans-serif;
    font-weight: 600;
    border-radius: 0 0 4px 4px;
    text-transform: uppercase;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    letter-spacing: 0.5px;
}

.widget-title + .custom-code-widget::before {
    content: "PUBLICIDADE";
}

/* Estilos específicos para o widget quando usado como banner */
.banner-widget .custom-code-widget {
    background: transparent;
    border: none;
    box-shadow: none;
}

.banner-widget .custom-code-widget.centered {
    display: block;
    text-align: center;
}

.banner-widget .custom-code-widget iframe,
.banner-widget .custom-code-widget div {
    margin: 0 auto;
    display: block;
}

/* Estilos para o formulário do widget no admin */
.widget-field-group {
    border: 1px solid #ddd;
    padding: 10px;
    margin: 10px 0;
    background-color: #f9f9f9;
    border-radius: 4px;
}

.widget-field-group p {
    margin: 10px 0;
}

.widget-field-group label {
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

.upload-image-button {
    margin-top: 5px;
    margin-left: 5px;
}

.widget-field-group textarea {
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
}

/* Responsividade para admin */
@media (max-width: 782px) {
    .widget-field-group {
        padding: 8px;
    }
    
    .upload-image-button {
        width: 100%;
        margin-top: 10px;
        margin-left: 0;
    }
}