:root {
    --main-color: #e50914; 
    --body-bg: #141414;
    --box-bg: #222222;
    --text-color: #ffffff;
    --nav-height: 70px;
    --plyr-color-main: #e50914;
}

* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: "Cairo", sans-serif;
    background-color: var(--body-bg);
    color: var(--text-color);
    padding-top: var(--nav-height);
}

a {
    text-decoration: none;
    color: unset;
}

img {
    max-width: 100%;
}

.main-color {
    color: var(--main-color);
}

.container {
    max-width: 1200px;
    padding: 0 20px;
    margin: auto;
}

/* شريط التنقل العلوي */
.nav-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 99;
    background-color: #000000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--nav-height);
}

.logo {
    font-size: 1.8rem;
    font-weight: 900;
}

/* الأزرار الموحدة بالتأثير اللوني */
.btn {
    color: #ffffff;
    padding: 10px 20px;
    font-size: 1.1rem;
    font-weight: 700;
    display: inline-flex;
    position: relative;
    align-items: center;
    justify-content: center;
    border: none;
    background-color: var(--box-bg);
    cursor: pointer;
    border-radius: 5px;
    overflow: hidden;
    transition: 0.3s ease-in-out;
    font-family: inherit;
    text-decoration: none;
    outline: none;
    text-align: center;
}

.btn span {
    position: relative;
    z-index: 1;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--main-color);
    color: var(--main-color);
    transition: all 0.3s ease-in-out;
}

.btn-outline:hover {
    background-color: var(--main-color);
    color: #fff;
}

/* تعديل زر الرجوع للبحث ليصبح مستطيلاً أصغر */
.btn-back {
    padding: 6px 16px;
    font-size: 0.95rem;
    margin-bottom: 20px;
}

/* كلاس مخصص لأزرار الحلقات */
.btn-ep {
    padding: 8px;
    font-size: 1rem;
    width: 100%;
    margin-bottom: 0 !important;
}

/* العناوين والبحث */
.section {
    padding-top: 40px;
    padding-bottom: 50px;
}

.section-header {
    margin-bottom: 30px;
    padding-inline-start: 15px;
    font-size: 1.4rem;
    font-weight: 700;
    border-inline-start: 4px solid var(--main-color);
    display: flex;
    align-items: center;
}

/* توحيد لون الخط الفاصل لجميع العناوين الفرعية بالحلقات لتكون رمادية متناسقة */
.section-header-sub {
    font-size: 1.2rem;
    margin-bottom: 15px;
    border-inline-start-color: #555;
}

.search-form {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}

.search-input {
    flex: 1;
    padding: 12px 20px;
    background: var(--box-bg) !important;
    border: 1px solid #444;
    color: var(--text-color);
    font-family: 'Cairo', sans-serif;
    font-size: 1.1rem;
    border-radius: 5px;
    outline: none;
    transition: border-color 0.3s;
}

/* منع تحول لون الخانة للأبيض عند الكتابة أو التركيز */
.search-input:focus, .search-input:active {
    background-color: var(--box-bg) !important;
    border-color: var(--main-color);
    color: var(--text-color);
}

/* ==========================================
   نظام الشبكة (تم تعديله إلى Flexbox للتوسيط)
   ========================================== */
.movies-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    padding: 10px 0;
}

.episodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    margin-top: 20px;
}

.movie-item {
    display: block;
    position: relative;
    overflow: hidden;
    width: 170px;
    height: 240px;
    flex: 0 0 auto; 
    cursor: pointer;
    border-radius: 8px;
    background-color: var(--box-bg);
}

.movie-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease-out;
}

.movie-item:hover img {
    transform: scale(1.1);
}

.movie-item-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 15px 10px 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.6) 60%, transparent 100%);
    text-align: center;
}

