/* إضافة CSS للـ custom dropdown */
.custom-dropdown-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.custom-dropdown {
    position: relative;
    width: 100%;
    background-color: var(--card-bg-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    min-width: 160px;
    transition: all var(--transition-speed);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.custom-dropdown:hover {
    border-color: var(--primary-color);
    background-color: rgba(255, 255, 255, 0.05);
}

.custom-dropdown.open {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 188, 212, 0.3);
}

.dropdown-selected {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background-color: transparent;
    cursor: pointer;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.dropdown-selected:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.selected-text {
    flex: 1;
    text-align: right;
    direction: rtl;
}

.dropdown-arrow {
    margin-left: 10px;
    transition: transform var(--transition-speed);
    font-size: 0.8rem;
    color: var(--primary-color);
}

.custom-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--card-bg-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.custom-dropdown.open .dropdown-options {
    display: block;
}

.dropdown-option {
    padding: 12px 18px;
    cursor: pointer;
    transition: background-color var(--transition-speed);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    direction: rtl;
    text-align: right;
}

.dropdown-option:last-child {
    border-bottom: none;
}

.dropdown-option:hover {
    background-color: rgba(0, 188, 212, 0.1);
    color: var(--primary-color);
}

.dropdown-option.selected {
    background-color: rgba(0, 188, 212, 0.2);
    color: var(--primary-color);
    font-weight: bold;
}

/* تحسين شكل أزرار وخيارات الدقة والمشغل مع الحفاظ على التوافق */
.control-group {
    min-width: 160px;
    margin: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.control-label {
    margin-left: 10px;
    font-weight: 600;
    color: var(--text-light-color);
    font-size: 1.08rem;
    letter-spacing: 0.5px;
}
.control-select {
    padding: 8px 32px 8px 16px;
    border-radius: 6px;
    background: var(--card-bg-color, #232323);
    color: var(--text-color, #fff);
    border: 1.2px solid var(--primary-color, #00bcd4);
    font-size: 1rem;
    min-width: 100px;
    max-width: 180px;
    width: auto;
    transition: border 0.2s, background 0.2s;
    box-shadow: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300bcd4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 10px center;
    background-size: 14px;
    padding-left: 32px;
    font-weight: 500;
}
.control-select:focus {
    border-color: var(--accent-color, #ffc107);
    outline: none;
    background: #232b;
}
.control-select:hover {
    border-color: var(--primary-color, #00bcd4);
    background-color: rgba(255,255,255,0.04);
}
.control-select option {
    background: #232526;
    color: #fff;
    font-weight: 500;
    font-size: 1rem;
}
@media (max-width: 700px) {
    .controls-container {
        flex-direction: row;
        justify-content: flex-start;
        gap: 6px;
        padding: 6px 0 6px 0;
    }
    .control-select {
        font-size: 0.9rem;
        min-width: 60px;
        max-width: 90px;
        padding: 5px 18px 5px 7px;
        padding-left: 18px;
    }
    .control-label {
        font-size: 0.9rem;
    }
}
@media (max-width: 480px) {
    .controls-container {
        flex-direction: row;
        gap: 4px;
        padding: 4px 0 4px 0;
    }
    .control-select {
        min-width: 50px;
        max-width: 70px;
        font-size: 0.8rem;
        padding: 4px 12px 4px 5px;
        padding-left: 12px;
    }
    .control-label {
        font-size: 0.8rem;
    }
}
/* تحسينات للتوافق مع الأجهزة القديمة */
.custom-dropdown-wrapper select {
    display: none !important;
}

/* تحسينات للأجهزة المحمولة */
@media (max-width: 768px) {
    .custom-dropdown {
        min-width: 140px;
        font-size: 0.9rem;
    }
    
    .dropdown-selected {
        padding: 10px 15px;
    }
    
    .dropdown-option {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    .dropdown-options {
        max-height: 150px;
    }
}

/* تحسينات للشاشات الصغيرة جداً */
@media (max-width: 480px) {
    .custom-dropdown {
        min-width: 120px;
        font-size: 0.8rem;
    }
    
    .dropdown-selected {
        padding: 8px 12px;
    }
    
    .dropdown-option {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* تحسينات للمتصفحات القديمة */
.custom-dropdown {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

.dropdown-selected {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

.dropdown-option {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

/* دعم Internet Explorer */
.custom-dropdown {
    zoom: 1;
}

.dropdown-selected {
    zoom: 1;
}

/* تحسينات للوصولية */
.dropdown-selected[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-option[aria-selected="true"] {
    background-color: rgba(0, 188, 212, 0.2);
    color: var(--primary-color);
    font-weight: bold;
}

/* تحسينات للطباعة */
@media print {
    .custom-dropdown-wrapper {
        display: none;
    }
}

/* تحسينات للشاشات عالية الدقة */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .dropdown-arrow {
        font-size: 0.7rem;
    }
}

/* تحسينات للوضع المظلم */
@media (prefers-color-scheme: dark) {
    .custom-dropdown {
        background-color: #2a2a2a;
        border-color: rgba(255, 255, 255, 0.3);
    }
    
    .dropdown-options {
        background-color: #2a2a2a;
        border-color: rgba(255, 255, 255, 0.3);
    }
    
    .dropdown-option {
        border-bottom-color: rgba(255, 255, 255, 0.2);
    }
}

/* تحسينات للحركة المخفضة */
@media (prefers-reduced-motion: reduce) {
    .custom-dropdown,
    .dropdown-arrow,
    .dropdown-option {
        transition: none;
    }
}

/* إصلاحات للمتصفحات القديمة */
/* Internet Explorer 8-9 */
.lt-ie10 .custom-dropdown {
    background: #333333;
    border: 1px solid #555555;
}

.lt-ie10 .dropdown-options {
    background: #333333;
    border: 1px solid #555555;
}

/* Firefox القديم */
@-moz-document url-prefix() {
    .custom-dropdown {
        -moz-appearance: none;
    }
}

/* Safari القديم */
@media screen and (-webkit-min-device-pixel-ratio:0) {
    .custom-dropdown {
        -webkit-appearance: none;
    }
}

/* تحسينات إضافية للتوافق */
.custom-dropdown * {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

/* دعم اللمس للأجهزة المحمولة */
@media (pointer: coarse) {
    .dropdown-option {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .dropdown-selected {
        min-height: 44px;
    }
}

/* تحسينات للشاشات الكبيرة */
@media (min-width: 1200px) {
    .custom-dropdown {
        min-width: 180px;
    }
}

/* تحسينات للوضع الأفقي على الأجهزة المحمولة */
@media (max-width: 768px) and (orientation: landscape) {
    .dropdown-options {
        max-height: 120px;
    }
}

/* تحسينات للتباين العالي */
@media (prefers-contrast: high) {
    .custom-dropdown {
        border-width: 2px;
    }
    
    .dropdown-option:hover {
        background-color: rgba(0, 188, 212, 0.3);
    }
}

/* إصلاحات للمشغلات - تحسين التوافق */
.player-wrapper video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    background-color: #000;
}

/* تحسينات للمشغلات على الأجهزة القديمة */
.player-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #000;
    overflow: hidden;
}

/* إصلاحات لـ Video.js على الأجهزة القديمة */
.video-js {
    width: 100% !important;
    height: 100% !important;
    background-color: #000 !important;
}

.video-js .vjs-tech {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

/* إصلاحات لـ Plyr على الأجهزة القديمة */
.plyr {
    width: 100% !important;
    height: 100% !important;
}

.plyr video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

/* تحسينات للتحكم في المشغلات */
.vjs-control-bar {
    background: rgba(0, 0, 0, 0.7) !important;
}

.plyr__controls {
    background: rgba(0, 0, 0, 0.7) !important;
}

/* إصلاحات للشاشات الذكية */
@media (min-width: 1920px) {
    .player-container {
        max-width: 1600px;
        margin: 0 auto;
    }
}

/* تحسينات للأداء على الأجهزة القديمة */
.player-wrapper:not(.active) {
    display: none !important;
    visibility: hidden;
}

.player-wrapper.active {
    display: block !important;
    visibility: visible;
}

/* إصلاحات للصوت فقط على الشاشات الذكية */
@media (min-width: 1200px) {
    .player-container {
        min-height: 400px;
    }
    
    .player-wrapper video {
        min-height: 400px;
    }
}

/* تحسينات للتحميل */
.loading {
    background-color: rgba(0, 0, 0, 0.9) !important;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* إصلاحات للمتصفحات التي لا تدعم backdrop-filter */
@supports not (backdrop-filter: blur(5px)) {
    .loading {
        background-color: rgba(0, 0, 0, 0.95) !important;
    }
}

/* تحسينات للنصوص على الأجهزة القديمة */
.buffer-message {
    font-family: Arial, sans-serif;
    line-height: 1.4;
    word-wrap: break-word;
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    hyphens: auto;
}

/* إصلاحات للتمرير السلس */
html {
    scroll-behavior: smooth;
}

/* إصلاح للمتصفحات التي لا تدعم scroll-behavior */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* تحسينات للأمان */
.player-wrapper video {
    pointer-events: auto;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* منع السحب والإفلات */
.player-wrapper video {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

/* تحسينات للوصولية */
.custom-dropdown {
    role: combobox;
    aria-haspopup: listbox;
    aria-expanded: false;
}

.custom-dropdown.open {
    aria-expanded: true;
}

.dropdown-options {
    role: listbox;
}

.dropdown-option {
    role: option;
}

/* تحسينات للتركيز بالوحة المفاتيح */
.dropdown-option:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
    background-color: rgba(0, 188, 212, 0.1);
}

/* إصلاحات للمتصفحات القديمة جداً */
/* Internet Explorer 7 */
*:first-child+html .custom-dropdown {
    background: #333333;
    border: 1px solid #555555;
}

/* Internet Explorer 6 */
* html .custom-dropdown {
    background: #333333;
    border: 1px solid #555555;
}

/* ستايل متقدم وحديث لقوائم المشغل والجودة مع الحفاظ على التوافق */
.controls-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 10px 0 10px 0;
    background: none;
    box-shadow: none;
    border-radius: 0;
    flex-wrap: wrap;
}
.control-group {
    display: flex;
    align-items: center;
    margin: 0;
    min-width: unset;
    gap: 4px;
}
.control-label {
    margin: 0 4px 0 0;
    font-weight: 500;
    color: var(--text-light-color);
    font-size: 0.98rem;
    letter-spacing: 0.2px;
    background: none;
    padding: 0;
    min-width: unset;
}
.control-select {
    padding: 6px 24px 6px 10px;
    border-radius: 5px;
    background: var(--card-bg-color, #232323);
    color: var(--text-color, #fff);
    border: 1px solid var(--primary-color, #00bcd4);
    font-size: 0.97rem;
    min-width: 70px;
    max-width: 110px;
    width: auto;
    transition: border 0.2s, background 0.2s;
    box-shadow: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300bcd4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 8px center;
    background-size: 12px;
    padding-left: 26px;
    font-weight: 500;
}
.control-select:focus {
    border-color: var(--accent-color, #ffc107);
    outline: none;
    background: #232b;
}
.control-select:hover {
    border-color: var(--primary-color, #00bcd4);
    background-color: rgba(255,255,255,0.04);
}
.control-select option {
    background: #232526;
    color: #fff;
    font-weight: 500;
    font-size: 0.97rem;
}
@media (max-width: 700px) {
    .controls-container {
        flex-direction: row;
        justify-content: flex-start;
        gap: 6px;
        padding: 6px 0 6px 0;
    }
    .control-select {
        font-size: 0.9rem;
        min-width: 60px;
        max-width: 90px;
        padding: 5px 18px 5px 7px;
        padding-left: 18px;
    }
    .control-label {
        font-size: 0.9rem;
    }
}
@media (max-width: 480px) {
    .controls-container {
        flex-direction: row;
        gap: 4px;
        padding: 4px 0 4px 0;
    }
    .control-select {
        min-width: 50px;
        max-width: 70px;
        font-size: 0.8rem;
        padding: 4px 12px 4px 5px;
        padding-left: 12px;
    }
    .control-label {
        font-size: 0.8rem;
    }
}
