/* library-video.css - أنماط خاصة بصفحة الفيديو معتمداً على الهوية الموحدة */

/* متغيرات محلية خاصة بالفيديو */
:root {
    --video-player-radius: 24px;
    --video-card-gap: 20px;
    --video-sidebar-width: 360px;
    --video-transition: 0.25s ease;
}

/* تخطيط الصفحة العام */
.video-page {
    padding: 28px 0 60px;
}

/* غلاف المشغل والقائمة الجانبية */
.yt-shell {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    align-items: start;
}

@media (min-width: 1100px) {
    .yt-shell {
        grid-template-columns: minmax(0, 1fr) var(--video-sidebar-width);
    }
}

.yt-main,
.yt-sidebar {
    min-width: 0;
}

/* بطاقة المشغل */
.yt-player-card {
    overflow: hidden;
    margin-bottom: 24px;
}

.yt-frame-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--video-player-radius) var(--video-player-radius) 0 0;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.yt-frame-wrap iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    transition: opacity 0.2s;
}

.yt-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    color: white;
    font-size: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    width: 80px;
    height: 80px;
    border-radius: 50%;
}

.yt-player-content {
    padding: 18px;
}

.yt-title {
    font-size: clamp(1.5rem, 4vw, 2rem);
    line-height: 1.5;
    margin-bottom: 12px;
}

.yt-meta-row {
    margin-bottom: 14px;
}

.yt-meta-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.9rem;
    font-weight: 600;
}

.yt-badge {
    font-size: 0.85rem;
}

.yt-desc-box {
    margin-top: 10px;
}

.yt-desc-text {
    font-size: 1rem;
    line-height: 1.9;
    white-space: pre-line;
}

/* شبكة الفيديوهات */
.yt-grid-section {
    margin-top: 10px;
}

.yt-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

@media (min-width: 768px) {
    .yt-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1100px) {
    .yt-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.yt-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.yt-card-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #dbe6f4;
    border-radius: 20px 20px 0 0;
    overflow: hidden;
}

.yt-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-duration {
    position: absolute;
    left: 8px;
    bottom: 8px;
    background: rgba(15, 23, 42, 0.85);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 8px;
    backdrop-filter: blur(4px);
}

.yt-card-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.yt-card-title {
    font-size: 1rem;
    line-height: 1.6;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.yt-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* الشريط الجانبي */
.yt-side-list {
    gap: 12px;
}

.side-video-item {
    cursor: pointer;
    transition: background var(--video-transition);
    padding: 8px;
    border-radius: 16px;
}

.side-video-item:hover,
.side-video-item.active {
    background: var(--primary-soft);
}

.side-thumb {
    width: 120px;
    height: 68px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
}

.side-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.side-info h4 {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.side-info span {
    font-size: 0.8rem;
}

/* الحالة الفارغة */
.yt-empty {
    margin-top: 20px;
    display: none; /* تظهر عند الحاجة */
}

/* مودال الفيديو */
.yt-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    padding: 16px;
}

.yt-modal.show {
    opacity: 1;
    visibility: visible;
}

.yt-modal-dialog {
    width: min(100%, 900px);
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 28px;
    background: var(--card-bg);
    box-shadow: var(--shadow-lg);
}

.yt-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-light);
}

.yt-modal-body {
    padding: 0;
}

.yt-modal-frame-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}

.yt-modal-frame-wrap iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.yt-modal-actions {
    padding: 18px 22px;
    border-top: 1px solid var(--border-light);
}

/* تحسينات للأجهزة الصغيرة */
@media (max-width: 640px) {
    .video-page {
        padding: 20px 0 48px;
    }

    .yt-player-content {
        padding: 14px;
    }

    .side-thumb {
        width: 100px;
        height: 56px;
    }
}
/* شريط التصنيفات الأفقي القابل للتمرير */
.video-chips-wrapper {
    margin: 20px 0 18px;
    position: relative;
}

.video-chips-scroll {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--gray-bg);
}

/* إخفاء شريط التمرير في WebKit (Chrome, Safari) مع الحفاظ على الوظيفة */
.video-chips-scroll::-webkit-scrollbar {
    height: 4px;
}

.video-chips-scroll::-webkit-scrollbar-track {
    background: var(--gray-bg);
    border-radius: 10px;
}

.video-chips-scroll::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

/* يمكن إخفاء شريط التمرير تماماً مع الاحتفاظ بالتمرير عبر اللمس */
.video-chips-scroll.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.video-chips-scroll.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* تنسيق الأزرار داخل الشريط */
.yt-chip {
    flex-shrink: 0;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 40px;
    background: var(--gray-bg);
    color: var(--text-dark);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.yt-chip:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.yt-chip.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-md);
}

/* دعم التمرير السلس عند استخدام عجلة الماوس */
.video-chips-scroll {
    scroll-snap-type: x mandatory;
}

.yt-chip {
    scroll-snap-align: start;
}