/* ============================================
   מערכת פרסומות - Advertising System
   ============================================ */

:root {
    --ad-sidebar-width: 300px;
}

/* פרסומת מסך מלא */
.ad-fullscreen-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999; /* מתחת לתיבת ההודעות אבל מעל הכל */
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(5px);
}

.ad-fullscreen-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.ad-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.ad-image:hover {
    transform: scale(1.02);
}

/* בקרת פרסומת - עיצוב פשוט ועדין */
.ad-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.98);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ad-timer-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ad-timer-label {
    color: #666;
    font-size: 13px;
    font-weight: 400;
}

.ad-timer-seconds {
    background: #f5f5f5;
    color: #333;
    font-size: 15px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 6px;
    min-width: 35px;
    text-align: center;
    border: 1px solid #e0e0e0;
}

/* כפתור דילוג - עיצוב פשוט */
.ad-skip-btn {
    background: #333;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ad-skip-btn:hover:not(:disabled) {
    background: #000;
}

.ad-skip-btn:disabled {
    background: #ddd;
    color: #999;
    cursor: not-allowed;
}

/* כפתור פרסום - עיצוב פשוט */
.ad-promote-btn {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.ad-promote-btn:hover {
    background: rgba(0, 0, 0, 0.85);
    transform: translateX(-50%) translateY(-2px);
}

/* ============================================
   פרסומת צד (דסקטופ בלבד)
   ============================================ */

.ad-sidebar-container {
    position: fixed;
    right: 0;
    top: 0;
    width: var(--ad-sidebar-width); /* רוחב קבוע במקום אחוזים */
    height: 100vh;
    padding-top: 120px; /* מתחת לסרגל + חיפוש */
    z-index: 999; /* מתחת למודעת fullscreen ולתיבת הודעות */
    animation: slideInRight 0.5s ease;
    pointer-events: auto;
}

.ad-sidebar-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: transparent; /* הסרת רקע לבן */
    border-radius: 12px 0 0 12px;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.ad-sidebar-image {
    width: 100%;
    height: 100%; /* תפיסת כל הגובה */
    object-fit: cover;
    transition: transform 0.3s ease;
}

.ad-sidebar-image:hover {
    transform: scale(1.05);
}

.ad-promote-btn-sidebar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    padding: 12px;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    backdrop-filter: blur(10px);
}

.ad-promote-btn-sidebar:hover {
    background: #000;
}

/* ============================================
   אנימציות
   ============================================ */

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

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

/* ============================================
   התאמה למובייל
   ============================================ */

@media (max-width: 768px) {
    /* הסתרת פרסומת צד במובייל */
    .ad-sidebar-container {
        display: none !important;
    }

    :root {
        --ad-sidebar-width: 0px;
    }

    body.has-sidebar-ad {
        padding-inline-start: 0;
        padding-inline-end: 0;
    }

    body.has-sidebar-ad .scroll-to-bottom {
        left: 20px !important;
        right: auto !important;
    }

    html[dir="rtl"] body.has-sidebar-ad .scroll-to-bottom {
        right: 20px !important;
        left: auto !important;
    }
    
    .ad-fullscreen-content {
        max-width: 95%;
        padding: 20px;
    }
    
    .ad-image {
        max-height: 60vh;
    }
    
    .ad-controls {
        flex-direction: column;
        gap: 10px;
        padding: 15px 20px;
    }
    
    .ad-timer-container {
        flex-direction: column;
        text-align: center;
        gap: 5px;
    }
    
    .ad-skip-btn {
        width: 100%;
        padding: 14px 20px;
    }
    
    .ad-promote-btn {
        bottom: -70px;
        font-size: 14px;
        padding: 10px 20px;
    }
}

/* התאמה לטאבלטים */
@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --ad-sidebar-width: 280px;
    }
}

/* התאמה למסכים גדולים */
@media (min-width: 1920px) {
    :root {
        --ad-sidebar-width: 350px;
    }
}

/* ============================================
   שיפורים נוספים
   ============================================ */

/* מניעת גלילה כשיש מודעת fullscreen */
body:has(.ad-fullscreen-container) {
    overflow: hidden;
}

/* כיווץ התוכן כשיש פרסומת צד */
body.has-sidebar-ad .app-container {
    width: calc(100% - var(--ad-sidebar-width));
    max-width: none;
    margin: 0;
    margin-left: 0;
    margin-right: auto;
    transition: width 0.3s ease;
}

html[dir="rtl"] body.has-sidebar-ad .app-container {
    margin-right: 0;
    margin-left: auto;
}

body.has-sidebar-ad .messages-area {
    width: 100%;
}

body.has-sidebar-ad .scroll-to-bottom {
    left: auto !important;
    right: calc(var(--ad-sidebar-width) + 20px) !important;
    transition: right 0.3s ease;
}

html[dir="rtl"] body.has-sidebar-ad .scroll-to-bottom {
    right: auto !important;
    left: calc(var(--ad-sidebar-width) + 20px) !important;
    transition: left 0.3s ease;
}

/* אפקט טשטוש ברקע */
.ad-fullscreen-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: inherit;
    filter: blur(10px);
    z-index: -1;
}

/* אפקט hover על תמונות עם קישור */
.ad-image[style*="cursor: pointer"],
.ad-sidebar-image[style*="cursor: pointer"] {
    position: relative;
}

.ad-image[style*="cursor: pointer"]::after,
.ad-sidebar-image[style*="cursor: pointer"]::after {
    content: '🔗 לחץ לפתיחה';
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.ad-image[style*="cursor: pointer"]:hover::after,
.ad-sidebar-image[style*="cursor: pointer"]:hover::after {
    opacity: 1;
}

/* אנימציה לכפתורים */
.ad-skip-btn, .ad-promote-btn, .ad-promote-btn-sidebar {
    position: relative;
    overflow: hidden;
}

.ad-skip-btn::before,
.ad-promote-btn::before,
.ad-promote-btn-sidebar::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ad-skip-btn:hover::before,
.ad-promote-btn:hover::before,
.ad-promote-btn-sidebar:hover::before {
    width: 300px;
    height: 300px;
}

/* RTL Support */
[dir="rtl"] .ad-sidebar-container {
    right: auto;
    left: 0;
    border-radius: 0 12px 12px 0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

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

[dir="rtl"] .ad-sidebar-container {
    animation: slideInLeft 0.5s ease;
}
