/* --- الجزء الأول: مشغل الفيديو والسيرفرات --- */
.ml-player-wrapper { 
    position: relative; 
    margin-bottom: 20px;
    background: #0f0f0f; 
    padding: 6px; 
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.6);
    direction: rtl;
}

.ml-player { 
    position: relative;
    width: 100%; 
    aspect-ratio: 16/9; 
    background: #000; 
    border-radius: 5px; 
    overflow: hidden; 
    display: flex;
    justify-content: center;
    align-items: center;
}

.ml-player iframe { width: 100%; height: 100%; border: 0; }

.audio-player-box {
    width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    background: linear-gradient(135deg, #121212, #1a252f);
}

.audio-player-box audio { filter: invert(100%) hue-rotate(180deg) brightness(1.2); height: 35px; }

.ml-servers-wrapper { margin-top: 8px; width: 100%; border-top: 1px solid #1a1a1a; padding-top: 8px; }

.ml-servers-scroll {
    display: flex !important; flex-wrap: nowrap !important; 
    overflow-x: auto !important; gap: 5px; 
    padding: 2px 0 6px 0 !important;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; 
}

.ml-servers-scroll::-webkit-scrollbar { display: none; }

.ml-server-btn {
    flex: 0 0 auto !important; padding: 3px 10px !important; 
    font-size: 10px !important; font-weight: 600;
    background: #181818; color: #777; border: 1px solid #222;
    border-radius: 3px; cursor: pointer; height: 26px; 
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}

.ml-server-btn:hover { background: #222; color: #eee; border-color: #444; }

.ml-server-btn.active { background: #ff0000 !important; color: #fff !important; border-color: #ff0000 !important; }

/* شاشة التحميل */
.player-loader { 
    position: absolute; top: 6px; left: 6px; right: 6px;
    height: calc(100% - 50px); 
    display: flex; justify-content: center; align-items: center; 
    background: rgba(0, 0, 0, 0.95); z-index: 100; border-radius: 5px;
    flex-direction: column;
}

.spinner { 
    width: 30px; height: 30px; border: 2px solid rgba(255, 255, 255, 0.1); 
    border-top: 2px solid #ff0000; border-radius: 50%; 
    animation: ml-spin 0.8s linear infinite; margin-bottom: 10px; 
}

@keyframes ml-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- الجزء الثاني: ميتابوكس لوحة التحكم --- */
.ml-meta-container {
    display: table !important;
    width: 100% !important;
    background: #fff !important;
    direction: rtl !important;
    border-spacing: 15px 0 !important;
    margin: 10px 0 !important;
}

.ml-main-info-block, 
.ml-secondary-info-block {
    display: table-cell !important;
    vertical-align: top !important;
}

.ml-main-info-block {
    width: 250px !important;
    background: #f0f6fb !important;
    padding: 20px !important;
    border-radius: 10px !important;
    border: 1px solid #d1e1ee !important;
}

.ml-secondary-info-block { background: transparent !important; }

.ml-info-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 15px !important;
}

.ml-info-label { font-weight: bold !important; color: #23282d !important; }

.ml-info-input {
    width: 80px !important;
    height: 45px !important;
    text-align: center !important;
    font-size: 22px !important;
    font-weight: 900 !important;
    border: 2px solid #1d2327 !important;
    border-radius: 6px !important;
    background: #fff !important;
}

.ml-input-group {
    display: flex !important;
    align-items: center !important;
    margin-bottom: 12px !important;
    padding: 10px 15px !important;
    border-radius: 8px !important;
    border: 1px solid #ddd !important;
}

.ml-input-group label { flex: 0 0 160px !important; font-weight: bold !important; margin: 0 !important; }

.ml-input-group input { flex: 1 !important; border: none !important; background: transparent !important; font-size: 14px !important; outline: none !important; }

.ml-blue-light { background: #f6fbfd !important; border-color: #d5ecf5 !important; color: #0073aa !important; }
.ml-red-light { background: #fdf6f6 !important; border-color: #f5d5d5 !important; color: #d63638 !important; }

/* --- الجزء الثالث: شبكة الحلقات --- */
.ml-custom-nav-box {
    background: #0f141e !important; 
    padding: 20px !important;
    border-radius: 12px !important;
    border: 1px solid #1c2431 !important;
    margin-top: 25px;
}

.ml-season-header {
    background: #ff0000 !important;
    color: #fff !important;
    padding: 15px 20px !important;
    border-radius: 8px !important;
    font-weight: bold !important;
    font-size: 16px !important;
    margin-bottom: 20px !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ml-episodes-list-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
    gap: 20px !important;
}

.ml-grid-item {
    background: #151921;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none !important;
    transition: all 0.3s ease;
    border: 1px solid #1c2431;
}

.ml-grid-item:hover {
    transform: translateY(-5px);
    border-color: #ff0000;
    box-shadow: 0 5px 15px rgba(255,0,0,0.2);
}

.ml-item-thumb { position: relative; aspect-ratio: 16/9; overflow: hidden; background: #000; }
.ml-item-thumb img { width: 100%; height: 100%; object-fit: cover; transition: 0.5s; }
.ml-grid-item:hover .ml-item-thumb img { transform: scale(1.1); }

.ml-item-count {
    position: absolute; top: 10px; right: 10px;
    background: rgba(255, 0, 0, 0.9);
    color: #fff; font-size: 11px; font-weight: bold;
    padding: 3px 10px; border-radius: 4px; z-index: 2;
}

.ml-item-title {
    padding: 12px; color: #eee; font-size: 14px; font-weight: 500;
    text-align: right; display: block; line-height: 1.4;
    background: #151921; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ml-grid-item.is-active { border: 2px solid #ff0000; background: #1c2431; }
.ml-grid-item.is-active .ml-item-title { color: #ff0000; font-weight: bold; }

/* --- الجزء الرابع: تنسيق الإعلانات الذكي --- */
.ad-item {
    min-height: 180px; /* ضمان وجود مساحة حتى لو لم يحمل الإعلان بعد */
    width: 100%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: #1a1d24;
    border: 1px dashed #333; /* يساعدك في رؤية مكان الإعلان أثناء التعديل */
    border-radius: 8px;
    overflow: hidden;
}

.ml-home-ad-space {
    width: 100%;
    max-width: 728px; /* العرض الأقصى المعتاد للبنرات */
    text-align: center;
}

.ml-home-ad-space img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* تجاوب الجوال الشامل */
@media (max-width: 782px) {
    .ml-meta-container, .ml-main-info-block, .ml-secondary-info-block {
        display: block !important;
        width: 100% !important;
    }
    .ml-main-info-block { margin-bottom: 15px !important; }
    .ml-episodes-list-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
        gap: 12px !important;
    }
    .ad-item { grid-column: span 1 !important; min-height: 120px; } /* تعديل مساحة الإعلان في الجوال */
}

/* تنسيق زر الرابط المختصر */
.ml-copy-link {
    background: #ff5722; color: #333; font-size: 11px; padding: 4px 8px;
    text-align: center; cursor: pointer; border-radius: 3px;
    margin: 0 5px 10px; position: relative; transition: 0.3s;
}
.ml-copy-link:hover { background: #ff5722; color: #fff; }
.ml-copy-link .tooltip {
    visibility: hidden; background-color: black; color: #fff; text-align: center;
    border-radius: 4px; padding: 5px; position: absolute; z-index: 1;
    bottom: 125%; left: 50%; transform: translateX(-50%); opacity: 0;
}
.ml-copy-link.copied .tooltip { visibility: visible; opacity: 1; }

/* منع ظهور شريط التمرير نهائياً في منطقة المشغل */
.ml-player {
    overflow: hidden !important; /* يمنع أي محتوى خارج الصندوق */
    position: relative;
}

#ml-player-iframe {
    width: 100%;
    height: 100%;
    border: none;
    overflow: hidden !important; /* للتأكيد على المتصفحات القديمة */
}

/* إذا كان المشغل يستخدم وسم فيديو لروابط m3u8 */
#ml-hls-player {
    outline: none;
    overflow: hidden;
}

/* --- تنسيق أزرار الحلقات أسفل المشغل --- */
.ml-quick-nav {
    margin-top: 15px;
    padding: 15px;
    background: #161a21;
    border-radius: 5px;
}

.quick-nav-title {
    color: #eee;
    font-size: 14px;
    margin-bottom: 12px;
    font-weight: bold;
    border-bottom: 1px solid #2c3442;
    padding-bottom: 8px;
}

.quick-nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px; /* المسافة بين الأزرار */
}

.ml-ep-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    background: #232a35;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 4px;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.3s ease;
    border: 1px solid #2c3442;
}

/* حالة تمرير الماوس Hover */
.ml-ep-btn:hover {
    background: #e74c3c; /* لون أحمر مثل الصورة */
    border-color: #ff5e4d;
    transform: translateY(-2px);
}

/* حالة الحلقة الحالية (الزر النشط) */
.ml-ep-btn.current-ep {
    background: #e74c3c;
    border-color: #ff5e4d;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.4);
    cursor: default;
}

/* --- تنسيق أرقام الصفحات في أرشيف المسلسل (Pagination) --- */
.tie-pagination, .page-nav, .pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
}

.tie-pagination a, .tie-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 35px;
    height: 35px;
    padding: 0 10px;
    background: #232a35;
    color: #fff !important;
    border-radius: 3px;
    text-decoration: none;
    font-size: 14px;
}

.tie-pagination span.current {
    background: #e74c3c !important;
    font-weight: bold;
}

.tie-pagination a:hover {
    background: #34495e;
}

/* --- تحديث نهائي لملف م الآخر CSS --- */

/* 1. تنسيق الحاوية الرئيسية والمشغل */
.ml-player-wrapper { 
    position: relative; 
    margin-bottom: 20px;
    background: #0f0f0f; 
    padding: 6px; 
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.6);
    direction: rtl;
}

.ml-player { 
    position: relative;
    width: 100%; 
    aspect-ratio: 16/9; 
    background: #000; 
    border-radius: 5px; 
    overflow: hidden !important; 
    display: flex;
    justify-content: center;
    align-items: center;
}

/* منع ظهور شريط التمرير داخل الـ Iframe */
#ml-player-iframe {
    width: 100%;
    height: 100%;
    border: none;
    overflow: hidden !important;
}

/* 2. تنسيق أزرار السيرفرات (شريط التمرير الأفقي) */
.ml-servers-scroll {
    display: flex !important;
    overflow-x: auto !important;
    gap: 8px;
    padding: 10px 5px !important;
    scrollbar-width: none; /* إخفاء الشريط في فيرفوكس */
}
.ml-servers-scroll::-webkit-scrollbar { display: none; } /* إخفاء الشريط في كروم */

.ml-server-btn {
    flex: 0 0 auto !important;
    padding: 8px 15px !important;
    background: #1a1a1a;
    color: #ccc;
    border: 1px solid #333;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.3s;
}
.ml-server-btn.active { background: #e74c3c !important; color: #fff !important; border-color: #ff5e4d !important; }

/* 3. تنسيق أزرار الحلقات أسفل المشغل (مربعات احترافية) */
.ml-quick-nav {
    margin-top: 20px;
    padding: 15px;
    background: #161a21;
    border-radius: 8px;
    border: 1px solid #1c2431;
}

.quick-nav-title {
    color: #fff;
    font-size: 15px;
    margin-bottom: 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-nav-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(45px, 1fr)); /* توزيع المربعات بانتظام */
    gap: 10px;
}

.ml-ep-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1/1; /* لضمان شكل المربع */
    background: #232a35;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 4px;
    font-weight: bold;
    font-size: 14px;
    transition: 0.3s ease;
    border: 1px solid #2c3442;
}

