/* TTFC Ad Banner - Frontend Styles */

.ttfc-ad-banner {
    position: relative;
    text-align: center;
    clear: both;
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    margin-top: 15px;
    margin-bottom: 15px;
    line-height: 0;
    background: #f0f0f0;
}

/* Dismiss (close) button */
.ttfc-ad-dismiss-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
    padding: 0;
    transition: background 0.2s;
}

.ttfc-ad-dismiss-btn:hover {
    background: rgba(0, 0, 0, 0.85);
}

[dir="rtl"] .ttfc-ad-dismiss-btn {
    left: 6px;
    right: auto;
}

.ttfc-ad-banner * {
    box-sizing: border-box;
}

/* Position-specific styles */
.ttfc-ad-position-header-top {
    margin: 0 auto 10px;
    padding: 5px 0;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.ttfc-ad-position-in-content {
    margin: 25px auto;
    padding: 15px 0;
}

.ttfc-ad-position-before-content {
    margin: 0 auto 25px;
}

.ttfc-ad-position-after-content {
    margin: 25px auto 0;
}

.ttfc-ad-position-footer {
    margin: 10px auto 0;
    padding: 5px 0;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.ttfc-ad-position-sidebar {
    margin: 15px 0;
}

/* Side banners - fixed, desktop only */
.ttfc-ad-position-side-right,
.ttfc-ad-position-side-left {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9990;
    width: 120px;
    max-width: 120px;
    margin: 0;
    background: transparent;
    line-height: 0;
}

.ttfc-ad-position-side-right {
    right: 10px;
    left: auto;
}

.ttfc-ad-position-side-left {
    left: 10px;
    right: auto;
}

.ttfc-ad-position-side-right .ttfc-ad-img,
.ttfc-ad-position-side-left .ttfc-ad-img {
    width: 120px;
    height: auto;
    max-height: 400px;
    object-fit: contain;
}

@media (max-width: 1400px) {
    .ttfc-ad-position-side-right,
    .ttfc-ad-position-side-left {
        display: none !important;
    }
}

/* Image styles */
.ttfc-ad-link {
    display: block;
    width: 100%;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.ttfc-ad-link:hover {
    opacity: 0.92;
}

.ttfc-ad-img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
    border-radius: 0;
}

/* Original size mode - show image as-is */
.ttfc-ad-original-size {
    width: auto;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.ttfc-ad-original-size .ttfc-ad-link {
    display: inline-block;
    width: auto;
}

.ttfc-ad-original-size .ttfc-ad-img {
    width: auto;
    height: auto;
    max-width: 100%;
    object-fit: none;
}

/* Desktop/Mobile image toggling */
.ttfc-ad-img-mobile {
    display: none;
}

@media (max-width: 768px) {
    .ttfc-ad-img-desktop {
        display: none;
    }

    .ttfc-ad-img-mobile {
        display: block;
    }
}

/* Device targeting (server-side primary, CSS fallback) */
.ttfc-ad-device-desktop {
    display: block;
}

.ttfc-ad-device-mobile {
    display: none;
}

@media (max-width: 768px) {
    .ttfc-ad-device-desktop {
        display: none;
    }

    .ttfc-ad-device-mobile {
        display: block;
    }
}

/* Slider */
.ttfc-ad-slider {
    position: relative;
    overflow: hidden;
    width: 100%;
}

.ttfc-ad-slide {
    width: 100%;
}

.ttfc-ad-slide-active {
    animation: ttfcAdSlideFade 0.5s ease;
}

@keyframes ttfcAdSlideFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ttfc-ad-slider-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 5;
}

.ttfc-ad-slider-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.ttfc-ad-slider-dot:hover {
    background: rgba(255, 255, 255, 0.7);
}

.ttfc-ad-dot-active {
    background: #fff;
}

/* HTML content */
.ttfc-ad-html-content {
    max-width: 100%;
    overflow: hidden;
}

.ttfc-ad-html-content iframe {
    max-width: 100%;
}

/* Popup */
.ttfc-ad-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: ttfcAdFadeIn 0.3s ease;
}

.ttfc-ad-popup-container {
    position: relative;
    max-width: 700px;
    width: 100%;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: ttfcAdSlideUp 0.3s ease;
}

.ttfc-ad-popup-container .ttfc-ad-img {
    border-radius: 0;
}

.ttfc-ad-popup-close {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    line-height: 32px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s;
    padding: 0;
}

.ttfc-ad-popup-close:hover {
    background: rgba(0, 0, 0, 0.85);
}

@keyframes ttfcAdFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ttfcAdSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* RTL adjustments */
[dir="rtl"] .ttfc-ad-popup-close {
    left: 8px;
    right: auto;
}

/* Accessibility: reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ttfc-ad-popup-overlay,
    .ttfc-ad-popup-container {
        animation: none;
    }
    .ttfc-ad-link:hover {
        opacity: 1;
    }
}

/* Print: hide ads */
@media print {
    .ttfc-ad-banner,
    .ttfc-ad-popup-overlay {
        display: none !important;
    }
}
