/**
 * סגנונות חזית לבאנרים
 * TTFC Banner Manager
 * 
 * הערה: כל התמונות משתמשות ב-object-fit: contain
 * כדי להציג את התמונה במלואה עם שוליים ריקים במקום חיתוך
 */

/* === מיכל באנר בסיסי === */
.ttfc-banner-wrapper {
    position: relative;
    margin: 20px 0;
    clear: both;
}

.ttfc-banner-wrapper.loading {
    min-height: 100px;
    background: linear-gradient(90deg, #f0f0f0 25%, #f8f8f8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

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

/* === באנר בסיסי === */
.ttfc-banner {
    display: block;
    width: 100%;
    height: auto;
    text-decoration: none;
    overflow: hidden;
    transition: all 0.3s ease;
    /* רקע גרדיאנט כברירת מחדל כדי למלא שוליים ריקים */
    background: inherit;
}

.ttfc-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.ttfc-banner img,
.ttfc-banner-image {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    /* רקע שקוף כדי שהשוליים יקבלו את צבע הרקע של הקונטיינר */
    background: transparent;
}

/* תמיכה ב-aspect-ratio מודרני */
.ttfc-banner-image[style*="aspect-ratio"] {
    object-fit: contain;
    width: 100%;
    height: auto;
}

/* === סוגי באנרים === */

/* Ultra Wide Hero Banner (19:6) */
.ttfc-banner-ultra_wide_hero {
    aspect-ratio: 19/6;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    overflow: hidden;
}

.ttfc-banner-ultra_wide_hero img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Ultra Wide Panoramic Banner (32:9) */
.ttfc-banner-ultra_wide_panoramic {
    aspect-ratio: 32/9;
    background: linear-gradient(135deg, #2196f3 0%, #21cbf3 100%);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.ttfc-banner-ultra_wide_panoramic img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.6s ease;
}

.ttfc-banner-ultra_wide_panoramic:hover img {
    transform: scale(1.05);
}

/* אפקט פרלקס לבאנר פנורמי */
.ttfc-banner-ultra_wide_panoramic.has-parallax img {
    transform: translateZ(0);
    will-change: transform;
}

/* טקסט על הבאנר הפנורמי */
.ttfc-banner-ultra_wide_panoramic .banner-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 20px 30px;
    border-radius: 8px;
    text-align: center;
    backdrop-filter: blur(5px);
    max-width: 80%;
}

.ttfc-banner-ultra_wide_panoramic .banner-overlay.position-left {
    left: 10%;
    transform: translate(0, -50%);
}

.ttfc-banner-ultra_wide_panoramic .banner-overlay.position-right {
    left: 90%;
    transform: translate(-100%, -50%);
}

.ttfc-banner-ultra_wide_panoramic .banner-overlay.position-center-left {
    left: 25%;
    transform: translate(-50%, -50%);
}

.ttfc-banner-ultra_wide_panoramic .banner-overlay.position-center-right {
    left: 75%;
    transform: translate(-50%, -50%);
}

/* Wide Standard Banner (16:9) */
.ttfc-banner-wide_standard {
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 6px;
    overflow: hidden;
}

/* Standard Classic Banner (4:3) */
.ttfc-banner-standard_classic {
    aspect-ratio: 4/3;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    border-radius: 6px;
    overflow: hidden;
}

/* Square Banner (1:1) */
.ttfc-banner-square {
    aspect-ratio: 1/1;
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    border-radius: 8px;
    overflow: hidden;
    max-width: 400px;
    margin: 0 auto;
}

/* Portrait Sidebar Banner (3:4) */
.ttfc-banner-portrait_sidebar {
    aspect-ratio: 3/4;
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    border-radius: 6px;
    overflow: hidden;
    max-width: 300px;
}

/* Banner Narrow (8:1) */
.ttfc-banner-banner_narrow {
    aspect-ratio: 8/1;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    border-radius: 4px;
    overflow: hidden;
}

/* Mobile Wide Banner (16:5) */
.ttfc-banner-mobile_wide {
    aspect-ratio: 16/5;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    border-radius: 6px;
    overflow: hidden;
}

/* Hero Banner - תאימות לאחור */
.ttfc-banner-hero_banner {
    width: 100%;
    max-width: 1920px;
    margin: 0 auto;
}

.ttfc-banner-hero_banner img {
    aspect-ratio: 1920 / 600;
    object-fit: contain;
}

/* Leaderboard */
.ttfc-banner-leaderboard {
    max-width: 728px;
    margin: 20px auto;
}

.ttfc-banner-leaderboard img {
    aspect-ratio: 728 / 90;
}

/* Medium Rectangle */
.ttfc-banner-medium_rectangle {
    max-width: 300px;
    margin: 20px 0;
}

.ttfc-banner-medium_rectangle img {
    aspect-ratio: 300 / 250;
}

/* Half Page */
.ttfc-banner-half_page {
    max-width: 300px;
    margin: 20px 0;
}

.ttfc-banner-half_page img {
    aspect-ratio: 300 / 600;
}

/* Mobile Banner */
.ttfc-banner-mobile_banner {
    display: none;
    max-width: 320px;
    margin: 10px auto;
}

@media (max-width: 768px) {
    .ttfc-banner-mobile_banner {
        display: block;
    }
    
    /* הסתרת באנרים גדולים במובייל */
    .ttfc-banner-hero_banner,
    .ttfc-banner-leaderboard {
        display: none;
    }
}

/* Billboard */
.ttfc-banner-billboard {
    max-width: 970px;
    margin: 20px auto;
}

.ttfc-banner-billboard img {
    aspect-ratio: 970 / 250;
}

/* === באנרים מיוחדים === */

/* In-Feed Banner */
.ttfc-banner-in_feed {
    margin: 40px 0;
    padding: 20px 0;
    border-top: 1px solid #e1e1e1;
    border-bottom: 1px solid #e1e1e1;
}

/* Interstitial/Popup */
.ttfc-banner-interstitial {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    max-width: 90%;
    max-height: 90%;
    background: white;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
}

.ttfc-banner-interstitial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    cursor: pointer;
}

.ttfc-banner-interstitial-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    color: #333;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 10;
}

