/**
 * Slots de Monetizacao (Ad Slots)
 * Sistema de placeholders para futuros banners
 * Otimizado para evitar CLS (Cumulative Layout Shift)
 */

.ad-slot {
    position: relative;
    width: 100%;
    margin: 1.5rem auto;
    background: transparent;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Estado vazio - colapsado para nao afetar layout */
.ad-slot:empty {
    display: none;
    height: 0;
    margin: 0;
    padding: 0;
}

/* Quando tiver conteudo, exibe com animacao suave */
.ad-slot:not(:empty) {
    display: block;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ad Slot Topo (Banner Superior) */
.ad-slot-top {
    max-width: 970px;
    min-height: 90px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.ad-slot-top:empty {
    min-height: 0;
}

/* Ad Slot Sidebar (Lateral Desktop) */
.ad-slot-sidebar {
    display: none;
}

@media (min-width: 1280px) {
    .ad-slot-sidebar {
        display: block;
        position: sticky;
        top: 100px;
        float: right;
        width: 300px;
        min-height: 600px;
        margin-left: 2rem;
        margin-bottom: 2rem;
        background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    }

    .ad-slot-sidebar:empty {
        display: none;
        width: 0;
        min-height: 0;
        margin: 0;
    }
}

/* Ad Slot Meio do Conteudo */
.ad-slot-content {
    max-width: 728px;
    min-height: 90px;
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    margin: 2rem auto;
}

.ad-slot-content:empty {
    min-height: 0;
    margin: 0;
}

/* Ad Slot Fim do Conteudo */
.ad-slot-bottom {
    max-width: 970px;
    min-height: 250px;
    background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
    margin-top: 3rem;
}

.ad-slot-bottom:empty {
    min-height: 0;
    margin: 0;
}

/* Indicador visual de slot (apenas em desenvolvimento) */
.ad-slot::before {
    content: attr(data-ad-position);
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(0, 0, 0, 0.1);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    pointer-events: none;
}

/* Remove indicador em producao (quando slot tiver conteudo) */
.ad-slot:not(:empty)::before {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ad-slot-top,
    .ad-slot-bottom {
        min-height: 50px;
        max-width: 320px;
    }

    .ad-slot-content {
        min-height: 50px;
        max-width: 320px;
    }
}

/* Lazy loading optimization */
.ad-slot[data-lazy="true"] {
    min-height: 0;
    content-visibility: auto;
}

/* Prevent layout shift with aspect ratio boxes */
.ad-slot-top,
.ad-slot-content {
    aspect-ratio: 970 / 90;
}

@media (max-width: 768px) {
    .ad-slot-top,
    .ad-slot-content {
        aspect-ratio: 320 / 50;
    }
}

.ad-slot-sidebar {
    aspect-ratio: 300 / 600;
}

.ad-slot-bottom {
    aspect-ratio: 970 / 250;
}

@media (max-width: 768px) {
    .ad-slot-bottom {
        aspect-ratio: 320 / 100;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .ad-slot-top {
        background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    }

    .ad-slot-sidebar {
        background: linear-gradient(135deg, #744210 0%, #c05621 100%);
    }

    .ad-slot-content {
        background: linear-gradient(135deg, #553c9a 0%, #7c3aed 100%);
    }

    .ad-slot-bottom {
        background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    }

    .ad-slot::before {
        color: rgba(255, 255, 255, 0.1);
    }
}

/* Accessibility */
.ad-slot[aria-label]::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
}

.ad-slot:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Performance optimization */
.ad-slot {
    contain: layout style paint;
    will-change: auto;
}

/* Print styles - oculta ads na impressao */
@media print {
    .ad-slot {
        display: none !important;
    }
}
