/* ===================== الأساسيات والمتغيرات ===================== */
:root {
    --bg-primary: #0b0b0f;
    --bg-secondary: #13131a;
    --bg-card: #1a1a24;
    --bg-card-hover: #22222e;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #8a8a9a;
    --accent-color: #ff4757;
    --accent-glow: rgba(255, 71, 87, 0.3);
    --border-color: rgba(255, 255, 255, 0.06);
    --glass-bg: rgba(26, 26, 36, 0.85);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="light"] {
    --bg-primary: #f5f5fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f0f5;
    --text-primary: #1a1a2e;
    --text-secondary: #333355;
    --text-muted: #6b6b80;
    --accent-color: #e74c3c;
    --accent-glow: rgba(231, 76, 60, 0.15);
    --border-color: rgba(0, 0, 0, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.9);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
}

/* ===================== الأنماط العامة ===================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    direction: rtl;
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

body {
    min-height: 100vh;
    padding-bottom: 80px;
    overflow-x: hidden;
    background: var(--bg-primary);
}

/* ===================== شاشة البداية ===================== */
.splash-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.splash-logo {
    width: 120px;
    height: auto;
    animation: pulseLogo 1.5s ease-in-out infinite;
}

@keyframes pulseLogo {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.splash-loader {
    display: flex;
    gap: 8px;
}

.splash-loader span {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-color);
    animation: bounce 0.8s infinite alternate;
}

.splash-loader span:nth-child(2) { animation-delay: 0.2s; }
.splash-loader span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    from { transform: translateY(0); opacity: 0.4; }
    to { transform: translateY(-12px); opacity: 1; }
}

/* ===================== الهيدر ===================== */
#mainHeader {
    display: flex;
    flex-direction: column;
    padding: 20px 16px 12px;
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 14px;
}

.header-top {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.app-title {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(135deg, var(--accent-color), #ff6b81);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: -2px;
    letter-spacing: 4px;
    text-transform: uppercase;
    opacity: 0.7;
}

/* حاوية البحث */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border-radius: 50px;
    padding: 0 16px;
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.search-container:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
    color: var(--text-muted);
    font-size: 16px;
    margin-left: 10px;
}

#searchInput {
    flex: 1;
    background: transparent;
    border: none;
    padding: 14px 0;
    font-family: var(--font-family);
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
}

#searchInput::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.clear-search {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.clear-search:hover {
    color: var(--accent-color);
    background: rgba(255, 71, 87, 0.1);
}

/* ===================== الصفحات والعناوين ===================== */
.page {
    display: none;
    padding: 20px 16px;
    animation: fadeInUp 0.4s ease;
}

.page.active {
    display: block;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
}

.page-title::after {
    content: '';
    position: absolute;
    bottom: -4px;
    right: 0;
    width: 40%;
    height: 3px;
    background: var(--accent-color);
    border-radius: 4px;
}

/* ===================== شبكة البطاقات ===================== */
.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    padding-bottom: 20px;
}

@media (min-width: 500px) {
    .grid-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}

@media (min-width: 768px) {
    .grid-container {
        grid-template-columns: repeat(5, 1fr);
        gap: 20px;
    }
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 60px 20px;
    font-size: 18px;
}

/* ===================== بطاقة الفيلم ===================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-smooth);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.card:hover {
    transform: translateY(-6px);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-lg);
    border-color: rgba(255, 71, 87, 0.2);
}

.card-img-container {
    position: relative;
    aspect-ratio: 2/3;
    background: var(--bg-secondary);
    overflow: hidden;
}

.card-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-smooth);
}

.card:hover .card-img-container img {
    transform: scale(1.06);
}

.card-rating {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    color: #ffc107;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
    letter-spacing: 0.5px;
}

.card-info {
    padding: 12px 10px;
    text-align: center;
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 6px;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===================== صفحة المشاهدة ===================== */
.watch-page {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    overflow-y: auto;
}

.watch-page.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.backdrop-blur {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: blur(40px) brightness(0.3);
    z-index: -1;
}

.player-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    margin-top: 60px;
}

#videoPlayer {
    width: 100%;
    height: 100%;
    border: none;
}

.back-btn {
    position: absolute;
    top: -40px;
    right: 16px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: none;
    color: #fff;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 10;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.details-wrapper {
    padding: 20px;
    color: #fff;
}

.movie-meta-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 10px;
}

.movie-meta-flex {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: #ccc;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.movie-meta-desc {
    font-size: 15px;
    line-height: 1.7;
    color: #bbb;
    margin-bottom: 24px;
}

.fav-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-color);
    color: #fff;
    border: none;
    padding: 14px 28px;
    border-radius: 50px;
    font-family: var(--font-family);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.fav-action-btn.is-fav {
    background: #2ecc71;
}

.fav-action-btn:active {
    transform: scale(0.96);
}

/* ===================== شريط التنقل السفلي ===================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    z-index: 200;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 10px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    font-weight: 500;
}

.nav-item i {
    font-size: 20px;
}

.nav-item.active {
    color: var(--accent-color);
    background: var(--accent-glow);
}

.nav-item:active {
    transform: scale(0.9);
}

/* ===================== الإعدادات ===================== */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 16px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.settings-item span {
    font-weight: 600;
}

.settings-item select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-family: var(--font-family);
    font-size: 14px;
    outline: none;
}

/* التبديل (Switch) */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    background: #444;
    border-radius: 34px;
    cursor: pointer;
    transition: 0.3s;
}

.slider::before {
    content: '';
    position: absolute;
    height: 22px;
    width: 22px;
    right: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .slider {
    background: var(--accent-color);
}

input:checked + .slider::before {
    transform: translateX(-22px);
}

/* بطاقة حول التطبيق */
.about-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 16px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.about-card h3 {
    font-size: 18px;
    margin-bottom: 10px;
}

.about-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 8px;
}

.credit-label {
    font-weight: 700;
    margin-top: 14px;
    color: var(--text-primary) !important;
}

.credit-name {
    color: var(--accent-color);
    font-weight: 800;
    font-size: 18px;
    margin-bottom: 16px !important;
}

.social-icons {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 12px;
}

.social-icons a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 18px;
    transition: all var(--transition-fast);
    border: 1px solid var(--border-color);
}

.social-icons a:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

/* ===================== التمرير والعرض ===================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 20px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* تحسينات للجوال الصغير */
@media (max-width: 400px) {
    .grid-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .card-title {
        font-size: 13px;
    }
    .app-title {
        font-size: 26px;
    }
}