/**
 * MetSul - Estilos de Ads
 * CLS prevention, responsivo, mobile-first.
 *
 * @package MetSul
 * @since 1.2.0
 */

/* ===========================================
   BASE - CLS Prevention
   =========================================== */
.ms-ad-section {
    padding-top: 20px;
    padding-bottom: 20px;
    background: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ms-ad-placeholder {
    position: relative;
    background: #eee;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid #e0e0e0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    /* CLS: reserva espaço antes do ad carregar */
    min-height: var(--ms-ad-min-height-mobile, 250px);
}

.ms-ad-placeholder::before {
    content: attr(data-label);
    position: absolute;
    top: -18px;
    left: 0;
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ms-ad-placeholder__text {
    font-size: 12px;
    color: #888;
    font-weight: 600;
    text-transform: uppercase;
}

.ms-ad-slot__inner {
    width: 100%;
    min-height: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Shimmer loading (quando vazio) */
.ms-ad-placeholder:not(.ms-ad-slot--loaded)::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0,
            rgba(255, 255, 255, 0.2) 20%,
            rgba(255, 255, 255, 0.5) 60%,
            rgba(255, 255, 255, 0));
    animation: ms-ad-shimmer 2s infinite;
}

@keyframes ms-ad-shimmer {
    100% {
        transform: translateX(100%);
    }
}

/* ===========================================
   MOBILE-ONLY / DESKTOP-ONLY
   =========================================== */
.ms-ad--mobile-only {
    display: flex !important;
}

@media (min-width: 769px) {
    .ms-ad--mobile-only {
        display: none !important;
    }
}

.ms-ad--desktop-only {
    display: none !important;
}

@media (min-width: 769px) {
    .ms-ad--desktop-only {
        display: flex !important;
    }
}

/* ===========================================
   RESPONSIVO - Desktop
   =========================================== */
@media (min-width: 769px) {
    .ms-ad-placeholder {
        min-height: var(--ms-ad-min-height-desktop, 90px);
        max-width: 970px;
    }

    .ms-ad-section {
        padding-top: 24px;
        padding-bottom: 24px;
    }
}

/* ===========================================
   VARIANTES POR POSIÇÃO
   =========================================== */
.ms-ad-section--top .ms-ad-placeholder {
    --ms-ad-min-height-mobile: 100px;
    --ms-ad-min-height-desktop: 90px;
}

@media (min-width: 769px) {
    .ms-ad-section--top .ms-ad-placeholder {
        min-height: 250px;
    }
}

.ms-ad-section--middle,
.ms-ad-section--inter {
    margin: 20px 0;
    background: #fcfcfc;
}

.ms-ad-section--inter .ms-ad-placeholder {
    border: 1px solid #eee;
}

/* Inline (in-article) */
.ms-ad-inline {
    margin: 24px 0;
}

.ms-ad-inline .ms-ad-placeholder {
    max-width: 100%;
}

/* ===========================================
   HEADER BANNER (full-width antes do header)
   Skeleton reserva espaço desde o primeiro paint (CLS)
   =========================================== */
.ms-ad-header-banner {
    height: 114px;
    width: 100%;
    background: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
    /* 320x100 mobile */
    padding: 8px 16px;
}

.ms-ad-header-banner__inner {
    position: relative;
    width: 100%;
    max-width: 970px;
    min-height: 100px;
}

.ms-ad-header-banner__label {
    position: absolute;
    top: -14px;
    left: 0;
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Skeleton: visível até o ad carregar, evita CLS */
.ms-ad-header-banner__skeleton {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, #e8e8e8 0%, #f0f0f0 50%, #e8e8e8 100%);
    background-size: 200% 100%;
    animation: ms-ad-header-skeleton 1.5s ease-in-out infinite;
    pointer-events: none;
}

/* Esconde skeleton quando o slot recebe conteúdo (ad carregou) */
.ms-ad-header-banner__inner:has(.ms-ad-header-banner__slot:not(:empty)) .ms-ad-header-banner__skeleton {
    display: none;
}

@keyframes ms-ad-header-skeleton {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.ms-ad-header-banner__slot {
    position: relative;
    width: 100%;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 769px) {
    .ms-ad-header-banner {
        min-height: 90px;
        /* 728x90 / 970x90 desktop */
        padding: 12px 20px;
    }

    .ms-ad-header-banner__inner {
        min-height: 90px;
    }

    .ms-ad-header-banner__skeleton {
        /* mantém preenchimento */
    }

    .ms-ad-header-banner__slot {
        min-height: 90px;
    }
}

/* ===========================================
   STICKY FOOTER (Allright - 320x50 mobile)
   =========================================== */
.ms-ad-sticky-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50px;
    padding: 6px 12px;
}

.ms-ad-sticky-footer__inner {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-height: 50px;
}

.ms-ad-sticky-footer__label {
    position: absolute;
    top: -12px;
    left: 12px;
    font-size: 9px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ms-ad-sticky-footer__slot {
    width: 100%;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Espaço para não sobrepor conteúdo quando sticky footer visível */
body.ms-has-ads {
    padding-bottom: 80px;
}

@media (min-width: 769px) {
    .ms-ad-sticky-footer {
        min-height: 90px;
        padding: 10px 20px;
    }

    .ms-ad-sticky-footer__inner {
        max-width: 970px;
        min-height: 90px;
    }

    .ms-ad-sticky-footer__slot {
        min-height: 90px;
    }

    body.ms-has-ads {
        padding-bottom: 120px;
    }
}