/* ========================================
   AD SLOT SYSTEM - Phase 1
   CLS Protection + Lazy Loading Ready
   ======================================== */

/* Ad Container Base */
.ad-slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 1px dashed var(--border-default);
    border-radius: var(--radius-l);
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Ad Label */
.ad-label {
    display: block;
    text-align: center;
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    margin-bottom: 8px;
}

/* Sponsored Badge */
.sponsored-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    border-radius: 4px;
    z-index: 10;
}

/* Desktop Side Rail (300x250) - Sticky */
.ad-side-rail {
    width: 300px;
    min-height: 250px;
    aspect-ratio: 300 / 250;
    position: sticky;
    top: 140px;
    margin-bottom: 24px;
}

@media (max-width: 1199px) {
    .ad-side-rail {
        display: none;
    }
}

/* Desktop Side Rail Container */
.ad-sidebar {
    display: none;
}

@media (min-width: 1200px) {
    .ad-sidebar {
        display: block;
        width: 300px;
        flex-shrink: 0;
    }
}

/* In-Feed Native Ad (Fluid - matches product card height) */
.ad-in-feed {
    min-height: 380px;
    aspect-ratio: 220 / 380;
    padding: 16px;
}

/* Below Fold Leaderboard (728x90) */
.ad-leaderboard {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    aspect-ratio: 728 / 90;
    margin: 48px auto;
}

@media (max-width: 768px) {
    .ad-leaderboard {
        max-width: 320px;
        aspect-ratio: 320 / 50;
        min-height: 50px;
    }
}

/* Mobile Anchor Ad (320x50) */
.ad-mobile-anchor {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 50px;
    z-index: 100;
    background: white;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) {
    .ad-mobile-anchor {
        display: none;
    }
}

/* Product Detail Page - Above Fold (300x250) */
.ad-pdp-above-fold {
    width: 100%;
    max-width: 300px;
    min-height: 250px;
    aspect-ratio: 300 / 250;
    margin: 24px 0;
}

/* Product Detail Page - Below Prices (728x90) */
.ad-pdp-below-prices {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    aspect-ratio: 728 / 90;
    margin: 32px auto;
}

/* Lazy Load States */
.ad-slot[data-lazy="true"] {
    background: linear-gradient(
        90deg,
        var(--bg-surface) 25%,
        var(--bg-primary) 50%,
        var(--bg-surface) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

.ad-slot[data-loaded="true"] {
    background: transparent;
    border-color: var(--border-default);
}

/* Test Mode - Show border for placeholders */
.ad-slot[data-loaded="true"]:has(.ad-placeholder) {
    border-style: dashed;
    border-color: var(--border-default);
}

/* Visual Separation - Ensure ads don't blend with content */
.ad-section-divider {
    width: 100%;
    height: 1px;
    background: var(--border-default);
    margin: 32px 0;
}

/* High Density User Segmentation */
.user-segment-high-density .ad-in-feed {
    /* Show every 8th product for high-value users */
}

/* Phase 2: Second Side Rail (future) */
.ad-side-rail-secondary {
    display: none;
    /* Activated in Phase 2 */
}

/* A/B Test Variants */
.ab-test-variant-a .ad-in-feed {
    /* Control: every 10th */
}

.ab-test-variant-b .ad-in-feed {
    /* Test: every 8th */
}

/* Ad Close Button (for mobile anchor) */
.ad-close-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
    transition: all 0.2s ease;
}

.ad-close-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Responsive Ad Adjustments */
@media (max-width: 768px) {
    .ad-in-feed {
        min-height: 320px;
        aspect-ratio: 180 / 320;
    }

    .ad-pdp-above-fold {
        max-width: 100%;
        aspect-ratio: 320 / 100;
        min-height: 100px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .ad-slot {
        background: rgba(255, 255, 255, 0.02);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .ad-slot[data-lazy="true"] {
        background: linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.02) 25%,
            rgba(255, 255, 255, 0.05) 50%,
            rgba(255, 255, 255, 0.02) 75%
        );
    }
}