.ttfc-banner-interstitial-close:hover {
    background: #f0f0f0;
    transform: scale(1.1);
}

/* Sticky Footer */
.ttfc-banner-sticky_footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9000;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    padding: 10px;
    text-align: center;
}

.ttfc-banner-sticky_footer .ttfc-banner {
    margin: 0 auto;
    max-width: 728px;
}

.ttfc-banner-sticky_footer-close {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 25px;
    height: 25px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* Native/Content Banner */
.ttfc-banner-native {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin: 30px 0;
}

.ttfc-banner-native-label {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    margin-bottom: 10px;
    display: block;
}

.ttfc-banner-native-content {
    display: flex;
    gap: 20px;
}

.ttfc-banner-native-image {
    flex: 0 0 150px;
}

.ttfc-banner-native-image img {
    width: 100%;
    border-radius: 4px;
}

.ttfc-banner-native-text {
    flex: 1;
}

.ttfc-banner-native-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.ttfc-banner-native-description {
    font-size: 14px;
    line-height: 1.6;
    color: #666;
}

/* === רוטציה === */
.ttfc-banner-block-rotation {
    position: relative;
    overflow: hidden;
}

.ttfc-banner-block-rotation .ttfc-banner {
    display: none;
}

.ttfc-banner-block-rotation .ttfc-banner.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

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

/* === רספונסיביות === */
@media (max-width: 1200px) {
    .ttfc-banner-billboard {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    /* התאמות למובייל */
    .ttfc-banner-wrapper {
        margin: 15px 0;
    }
    
    .ttfc-banner-native-content {
        flex-direction: column;
    }
    
    .ttfc-banner-native-image {
        flex: 1;
    }
    
    /* באנרים דביקים במובייל */
    .ttfc-banner-sticky_footer {
        padding: 5px;
    }
}

@media (max-width: 480px) {
    /* באנרים למסכים קטנים במיוחד */
    .ttfc-banner-medium_rectangle,
    .ttfc-banner-half_page {
        max-width: 100%;
    }
}

/* === Lazy Loading === */
.ttfc-banner[data-lazy="true"] {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.ttfc-banner.loaded {
    opacity: 1;
}

/* === הודעת נגישות === */
.ttfc-banner-accessibility {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* === RTL Support === */
[dir="rtl"] .ttfc-banner-interstitial-close {
    right: auto;
    left: 10px;
}

[dir="rtl"] .ttfc-banner-sticky_footer-close {
    right: auto;
    left: 5px;
}

[dir="rtl"] .ttfc-banner-native-content {
    flex-direction: row-reverse;
}

/* === Debug Mode === */
.ttfc-banner-debug {
    position: relative;
}

.ttfc-banner-debug::before {
    content: attr(data-banner-id) " | " attr(data-block-id);
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    padding: 2px 8px;
    font-size: 10px;
    z-index: 10;
    pointer-events: none;
}

/* === פופ-אפ באנרים === */
.ttfc-popup-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.8) !important;
    z-index: 99999999 !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    visibility: hidden !important;
}

.ttfc-popup-overlay.show {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.ttfc-popup-modal {
    position: relative !important;
    max-width: 90vw !important;
    max-height: 90vh !important;
    background: white !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    animation: popupSlideIn 0.4s ease-out !important;
    transform: translateY(0) !important;
    display: block !important;
    z-index: 99999999 !important;
    width: auto !important;
    height: auto !important;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ttfc-popup-content {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    display: block !important;
    background: transparent !important;
}

.ttfc-popup-content .ttfc-banner-wrapper,
.ttfc-popup-content .ttfc-banner-wrapper-interstitial,
.ttfc-popup-content .ttfc-banner,
.ttfc-popup-content .ttfc-banner-interstitial {
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transition: none !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    overflow: visible !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.ttfc-popup-content .ttfc-banner:hover {
    transform: none;
    box-shadow: none;
}

.ttfc-popup-content .ttfc-banner img,
.ttfc-popup-content .ttfc-banner-image {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    border-radius: 0 !important;
    object-fit: fill !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    z-index: 1 !important;
}

.ttfc-popup-close {
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    background: rgba(0, 0, 0, 0.7) !important;
    color: white !important;
    border: none !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    font-size: 20px !important;
    line-height: 1 !important;
    z-index: 999999999 !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-family: Arial, sans-serif !important;
    font-weight: bold !important;
    pointer-events: auto !important;
}

.ttfc-popup-close:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.ttfc-popup-close:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* מניעת גלילה כאשר פופ-אפ פתוח */
body.ttfc-popup-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* התאמות למובייל */
/* התאמות לדסקטופ */
@media (min-width: 769px) {
    .ttfc-popup-modal {
        min-width: 400px !important;
        min-height: 300px !important;
    }
    
    .ttfc-popup-content {
        min-height: 300px !important;
    }
    
    .ttfc-popup-content .ttfc-banner {
        min-height: 300px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

@media (max-width: 768px) {
    .ttfc-popup-modal {
        max-width: 95vw;
        max-height: 95vh;
        margin: 10px;
        border-radius: 8px;
    }
    
    .ttfc-popup-close {
        top: 10px;
        right: 10px;
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    
    .ttfc-popup-overlay {
        padding: 10px;
    }
}

/* התאמות למסכים קטנים מאוד */
@media (max-width: 480px) {
    .ttfc-popup-modal {
        max-width: 100vw;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        width: 100%;
        height: 100%;
    }
    
    .ttfc-popup-overlay {
        padding: 0;
        align-items: stretch;
    }
    
    .ttfc-popup-content {
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* אנימציות לסגירה */
.ttfc-popup-overlay.closing {
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
    display: none !important;
    visibility: hidden !important;
}

.ttfc-popup-overlay.closing .ttfc-popup-modal {
    animation: popupSlideOut 0.3s ease-in !important;
}

@keyframes popupSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }
}

/* תמיכה ב-RTL */
.rtl .ttfc-popup-close {
    right: auto;
    left: 15px;
}

@media (max-width: 768px) {
    .rtl .ttfc-popup-close {
        left: 10px;
        right: auto;
    }
}

/* נגישות */
.ttfc-popup-overlay:focus-within .ttfc-popup-modal {
    outline: 3px solid #005ccc;
    outline-offset: 2px;
}

/* תיקון חירום לתמונות שלא מוצגות */
.ttfc-popup-overlay .ttfc-popup-modal .ttfc-popup-content .ttfc-banner-wrapper .ttfc-banner img,
.ttfc-popup-overlay .ttfc-popup-modal .ttfc-popup-content .ttfc-banner-wrapper .ttfc-banner .ttfc-banner-image,
.ttfc-popup-overlay .ttfc-popup-modal .ttfc-popup-content img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: fill !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    z-index: 10 !important;
    /* background: red !important; - הוסר לאחר דיבאג */
    min-height: 100px !important;
    max-width: none !important;
    max-height: none !important;
    transform: none !important;
    filter: none !important;
    clip: none !important;
    clip-path: none !important;
}

/* אם התמונה לא נטענת, הצג רקע צבעוני */
.ttfc-popup-content .ttfc-banner-wrapper::before {
    content: "תמונה לא נטענה" !important;
    display: block !important;
    width: 100% !important;
    height: 200px !important;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4) !important;
    color: white !important;
    text-align: center !important;
    line-height: 200px !important;
    font-size: 18px !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1 !important;
}

/* הבטחת תצוגה נכונה של כל סוגי הבאנרים בפופ-אפ */
.ttfc-popup-content .ttfc-banner-flexible_wide,
.ttfc-popup-content .ttfc-banner-interstitial,
.ttfc-popup-content .ttfc-banner-ultra_wide_hero,
.ttfc-popup-content .ttfc-banner-wide_standard,
.ttfc-popup-content .ttfc-banner-standard_classic,
.ttfc-popup-content .ttfc-banner-square,
.ttfc-popup-content .ttfc-banner-portrait_sidebar,
.ttfc-popup-content .ttfc-banner-banner_narrow,
.ttfc-popup-content .ttfc-banner-mobile_wide {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    position: relative !important;
}

.ttfc-popup-content .ttfc-banner-flexible_wide img,
.ttfc-popup-content .ttfc-banner-interstitial img,
.ttfc-popup-content .ttfc-banner-ultra_wide_hero img,
.ttfc-popup-content .ttfc-banner-wide_standard img,
.ttfc-popup-content .ttfc-banner-standard_classic img,
.ttfc-popup-content .ttfc-banner-square img,
.ttfc-popup-content .ttfc-banner-portrait_sidebar img,
.ttfc-popup-content .ttfc-banner-banner_narrow img,
.ttfc-popup-content .ttfc-banner-mobile_wide img {
    width: 100% !important;
    height: 100% !important;
    object-fit: fill !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}
