/* ============================================================
   assets/css/library-video.css
   مكتبة الفيديو — الشبكة، التصنيفات، البحث، المودال
   ------------------------------------------------------------
   ما هو مشترك (لا نكرره):
     - .ui-card-grid, .yt-card, .ui-result-bar  → component-system
     - .ui-empty-state, .ui-pill                → component-system
     - .ui-btn, .ui-hero-surface                → component-system
   ------------------------------------------------------------
   الأقسام:
     PART 1 — شريط البحث المحسّن
     PART 2 — شريط التصنيفات الأفقي
     PART 3 — قائمة منسدلة للتصنيفات
     PART 4 — شبكة الفيديوهات
     PART 5 — بطاقة الفيديو (yt-card)
     PART 6 — مودال الفيديو
     PART 7 — الاستجابة للجوال
     PART 8 — RTL / LTR
     PART 9 — الطباعة
   ============================================================ */

/* ============================================================
   PART 1 — شريط البحث المحسّن
   ============================================================ */
.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--white);
    border: 2px solid var(--border-light);
    border-radius: 50px;
    padding: 4px 4px 4px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 20px;
}

.search-wrapper:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 4px 20px rgba(79, 172, 254, 0.15);
}

.search-wrapper .search-icon {
    color: #94a3b8;
    font-size: 1.1rem;
    margin-inline-end: 8px;
    flex-shrink: 0;
}

.search-wrapper input[type="text"] {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 10px 0;
    font-size: 1.05rem;
    color: var(--text-main);
    font-family: var(--font-ui-ar);
    min-width: 0;
}

.search-wrapper input[type="text"]::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.search-wrapper .clear-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px 12px;
    margin-inline-start: 4px;
    transition: color 0.2s;
    display: none;
}

.search-wrapper .clear-btn:hover {
    color: var(--danger);
}

.search-wrapper .search-btn {
    background: var(--primary-dark);
    color: var(--white);
    border: none;
    border-radius: 50px;
    padding: 10px 24px;
    font-weight: 700;
    font-size: 1rem;
    font-family: var(--font-ui-ar);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.search-wrapper .search-btn:hover {
    background: #1e3a8a;
    transform: translateY(-1px);
}

/* ============================================================
   PART 2 — شريط التصنيفات الأفقي
   ============================================================ */
.video-categories-bar {
    position: relative;
    z-index: 50;
    overflow: visible;
}

.video-categories-scroll {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
    white-space: nowrap;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-light) var(--border-light);
}

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

.video-categories-scroll::-webkit-scrollbar-track {
    background: var(--border-light);
    border-radius: 10px;
}

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

.cat-bar-item {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

.cat-bar-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 30px;
    border: 2px solid var(--border-light);
    background: var(--offwhite);
    cursor: pointer;
    font-weight: 700;
    font-size: 1.05rem;
    font-family: var(--font-ui-ar);
    transition: all 0.2s;
    white-space: nowrap;
    user-select: none;
    color: var(--text-main);
}

.cat-bar-btn:hover {
    background: var(--border-light);
    border-color: #cbd5e1;
}

.cat-bar-btn.active {
    background: var(--primary-dark);
    color: var(--white);
    border-color: var(--primary-dark);
    box-shadow: 0 6px 16px rgba(30, 64, 175, 0.25);
}

.cat-bar-btn .cat-count {
    font-size: 0.85rem;
    opacity: 0.8;
}

.cat-arrow {
    font-size: 0.85rem;
    transition: transform 0.2s;
    display: inline-block;
}

.cat-bar-item.open .cat-arrow {
    transform: rotate(180deg);
}

/* ============================================================
   PART 3 — قائمة منسدلة للتصنيفات
   ============================================================ */
.cat-bar-dropdown {
    position: fixed;
    top: 0;
    right: 0;
    min-width: 220px;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    display: none;
    z-index: var(--z-dropdown);
    max-height: 400px;
    overflow-y: auto;
    white-space: nowrap;
}

