/* تحسينات YouTube المتقدمة */

/* حاوي الفيديو الرئيسي */
.youtube-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.youtube-container:hover {
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

/* مشغل YouTube */
.youtube-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    transition: all 0.3s ease;
}

.youtube-player:hover {
    transform: scale(1.01);
}

/* مؤشر التحميل */
.youtube-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #ff0000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1;
}

.youtube-container.loaded::before {
    display: none;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* تحسين العرض على الأجهزة المحمولة */
@media (max-width: 768px) {
    .youtube-container {
        border-radius: 0;
        margin: 0 -10px;
        width: calc(100% + 20px);
        box-shadow: none;
    }
    
    .youtube-container:hover {
        transform: none;
        box-shadow: none;
    }
    
    .youtube-player:hover {
        transform: none;
    }
}

/* تحسين العرض على الشاشات الصغيرة */
@media (max-width: 480px) {
    .youtube-container {
        margin: 0 -15px;
        width: calc(100% + 30px);
    }
}

/* وضع الشاشة الكاملة */
.youtube-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    padding-bottom: 0;
    z-index: 9999;
    border-radius: 0;
}

/* أزرار التحكم الإضافية */
.video-controls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.youtube-container:hover .video-controls {
    opacity: 1;
}

.control-btn {
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: rgba(0,0,0,0.9);
    transform: scale(1.05);
}

/* تحسينات إضافية للأداء */
.youtube-container[data-loading="true"] {
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
                linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    animation: loading 1s linear infinite;
}

@keyframes loading {
    0% { background-position: 0 0, 0 10px, 10px -10px, -10px 0px; }
    100% { background-position: 20px 20px, 20px 30px, 30px 10px, 10px 20px; }
}

/* تحسينات للوصولية */
.youtube-player:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* تحسينات للطباعة */
@media print {
    .youtube-container {
        display: none;
    }
}

/* تحسينات للوضع الليلي */
@media (prefers-color-scheme: dark) {
    .youtube-container {
        box-shadow: 0 4px 20px rgba(255,255,255,0.1);
    }
    
    .youtube-container:hover {
        box-shadow: 0 8px 30px rgba(255,255,255,0.15);
    }
}