.movie-item-title {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

/* ==========================================
   أزرار الترقيم وتحميل المزيد (AJAX)
   ========================================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.page-btn {
    padding: 10px 22px;
    background: transparent;
    border: 1px solid var(--main-color);
    border-radius: 8px;
    color: var(--text-color);
    font-family: 'Cairo', sans-serif;
    font-weight: bold;
    font-size: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.page-btn:hover {
    background: var(--main-color);
    color: #fff;
}

.page-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.page-info {
    color: #aaa;
    font-weight: 700;
    margin: 0 10px;
    font-size: 1.1rem;
}

/* ==========================================
   العناصر الأخرى
   ========================================== */
.view-container {
    background: var(--box-bg);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.dl-container {
    text-align: center;
    padding: 30px 0;
}

.alert-error {
    background: rgba(229, 9, 20, 0.1);
    border: 1px solid var(--main-color);
    color: #ff4d4d;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 700;
    text-align: center;
}

.alert-loading {
    display: none;
    color: var(--main-color);
    font-weight: 700;
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.1rem;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.disabled {
    pointer-events: none !important;
    opacity: 0.6 !important;
    cursor: not-allowed !important;
}

/* ==========================================
   ستايلات صفحة العرض والمودال (تم نقلها من بايثون)
   ========================================== */
.toast-notification {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    background-color: var(--main-color); color: white; padding: 14px 24px;
    border-radius: 8px; font-size: 1rem; font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25); z-index: 999999;
    display: none; animation: fadeInOut 5s forwards;
}
@keyframes fadeInOut { 
    0% { opacity: 0; top: 0px; } 
    10% { opacity: 1; top: 20px; } 
    90% { opacity: 1; top: 20px; } 
    100% { opacity: 0; top: 0px; } 
}
.view-poster { 
    display: block; margin: 0 0 25px auto; max-width: 220px; width: 100%; 
    border-radius: 12px; box-shadow: 0 10px 30px rgba(229, 9, 20, 0.15); 
    border: 1px solid rgba(255, 255, 255, 0.05); object-fit: cover; 
}
.sng-modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0, 0, 0, 0.9); z-index: 99999; display: none; 
    flex-direction: column; align-items: center; justify-content: center; 
}
.sng-modal-overlay.open { display: flex; }
.sng-modal { 
    width: 90%; max-width: 1000px; height: 80%; background: #000; 
    display: flex; flex-direction: column; border-radius: 8px; 
    overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
}
.sng-modal-head { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 12px 20px; background: #1a1a1a; 
}
.sng-modal-ttl { font-size: 1.1rem; font-weight: bold; color: #fff; }
.sng-modal-x { 
    background: transparent; color: var(--main-color); border: 1px solid var(--main-color); 
    padding: 2px 10px; border-radius: 6px; cursor: pointer; 
    font-family: 'Cairo'; font-weight: bold; font-size: 0.95rem; 
    transition: 0.3s ease-in-out; display: inline-flex; align-items: center; justify-content: center; 
}
.sng-modal-x:hover { background: var(--main-color); color: #fff; }
.sng-modal-player { 
    flex-grow: 1; position: relative; width: 100%; background: #000; 
    display: flex; justify-content: center; align-items: center;
}
.sng-modal-player iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }
.modal-loading { color: white; text-align: center; padding: 40px 20px; font-size: 1.2rem; font-weight: bold; }

/* ==========================================
   ستايلات صفحة التحميل الاحتياطي (FFmpeg)
   ========================================== */
.fallback-container { text-align: center; padding: 40px 20px; max-width: 600px; margin: 0 auto; }
.fallback-desc { color: #a0a0a0; font-size: 1rem; margin-bottom: 25px; }
.progress-bar-container { width: 100%; background-color: var(--body-bg); border-radius: 20px; overflow: hidden; margin-bottom: 20px; border: 1px solid #444; }
.progress { width: 0%; height: 25px; background-color: var(--main-color); transition: width 0.3s ease; }
#status { font-size: 1.1rem; color: var(--text-color); font-weight: 700; }

/* ==========================================
   التجاوب مع شاشات الجوال
   ========================================== */
@media only screen and (max-width: 768px) {
    .search-form { flex-direction: column; }
    .movies-grid { gap: 15px; }
    .movie-item { width: 130px; height: 185px; }
    .view-container { padding: 20px 15px; }
    .pagination { flex-direction: column; gap: 15px; }
    .sng-modal { width: 100%; height: 100%; max-width: 100%; border-radius: 0; }
}