.cat-bar-item.open .cat-bar-dropdown {
    display: block;
}

.cat-bar-sub-btn {
    display: block;
    width: 100%;
    text-align: right;
    padding: 12px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-ui-ar);
    transition: background 0.15s;
    color: var(--text-main);
}

.cat-bar-sub-btn:hover {
    background: var(--offwhite);
}

.cat-bar-sub-btn.active {
    background: #dbeafe;
    color: var(--primary-dark);
    font-weight: 700;
}

.cat-bar-sub-btn .cat-count {
    font-size: 0.85rem;
    opacity: 0.7;
}

[dir="rtl"] .cat-bar-dropdown {
    right: auto;
    left: 0;
}

[dir="ltr"] .cat-bar-dropdown {
    left: auto;
    right: 0;
}

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

/* ============================================================
   PART 5 — بطاقة الفيديو (تخصيصات على yt-card من component-system)
   ============================================================ */
.yt-card {
    cursor: pointer;
    overflow: hidden;
}

.yt-card-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #f1f5f9;
}

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

.yt-card:hover .yt-card-thumb img {
    transform: scale(1.05);
}

.video-duration {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.78);
    color: var(--white);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    z-index: 2;
}

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

.yt-card-title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--primary-dark);
    font-weight: 800;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.yt-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

/* ============================================================
   PART 6 — مودال الفيديو
   ============================================================ */
.video-modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.video-modal.open {
    display: flex;
    animation: lvModalFadeIn 0.25s ease-out;
}

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

.video-modal .modal-content {
    max-width: 800px;
    width: 100%;
    background: var(--white);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    direction: ltr;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
}

.video-modal #closeModal {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.video-modal #closeModal:hover {
    background: rgba(220, 38, 38, 0.9);
    transform: scale(1.05);
}

.video-modal .modal-video-wrap {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    background: #000;
    flex-shrink: 0;
}

.video-modal #modalPlayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.video-modal .modal-info {
    padding: 16px 20px;
    background: var(--white);
    text-align: right;
    overflow-y: auto;
    flex: 1;
}

.video-modal .modal-title {
    margin: 0 0 8px;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary-dark);
    line-height: 1.4;
    word-break: break-word;
}

.video-modal .modal-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.video-modal .modal-actions {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.video-modal .modal-actions .ui-btn {
    flex: 1 1 auto;
    min-width: 120px;
    justify-content: center;
}

/* ============================================================
   PART 7 — الاستجابة للجوال
   ============================================================ */
@media (max-width: 768px) {
    .search-wrapper {
        padding: 4px 4px 4px 10px;
    }

    .search-wrapper .search-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .search-wrapper .search-btn span {
        display: none;
    }

    .cat-bar-btn {
        padding: 10px 18px;
        font-size: 1rem;
    }

    .cat-bar-dropdown {
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        min-width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 60vh;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    }

    .cat-bar-sub-btn {
        padding: 14px 20px;
        font-size: 1rem;
    }

    .video-modal {
        padding: 0;
        align-items: flex-end;
    }

    .video-modal .modal-content {
        border-radius: 20px 20px 0 0;
        max-height: 95vh;
    }

    .video-modal .modal-title {
        font-size: 1.1rem;
    }

    .video-modal .modal-actions .ui-btn {
        flex: 1 1 100%;
    }
}

@media (max-width: 480px) {
    .cat-bar-btn {
        padding: 10px 16px;
        font-size: 0.95rem;
    }

    .video-duration {
        font-size: 0.75rem;
        padding: 3px 8px;
    }

    .yt-card-title {
        font-size: 0.95rem;
    }
}

/* ============================================================
   PART 8 — RTL / LTR
   ============================================================ */
body[dir="rtl"] .video-duration {
    left: 8px;
    right: auto;
}

body[dir="ltr"] .video-duration {
    right: 8px;
    left: auto;
}