.ml-ep-btn:hover {
    background: #e74c3c;
    border-color: #ff5e4d;
    transform: translateY(-3px);
}

.ml-ep-btn.current-ep {
    background: #e74c3c;
    border-color: #ff5e4d;
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.3);
}

/* 4. تنسيق لودر التحميل */
.player-loader { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center; 
    background: rgba(0, 0, 0, 0.9); z-index: 10; flex-direction: column;
}

.spinner { 
    width: 40px; height: 40px; border: 3px solid rgba(255, 255, 255, 0.1); 
    border-top: 3px solid #e74c3c; border-radius: 50%; 
    animation: ml-spin 1s linear infinite; margin-bottom: 10px; 
}

@keyframes ml-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* 5. تجاوب الجوال */
@media (max-width: 768px) {
    .quick-nav-links {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
        gap: 6px;
    }
    .ml-ep-btn { font-size: 12px; }
}


/* تصميم تنبيه مانع الإعلانات - م الآخر */
.ublock-notice {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    z-index: 100;
    width: 80%;
    border: 2px solid #ff4d4d;
    box-shadow: 0 0 20px rgba(255, 77, 77, 0.5);
}
.ublock-notice button {
    background: #ff4d4d;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 10px;
    font-weight: bold;
}

/* شاشة انتظار احترافية م الآخر */
.mlakhir-loader {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #000 url('https://mlakhir.com/wp-content/uploads/2024/01/logo.png') no-repeat center 40%;
    background-size: 150px; /* تحكم بحجم شعارك من هنا */
    color: #fff;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: Arial, sans-serif;
    transition: opacity 0.5s ease;
}

