/**
 * ====================================================================
 * نظام إدارة الأفلام الاحترافية - ملف التنسيق الأساسي (Style Sheet)
 * ====================================================================
 * الإصلاح الجذري:
 * تم إضافة تنسيق صارم لقائمة الاقتراحات (Autocomplete) لمنع الصور العملاقة.
 * الصور الآن محددة بـ 45 بكسل عرض و 65 بكسل ارتفاع.
 */

/* ====================================================================
   1. متغيرات النظام
   ==================================================================== */
:root {
    --bg-main: #0a0a0b;
    --bg-secondary: #141417;
    --bg-card: #1c1c21;
    --primary: #e50914;
    --primary-hover: #ff1f2a;
    --text-main: #ffffff;
    --text-dim: #b3b3b3;
    --nav-height: 65px;
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ====================================================================
   2. إعدادات عامة
   ==================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }
body {
    font-family: 'Noto Sans Arabic', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    padding-bottom: 80px; 
}

/* ====================================================================
   3. اللودر
   ==================================================================== */
.loader-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-main); z-index: 9999;
    display: flex; justify-content: center; align-items: center;
    transition: opacity 0.5s ease;
}
.spinner {
    width: 40px; height: 40px; border: 3px solid rgba(229, 9, 20, 0.2); 
    border-radius: 50%; border-top-color: var(--primary); 
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ====================================================================
   4. الهيدر
   ==================================================================== */
.main-header {
    padding: 0.8rem 4%; display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; background: rgba(10, 10, 11, 0.9); 
    z-index: 1000; backdrop-filter: blur(12px); 
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.logo { font-size: 1.4rem; font-weight: 900; letter-spacing: 0.5px; cursor: pointer; }
.header-actions button { background: transparent; border: none; color: white; padding: 8px; cursor: pointer; }

/* ====================================================================
   5. السلايدر
   ==================================================================== */
.hero-wrapper {
    position: relative; width: 100%; height: 50vh; overflow: hidden; 
    margin-bottom: 25px; background: var(--bg-card); box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.hero-slider { display: flex; width: 100%; height: 100%; transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
.hero-slide { min-width: 100%; height: 100%; position: relative; background-size: cover; background-position: center top; }
.hero-overlay {
    position: absolute; inset: 0; 
    background: linear-gradient(to top, var(--bg-main) 10%, rgba(10,10,11,0.6) 40%, transparent 100%);
    display: flex; align-items: flex-end; padding: 25px 5%;
}
.hero-content { width: 100%; opacity: 0; transform: translateY(30px); transition: all 0.6s ease 0.3s; }
.hero-slide.active .hero-content { opacity: 1; transform: translateY(0); }
.hero-title { font-size: 2rem; font-weight: 800; margin-bottom: 10px; text-shadow: 0 4px 10px rgba(0,0,0,0.8); }
.hero-meta { font-size: 0.85rem; color: #ddd; margin-bottom: 15px; display: flex; gap: 10px; align-items: center; }
.slider-dots { position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; z-index: 10; }
.dot { width: 6px; height: 6px; background: rgba(255,255,255,0.3); border-radius: 50%; cursor: pointer; transition: 0.3s; }
.dot.active { background: var(--primary); transform: scale(1.3); }

/* ====================================================================
   6. الأزرار
   ==================================================================== */
.btn-hero { padding: 8px 20px; border-radius: 50px; border: none; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn-hero.play { background: var(--primary); color: white; }
.btn-glass { background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.1); color: white; backdrop-filter: blur(5px); }

/* ====================================================================
   7. الأقسام
   ==================================================================== */
.content-section { padding-bottom: 20px; display: none; }
.content-section.active { display: block; animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.section-header { padding: 0 4%; margin: 25px 0 15px; display: flex; align-items: center; justify-content: space-between; }
.section-title { font-size: 1.1rem; font-weight: 700; border-right: 3px solid var(--primary); padding-right: 10px; }

/* ====================================================================
   8. بطاقات الأفلام
   ==================================================================== */
.horizontal-scroll-container {
    width: 100%; overflow-x: auto; padding: 5px 4% 20px; 
    white-space: nowrap; scrollbar-width: none; display: flex; gap: 12px;
}
.horizontal-scroll-container::-webkit-scrollbar { display: none; }

.movie-card { 
    display: inline-block; position: relative; width: 115px; min-width: 115px; max-width: 115px; 
    cursor: pointer; transition: transform 0.2s ease; 
}
.movie-card:hover { transform: scale(1.05); z-index: 5; }

.card-poster { 
    width: 100%; aspect-ratio: 2/3; border-radius: 8px; object-fit: cover; 
    background: var(--bg-card); margin-bottom: 6px; 
}
.card-title { 
    font-size: 0.8rem; font-weight: 600; white-space: nowrap; 
    overflow: hidden; text-overflow: ellipsis; color: #f0f0f0; 
}

/* ====================================================================
   9. البحث والاقتراحات (Search & Suggestions) - [تم الإصلاح]
   ==================================================================== */

/* حاوية البحث */
.search-input-wrapper {
    position: relative; display: flex; align-items: center; 
    background: #151518; border-radius: 16px; 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    margin: 0 4% 20px 4%; box-shadow: 0 4px 15px rgba(0,0,0,0.2); 
    transition: all 0.3s ease;
    z-index: 1001;
}
.search-input-wrapper:focus-within { 
    border-color: var(--primary); background: #1a1a1e; 
    box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.15); 
}
.search-icon { position: absolute; left: 20px; color: var(--text-dim); width: 22px; transition: color 0.3s; }
.search-input-wrapper:focus-within .search-icon { color: white; }
#main-search-input { width: 100%; padding: 16px 20px 16px 55px; background: transparent; border: none; color: white; font-size: 1rem; font-weight: 600; }

/* --- [هام جداً] تنسيق القائمة المنسدلة (Suggestions Dropdown) --- */
.suggestions-dropdown {
    position: absolute;
    top: 100%; /* تظهر أسفل الحقل مباشرة */
    left: 0;
    right: 0;
    width: 100%;
    background: #1c1c21;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: none;
    border-radius: 0 0 16px 16px;
    max-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: max-height 0.3s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    z-index: 1002;
}

.suggestions-dropdown.active {
    max-height: 350px;
    padding-bottom: 10px;
}

/* العنصر الفردي في الاقتراحات */
.suggestion-item {
    display: flex; /* ترتيب أفقي (صورة بجانب نص) */
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    transition: background 0.2s;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: rgba(255,255,255,0.08); }

/* --- [هام] تصغير صورة الاقتراح لتكون أيقونة --- */
.suggestion-poster {
    width: 45px !important;    /* عرض ثابت صغير */
    height: 65px !important;   /* ارتفاع ثابت صغير */
    min-width: 45px;           /* منع الانكماش */
    object-fit: cover;         /* ملء المساحة دون تشويه */
    border-radius: 6px;
    background: #111;
}

/* معلومات الاقتراح (النص) */
.suggestion-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden; /* لمنع النص من الخروج */
}

.suggestion-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-meta {
    font-size: 0.8rem;
    color: var(--text-dim);
}


/* --- الفلاتر --- */
.search-filters { padding: 0 4% 15px; display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; }
.search-filters::-webkit-scrollbar { display: none; }
.filter-select {
    -webkit-appearance: none; appearance: none;
    background-color: #232329; color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 50px; 
    padding: 12px 20px 12px 40px; font-size: 0.9rem; font-weight: 600; cursor: pointer;
    min-width: 110px; transition: all 0.3s ease;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' 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 15px center; background-size: 16px;
}
.filter-select:hover { background-color: #2a2a30; border-color: rgba(255, 255, 255, 0.3); }

/* --- الكبسولات واللغات --- */
.category-chips { display: flex; gap: 10px; overflow-x: auto; padding: 10px 4% 20px 4%; margin-bottom: 10px; scrollbar-width: none; }
.category-chips::-webkit-scrollbar { display: none; }
.chip {
    padding: 10px 24px; background: #232329; border: 1px solid rgba(255, 255, 255, 0.08); 
    border-radius: 50px; white-space: nowrap; cursor: pointer; font-weight: 600; 
    font-size: 0.9rem; color: #ccc; transition: 0.3s; display: flex; align-items: center; justify-content: center;
}
.chip.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 4px 15px rgba(229, 9, 20, 0.4); }
.chip.back-btn { width: 40px; height: 40px; padding: 0; border-radius: 50%; background: rgba(255,255,255,0.1); }

.language-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; padding: 10px 0; }
.language-card {
    position: relative; height: 90px; border-radius: 12px; overflow: hidden; cursor: pointer; 
    transition: transform 0.2s, box-shadow 0.2s; border: 1px solid rgba(255, 255, 255, 0.08); 
    display: flex; align-items: center; justify-content: center; background: #222; 
}
.language-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.4); border-color: rgba(255,255,255,0.3); }
.lang-overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.4) 100%); z-index: 1; }
.lang-name { position: relative; z-index: 2; color: white; font-weight: 800; font-size: 1.1rem; letter-spacing: 0.5px; text-shadow: 0 2px 4px rgba(0,0,0,0.6); }

