/**
 * Footer Ads Styles for Affiliate Link Manager
 */

/* Footer Ad Container */
.alm-footer-ad-container {
    position: fixed;
    bottom: 0;
    z-index: 999999;
    background: transparent;
    box-shadow: none;
    border: 0;
    max-width: 100%;
    width: max-content;
    transition: all 0.3s ease;
}

/* Position Variants */
.alm-footer-ad-container.alm-position-bottom-left {
    left: 20px;
    right: auto;
    max-width: 320px;
}

.alm-footer-ad-container.alm-position-bottom-center {
    left: 50%;
    transform: translateX(-50%);
    max-width: 728px;
}

.alm-footer-ad-container.alm-position-bottom-right {
    right: 20px;
    left: auto;
    max-width: 320px;
}

/* Footer Ad Content */
.alm-footer-ad-content {
    position: relative;
    padding: 0;
    background: transparent;
    line-height: 0;
}

/* Close Button (small, subtle, no text) */
.alm-footer-ad-close {
    position: absolute;
    top: -10px;
    right: -6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(22px, 2.2vw + 14px, 28px);
    height: clamp(22px, 2.2vw + 14px, 28px);
    padding: 0;
    background: rgba(17, 17, 17, .78);
    color: #fff;
    border: 0;
    border-radius: 50%;
    font-size: clamp(15px, 1vw + 10px, 18px);
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    transition: background-color .2s ease, transform .2s ease;
}

.alm-footer-ad-close:hover {
    background: #000;
    transform: scale(1.08);
}

.alm-footer-ad-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Ad Wrapper */
.alm-footer-ad-wrapper {
    display: block;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.alm-footer-ad-wrapper.alm-loading {
    opacity: 0.7;
}

/* Ad Link */
.alm-footer-ad-link {
    display: block;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.alm-footer-ad-link:hover {
    transform: scale(1.02);
}

.alm-footer-ad-link:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Ad Image */
.alm-footer-ad-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, .22);
    transition: opacity 0.3s ease;
    margin: 0 auto;
}

.alm-footer-ad-image.alm-fade-out {
    opacity: 0;
}

.alm-footer-ad-image.alm-fade-in {
    opacity: 1;
}

/* Loading Spinner */
.alm-footer-ad-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.alm-footer-ad-loading.alm-show {
    display: block;
}

.alm-loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: alm-spin 1s linear infinite;
}

@keyframes alm-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Fade Animations */
.alm-footer-ad-container.alm-fade-in {
    animation: almFadeInUp 0.5s ease forwards;
}

.alm-footer-ad-container.alm-fade-out {
    animation: almFadeOutDown 0.3s ease forwards;
}

@keyframes almFadeInUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes almFadeOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(100%);
    }
}

/* Center position fade animation adjustment */
.alm-footer-ad-container.alm-position-bottom-center.alm-fade-in {
    animation: almFadeInUpCenter 0.5s ease forwards;
}

.alm-footer-ad-container.alm-position-bottom-center.alm-fade-out {
    animation: almFadeOutDownCenter 0.3s ease forwards;
}

@keyframes almFadeInUpCenter {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes almFadeOutDownCenter {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(100%);
    }
}

/* Mobile & Android: full width footer ad */
@media (max-width: 768px) {
    .alm-footer-ad-container,
    .alm-footer-ad-container.alm-position-bottom-left,
    .alm-footer-ad-container.alm-position-bottom-center,
    .alm-footer-ad-container.alm-position-bottom-right {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        transform: none !important;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .alm-footer-ad-content {
        width: 100%;
    }

    .alm-footer-ad-wrapper,
    .alm-footer-ad-link {
        width: 100%;
    }

    .alm-footer-ad-image {
        width: 100%;
        max-width: 100%;
        height: auto;
        border-radius: 0;
        box-shadow: none;
    }

    /* Close button stays inside the screen */
    .alm-footer-ad-close {
        top: 6px;
        right: 6px;
    }

    .alm-footer-ad-container.alm-fade-in,
    .alm-footer-ad-container.alm-position-bottom-center.alm-fade-in {
        animation: almFadeInUp 0.5s ease forwards;
    }

    .alm-footer-ad-container.alm-fade-out,
    .alm-footer-ad-container.alm-position-bottom-center.alm-fade-out {
        animation: almFadeOutDown 0.3s ease forwards;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .alm-footer-ad-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .alm-footer-ad-container,
    .alm-footer-ad-wrapper,
    .alm-footer-ad-link,
    .alm-footer-ad-image {
        transition: none !important;
        animation: none !important;
    }
    
    .alm-loading-spinner {
        animation: none !important;
    }
}

/* Print Styles */
@media print {
    .alm-footer-ad-container {
        display: none !important;
    }
}

