:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --background-color: #ffffff;
    --text-color: #333333;
    --card-bg: #f8f9fa;
    --border-color: #dee2e6;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"],
body.dark {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --background-color: #121212;
    --text-color: #ffffff;
    --card-bg: #1e1e1e;
    --border-color: #444444;
    --shadow-color: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

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

/* زر تبديل الوضع */
.theme-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 4px 15px var(--shadow-color);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* الهيدر */
header {
    background-color: var(--card-bg);
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px var(--shadow-color);
}

.logo {
    height: 82px;
    width: auto;
    max-width: 100%;
}

/* المحتوى الرئيسي */
.main-content {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    margin-top: 2rem;
    min-height: calc(100vh - 200px);
}

/* الشريط الجانبي */
.sidebar {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px var(--shadow-color);
    position: sticky;
    top: 2rem;
    height: fit-content;
}

.sidebar h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

.categories-list {
    list-style: none;
}

.categories-list li {
    margin-bottom: 0.75rem;
}

.categories-list a {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.75rem 1rem;
    display: block;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.categories-list a:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateX(-5px);
}

.category-count {
    font-size: 0.8rem;
    color: var(--secondary-color);
    background: var(--background-color);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    margin-right: 0.5rem;
}

/* شبكة الفيديوهات */
.videos-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.horizontal-scroll {
    display: flex;
    overflow-x: auto;
    gap: 1.5rem;
    padding-bottom: 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--card-bg);
}

.horizontal-scroll::-webkit-scrollbar {
    height: 8px;
}

.horizontal-scroll::-webkit-scrollbar-track {
    background: var(--card-bg);
    border-radius: 4px;
}

.horizontal-scroll::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.horizontal-scroll .video-card {
    flex: 0 0 auto;
    width: 280px;
}

/* بطاقات الفيديو */
.video-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow-color);
    cursor: pointer;
}

.video-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 25px var(--shadow-color);
}

.video-thumbnail {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 160px;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.05);
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
}

.video-card:hover .video-overlay {
    opacity: 1;
}

.play-button {
    transition: all 0.3s ease;
}

.play-button svg {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    width: 64px;
    height: 64px;
}

.video-info {
    padding: 1rem;
}

.video-info h4 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    line-height: 1.4;
    color: var(--text-color);
    min-height: 2.8em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.category {
    color: var(--secondary-color);
    font-size: 0.85rem;
    background: var(--background-color);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    display: inline-block;
}

.video-meta {
    margin-top: 0.5rem;
    color: var(--secondary-color);
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* الأقسام */
section {
    margin-bottom: 4rem;
}

section h2, section h3 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    position: relative;
    padding-bottom: 0.5rem;
}

section h2::after, section h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 60px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
}

/* نافذة الفيديو */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    margin: 2% auto;
    padding: 0;
    width: 90%;
    max-width: 800px;
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.3rem;
}

.close {
    position: absolute;
    top: 15px;
    left: 20px;
    color: var(--text-color);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    background: var(--primary-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close:hover {
    background: var(--secondary-color);
    transform: rotate(90deg);
}

#videoPlayer {
    padding: 0;
    border-radius: 0 0 15px 15px;
    overflow: hidden;
}

#videoPlayer iframe {
    border-radius: 0 0 15px 15px;
    width: 100%;
    height: 400px;
}

/* التجاوب */
@media (max-width: 1200px) {
    .videos-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 992px) {
    .videos-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .main-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .sidebar {
        position: static;
        order: 2;
    }
}

@media (max-width: 768px) {
    .videos-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .theme-toggle {
        bottom: 15px;
        left: 15px;
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    #videoPlayer iframe {
        height: 300px;
    }
}

@media (max-width: 576px) {
    .videos-grid {
        grid-template-columns: 1fr;
    }
    
    .horizontal-scroll .video-card {
        width: 250px;
    }
    
    .video-thumbnail {
        height: 140px;
    }
    
    #videoPlayer iframe {
        height: 250px;
    }
}

/* تأثيرات إضافية */
.video-card:active {
    transform: scale(0.98);
}

/* ضمان تحميل الصورة البديلة */
img[onerror] {
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
}