/* --- شبكة نتائج البحث --- */
.movie-grid {
    display: grid; 
    grid-template-columns: repeat(auto-fill, 115px); 
    gap: 15px; 
    padding-bottom: 30px;
    justify-content: center; 
}

/* ====================================================================
   10. النافذة المنبثقة
   ==================================================================== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 2000; display: none; justify-content: center; align-items: flex-end; backdrop-filter: blur(8px); }
.modal.active { display: flex; }
.modal-content {
    background: #121212; width: 100%; max-width: 600px; height: 90vh; 
    border-radius: 24px 24px 0 0; overflow-y: auto; position: relative; 
    box-shadow: 0 -10px 50px rgba(0,0,0,0.8); animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-hero { width: 100%; height: 320px; background-size: cover; background-position: center top; position: relative; }
.modal-hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, #121212 5%, transparent 80%); }
.modal-close-btn {
    position: absolute; top: 15px; right: 15px; width: 40px; height: 40px; 
    border-radius: 50%; background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.1); 
    color: white; display: flex; align-items: center; justify-content: center; 
    cursor: pointer; z-index: 2005; backdrop-filter: blur(4px); transition: 0.2s;
}
.modal-close-btn:hover { background: rgba(255,255,255,0.3); transform: rotate(90deg); }
.modal-body { padding: 25px; position: relative; top: -40px; z-index: 10; }
.modal-title { font-size: 2rem; font-weight: 800; margin-bottom: 10px; line-height: 1.1; text-shadow: 0 2px 10px black; }
.modal-info-row { display: flex; gap: 15px; align-items: center; color: #ccc; margin-bottom: 25px; font-size: 0.9rem; }
.match-score { color: #46d369; font-weight: 800; }
.age-badge { border: 1px solid #777; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; }
.modal-actions { display: flex; flex-direction: column; gap: 12px; margin-bottom: 30px; }
.btn-block { width: 100%; padding: 14px; border-radius: 8px; font-weight: 700; font-size: 1rem; display: flex; align-items: center; justify-content: center; gap: 8px; border: none; cursor: pointer; }
.btn-primary-modern { background: white; color: black; }
.btn-primary-modern:hover { background: #e0e0e0; }
.btn-secondary-modern { background: rgba(255,255,255,0.2); color: white; }
.modal-desc { font-size: 0.95rem; line-height: 1.6; color: #ccc; margin-bottom: 25px; }
.cast-row { display: flex; gap: 15px; overflow-x: auto; padding: 10px 0 20px; scrollbar-width: none; }
.cast-item { min-width: 80px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.cast-img { width: 70px; height: 70px; border-radius: 50%; object-fit: cover; border: 2px solid #333; margin-bottom: 8px; background-color: #222; }
.cast-name { font-size: 0.75rem; color: #bbb; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.genre-tags-container { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.genre-tag { font-size: 0.8rem; color: #ddd; background: #333; padding: 6px 14px; border-radius: 50px; }

/* ====================================================================
   11. مشغل الفيديو
   ==================================================================== */
