/* ======================================
   AD OPTIMIZATION STYLES
   AdSense Policy Compliant + High eCPM/CTR
   ====================================== */

/* ---- AD UNIT BASE STYLES ---- */
.ad-unit {
    position: relative;
    margin: 1rem 0;
    clear: both;
    text-align: center;
    min-height: 50px;
}

.ad-unit__label {
    font-size: 0.6875rem;
    color: #8392ab;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    text-align: center;
    padding: 2px 0;
    line-height: 1;
    margin-bottom: 4px;
    font-weight: 500;
}

.ad-unit__content {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-unit__spacer {
    height: 0.75rem;
}

/* ---- POSITION-SPECIFIC STYLES ---- */

/* Header Ad - Responsive leaderboard */
.ad-unit--header {
    background: #ffffff;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    margin: 0;
    padding: 8px 0 4px;
    z-index: 999;
}

.ad-unit--header .ad-unit__content {
    max-height: 100px;
    overflow: hidden;
}

.ad-unit--header .ad-unit__spacer {
    height: 0;
}

/* Sidebar Ad - Native card style with optional sticky */
.ad-unit--sidebar {
    background: #ffffff;
    border-radius: 1rem;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    padding: 1rem;
    margin: 0;
}

.ad-unit--sidebar .ad-unit__label {
    text-align: left;
    margin-bottom: 8px;
}

.ad-unit--sticky {
    position: -webkit-sticky;
    position: sticky;
    top: 100px;
    z-index: 100;
}

/* Content Ad - Blends with dashboard cards */
.ad-unit--content {
    background: #ffffff;
    border-radius: 1rem;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    padding: 1rem;
    transition: box-shadow 0.3s ease;
}

.ad-unit--content:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* Footer Ad - Clean minimal */
.ad-unit--footer {
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 12px 0 8px;
    margin: 1rem 0 0;
}

/* Between Messages Ad */
.ad-unit--between_messages {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.75rem;
    padding: 0.75rem;
    margin: 0.75rem 0;
}

/* ---- SKELETON LOADER ---- */
.ad-unit__skeleton {
    width: 100%;
    min-height: 90px;
    border-radius: 8px;
    overflow: hidden;
}

.ad-skeleton-pulse {
    width: 100%;
    height: 90px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: adSkeletonPulse 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes adSkeletonPulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- RESPONSIVE AD SIZING ---- */

/* Mobile: Banner 320x50 */
@media (max-width: 575.98px) {
    .ad-unit--header .ad-unit__content {
        max-height: 60px;
    }
    
    .ad-unit--header {
        padding: 4px 0 2px;
    }
    
    .ad-unit--sidebar {
        border-radius: 0.75rem;
        padding: 0.75rem;
    }
    
    .ad-unit--sticky {
        position: relative;
        top: auto;
    }
    
    .ad-unit--content {
        padding: 0.75rem;
        border-radius: 0.75rem;
    }
    
    .ad-skeleton-pulse {
        height: 60px;
    }
    
    .ad-unit__label {
        font-size: 0.625rem;
    }
}

/* Tablet: Medium rectangle 300x250 or Banner 468x60 */
@media (min-width: 576px) and (max-width: 767.98px) {
    .ad-unit--header .ad-unit__content {
        max-height: 80px;
    }
    
    .ad-unit--sticky {
        position: relative;
        top: auto;
    }
    
    .ad-skeleton-pulse {
        height: 70px;
    }
}

/* Desktop: Leaderboard 728x90 */
@media (min-width: 768px) {
    .ad-unit--header .ad-unit__content {
        max-height: 100px;
    }
    
    .ad-unit--sidebar .ad-unit__content {
        min-height: 250px;
    }
    
    .ad-skeleton-pulse {
        height: 90px;
    }
    
    .ad-unit--sidebar .ad-skeleton-pulse {
        height: 250px;
    }
}

/* Large Desktop: Large Leaderboard 970x90 */
@media (min-width: 1200px) {
    .ad-unit--header .ad-unit__content {
        max-height: 110px;
    }
}

/* ---- COOKIE CONSENT BANNER ---- */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    background: #ffffff;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
    border-top: 2px solid #cb0c9f;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Open Sans', sans-serif;
}

.cookie-consent--visible {
    transform: translateY(0);
}

.cookie-consent--hidden {
    transform: translateY(100%);
}

.cookie-consent__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.cookie-consent__content {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    flex: 1;
    min-width: 0;
}

.cookie-consent__icon {
    font-size: 1.75rem;
    color: #cb0c9f;
    flex-shrink: 0;
    margin-top: 2px;
}

.cookie-consent__title {
    font-weight: 700;
    font-size: 0.9375rem;
    color: #344767;
    margin-bottom: 0.25rem;
}

.cookie-consent__description {
    font-size: 0.8125rem;
    color: #67748e;
    line-height: 1.5;
    margin-bottom: 0;
}

.cookie-consent__link {
    color: #cb0c9f;
    text-decoration: underline;
    font-weight: 600;
}

.cookie-consent__link:hover {
    color: #9b0978;
}

.cookie-consent__actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.cookie-consent__btn {
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.cookie-consent__btn--accept {
    background: linear-gradient(310deg, #7928ca, #cb0c9f);
    color: #fff;
}

.cookie-consent__btn--accept:hover {
    background: linear-gradient(310deg, #6a1fb5, #b50a8e);
    box-shadow: 0 4px 12px rgba(203, 12, 159, 0.3);
}

.cookie-consent__btn--essential {
    background: #f0f2f5;
    color: #344767;
}

.cookie-consent__btn--essential:hover {
    background: #e3e6ea;
}

.cookie-consent__btn--settings {
    background: transparent;
    color: #67748e;
    border: 1px solid #d2d6da;
}

.cookie-consent__btn--settings:hover {
    background: #f0f2f5;
    color: #344767;
}

/* Cookie Settings Panel */
.cookie-consent__settings-panel {
    border-top: 1px solid #e9ecef;
    max-width: 1200px;
    margin: 0 auto;
}

.cookie-consent__settings-inner {
    padding: 1rem 1.5rem 1.25rem;
}

.cookie-consent__settings-title {
    font-weight: 700;
    color: #344767;
    margin-bottom: 0.75rem;
}

.cookie-consent__option {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f0f2f5;
}

.cookie-consent__option:last-of-type {
    border-bottom: none;
}

/* Mobile cookie consent */
@media (max-width: 767.98px) {
    .cookie-consent__inner {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
    }
    
    .cookie-consent__content {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .cookie-consent__icon {
        display: none;
    }
    
    .cookie-consent__actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .cookie-consent__btn {
        flex: 1;
        text-align: center;
        padding: 0.625rem 0.75rem;
    }
    
    .cookie-consent__settings-inner {
        padding: 0.75rem 1rem;
    }
}

/* ---- ANCHOR AD (Footer Replacement) ---- */
.ad-anchor {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99990;
    background: #ffffff;
    border-top: 1px solid #e9ecef;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    text-align: center;
    padding: 4px 0;
    transition: transform 0.3s ease;
}

.ad-anchor.ad-anchor--hidden {
    transform: translateY(100%);
}

.ad-anchor__close {
    position: absolute;
    top: -12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #d2d6da;
    color: #67748e;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    z-index: 1;
    transition: all 0.2s ease;
}

.ad-anchor__close:hover {
    background: #f0f2f5;
    color: #344767;
}

.ad-anchor__label {
    font-size: 0.5625rem;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

/* Hide anchor ad when cookie consent is visible */
.cookie-consent--visible ~ .ad-anchor {
    transform: translateY(100%);
}

/* ---- LAZY LOADING STATES ---- */
.ad-unit[data-ad-lazy="true"]:not(.ad-unit--loaded) {
    min-height: 50px;
}

.ad-unit--loaded .ad-unit__skeleton {
    display: none;
}

.ad-unit--loaded .ad-unit__ad {
    display: block !important;
}

/* ---- VIEWABILITY TRACKING ---- */
.ad-unit[data-ad-viewable="true"] {
    /* Just for tracking, no visual change */
}

/* ---- A/B TESTING VARIANT STYLES ---- */
/* Variant B: Alternate ad positioning */
[data-ad-variant="B"] .ad-unit--variant-b.ad-unit--content {
    border-left: 3px solid #cb0c9f;
    background: linear-gradient(135deg, #ffffff 0%, #fdf2f8 100%);
}

[data-ad-variant="B"] .ad-unit--variant-b .ad-unit__label {
    color: #cb0c9f;
    font-weight: 600;
}

[data-ad-variant="B"] .ad-unit--header {
    background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 100%);
}

/* ---- CUMULATIVE LAYOUT SHIFT PREVENTION ---- */
.ad-unit--header {
    min-height: 50px;
}

.ad-unit--content {
    min-height: 90px;
}

.ad-unit--sidebar {
    min-height: 100px;
}

@media (min-width: 768px) {
    .ad-unit--header {
        min-height: 90px;
    }
    
    .ad-unit--sidebar {
        min-height: 250px;
    }
}

/* ---- PRINT STYLES ---- */
@media print {
    .ad-unit,
    .cookie-consent,
    .ad-anchor {
        display: none !important;
    }
}

/* ---- REDUCED MOTION ---- */
@media (prefers-reduced-motion: reduce) {
    .ad-skeleton-pulse {
        animation: none;
        background: #f0f0f0;
    }
    
    .cookie-consent {
        transition: none;
    }
}

/* ---- HIGH CONTRAST MODE ---- */
@media (prefers-contrast: high) {
    .ad-unit__label {
        color: #000;
        font-weight: 700;
    }
    
    .ad-unit--content,
    .ad-unit--sidebar {
        border-width: 2px;
        border-color: #000;
    }
}