.mlakhir-loader .loader-text {
    margin-top: 100px; /* المسافة تحت الشعار */
    font-size: 16px;
    font-weight: bold;
}

.mlakhir-loader .spinner {
    margin-top: 20px;
    width: 40px;
    height: 40px;
    border: 4px solid #333;
    border-top: 4px solid #ff0000; /* لون الأنميشن الأحمر */
    border-radius: 50%;
    animation: ml-spin 1s linear infinite;
}

@keyframes ml-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* تعديل خاص بلوحة تحكم م الآخر لضبط حجم المشغلات */
.ml-input-group.server-row {
    padding: 5px 10px !important; /* تقليل الحشو الداخلي للصف */
    gap: 8px !important;
}

.ml-input-group.server-row label {
    flex: 0 0 60px !important; /* تقليل عرض كلمة "مشغل" من 160px إلى 60px */
    background: #1d2327 !important; /* اللون الداكن المتماشي مع لوحة التحكم */
    color: #fff !important;
    height: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 4px !important;
    font-size: 11px !important;
    min-width: 60px !important;
}

/* تنسيق زر الحذف ليطابق حجم المشغل */
.btn-del-mini {
    background: #d63638 !important; /* اللون الأحمر الرسمي للوردبريس */
    color: #fff !important;
    border: none !important;
    padding: 0 10px !important;
    height: 28px !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 11px !important;
    transition: 0.2s !important;
}

.btn-del-mini:hover {
    background: #b32d2e !important;
}

/* ضبط حقل إدخال الرابط */
.ml-input-group.server-row input {
    border: 1px solid #ddd !important;
    background: #fff !important;
    height: 28px !important;
    padding: 0 8px !important;
    border-radius: 4px !important;
}

.player-container { 
    min-height: 250px; /* أو حسب ارتفاع المشغل عندك في الموبايل */
    background: #000; /* خلفية سوداء تظهر قبل تحميل الفيديو */
}

.play-button {
    position: relative;
    z-index: 9999 !important;
    cursor: pointer;
}