.player-overlay { position: fixed; inset: 0; background: black; z-index: 3000; display: none; }
.player-overlay.active { display: block; }
.player-overlay iframe { width: 100%; height: 100%; border: none; }
.close-player {
    position: absolute; top: 20px; right: 20px; background: rgba(0,0,0,0.7); 
    color: white; border: none; border-radius: 50%; width: 45px; height: 45px; 
    z-index: 3001; cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* ====================================================================
   12. القائمة السفلية
   ==================================================================== */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; width: 100%; height: 65px; 
    background: rgba(10, 10, 11, 0.98); border-top: 1px solid rgba(255, 255, 255, 0.05); 
    display: flex; justify-content: space-around; align-items: center; z-index: 900;
}
.nav-item { display: flex; flex-direction: column; align-items: center; color: #777; text-decoration: none; flex: 1; }
.nav-item i { width: 22px; height: 22px; margin-bottom: 4px; transition: 0.3s; }
.nav-item.active { color: var(--primary); }
.nav-item.active i { transform: translateY(-3px); }

/* ====================================================================
   13. التجاوب
   ==================================================================== */
@media (min-width: 768px) {
    .modal { align-items: center; }
    .modal-content { height: auto; max-height: 85vh; border-radius: 16px; }
    .modal-actions { flex-direction: row; }
}