/**
 * Estilos específicos para anuncios de AdSense
 * Optimizados para diferentes ubicaciones y dispositivos
 */

/* Contenedores base para anuncios */
.adsense-container {
    margin: 1rem auto;
    text-align: center;
    clear: both;
    overflow: hidden;
}

/* Estilos específicos por ubicación */

/* Portada: Después de la cabecera */
.adsense-home_after_header {
    margin: 2rem auto;
    max-width: 970px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
    padding: 1rem;
}

/* Portada: Entre categorías */
.adsense-home_between_categories {
    margin: 3rem auto;
    max-width: 728px;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    padding: 2rem 1rem;
    background: rgba(249, 250, 251, 0.5);
}

/* Barra lateral principal */
.adsense-sidebar_main {
    margin: 1.5rem 0;
    max-width: 300px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Artículo: Antes del contenido */
.adsense-single_before_content {
    margin: 2rem auto;
    max-width: 728px;
    border-bottom: 2px solid #f3f4f6;
    padding-bottom: 1.5rem;
}

/* Artículo: Después del contenido */
.adsense-single_after_content {
    margin: 2rem auto;
    max-width: 728px;
    border-top: 2px solid #f3f4f6;
    padding-top: 1.5rem;
}

/* Anuncios intersticiales */
.adsense-interstitial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.adsense-interstitial-container {
    background-color: white;
    border-radius: 8px;
    max-width: 95%;
    max-height: 95vh;
    width: 728px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.adsense-interstitial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.adsense-interstitial-close {
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    padding: 0 5px;
}

.adsense-interstitial-close:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.adsense-interstitial-content {
    padding: 20px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 250px;
    text-align: center;
}

/* Placeholders para anuncios */
.adsense-placeholder {
    border: 2px dashed #d1d5db;
    background-color: #f9fafb;
    color: #6b7280;
    font-family: monospace;
    font-size: 0.875rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    word-break: break-word;
    position: relative;
}

.adsense-placeholder::before {
    content: "📢";
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 1.2rem;
}

/* Responsive Design */

/* Tablets */
@media (max-width: 768px) {
    .adsense-home_after_header,
    .adsense-home_between_categories,
    .adsense-single_before_content,
    .adsense-single_after_content {
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    
    .adsense-sidebar_main {
        max-width: 100%;
        margin: 1rem 0;
    }
    
    .adsense-interstitial-container {
        width: 95%;
        margin: 1rem;
    }
}

/* Móviles */
@media (max-width: 480px) {
    .adsense-container {
        margin: 1rem 0;
        padding: 0.5rem;
    }
    
    .adsense-home_after_header,
    .adsense-home_between_categories {
        padding: 1rem 0.5rem;
        margin: 1.5rem 0;
    }
    
    .adsense-single_before_content,
    .adsense-single_after_content {
        margin: 1.5rem 0;
        padding: 1rem 0;
    }
    
    .adsense-sidebar_main {
        padding: 0.75rem;
        margin: 1rem 0;
    }
    
    .adsense-interstitial-container {
        width: 98%;
        margin: 0.5rem;
    }
    
    .adsense-interstitial-content {
        padding: 15px;
        min-height: 200px;
    }
}

/* Modo oscuro */
@media (prefers-color-scheme: dark) {
    .adsense-home_after_header {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .adsense-home_between_categories {
        background: rgba(17, 24, 39, 0.5);
        border-color: #374151;
    }
    
    .adsense-sidebar_main {
        background: #1f2937;
        border-color: #374151;
    }
    
    .adsense-single_before_content,
    .adsense-single_after_content {
        border-color: #374151;
    }
    
    .adsense-placeholder {
        background-color: #1f2937;
        border-color: #4b5563;
        color: #9ca3af;
    }
}

/* Animaciones suaves */
.adsense-container {
    transition: opacity 0.3s ease-in-out;
}

.adsense-container.loading {
    opacity: 0.7;
}

/* Estilos para anuncios automáticos */
.adsense-auto {
    position: relative;
}

.adsense-auto::after {
    content: "Anuncio";
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: #9ca3af;
    background: #f9fafb;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}

/* Mejoras de accesibilidad */
.adsense-container:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Optimizaciones de rendimiento */
.adsense-container img {
    max-width: 100%;
    height: auto;
}

.adsense-container iframe {
    max-width: 100%;
}

/* Estados de carga */
.adsense-container.ads-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Estilos para diferentes formatos de anuncio */
.adsense-rectangle {
    display: inline-block;
    vertical-align: top;
}

.adsense-leaderboard {
    width: 100%;
    max-width: 728px;
}

.adsense-banner {
    width: 100%;
    max-width: 468px;
}

.adsense-skyscraper {
    width: 160px;
    height: 600px;
}

/* Compatibilidad con temas oscuros de Tailwind */
.dark .adsense-home_after_header {
    background: rgba(255, 255, 255, 0.05);
}

.dark .adsense-home_between_categories {
    background: rgba(17, 24, 39, 0.5);
    border-color: #374151;
}

.dark .adsense-sidebar_main {
    background: #1f2937;
    border-color: #374151;
}

.dark .adsense-single_before_content,
.dark .adsense-single_after_content {
    border-color: #374151;
}

.dark .adsense-placeholder {
    background-color: #1f2937;
    border-color: #4b5563;
    color: #9ca3af;
}