﻿* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    background: #f8fafc;
    color: #334155;
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.page-header {
    background: white;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    padding: 1rem 1.5rem;
    position: relative;
    z-index: 20;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-text h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-text p {
    color: #64748b;
    font-size: 0.85rem;
    margin-top: 0.2rem;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 300px;
}

    .search-box input {
        width: 100%;
        padding: 0.6rem 1rem 0.6rem 2.5rem;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        font-family: inherit;
        background: #f8fafc;
        color: #334155;
        font-size: 0.9rem;
    }

    .search-box i {
        position: absolute;
        right: 0.9rem;
        top: 50%;
        transform: translateY(-50%);
        color: #94a3b8;
    }

/* Main Layout */
.main-container {
    display: flex;
    height: calc(100vh - 80px);
    max-width: 1600px;
    /*margin: 0 auto;*/
    padding: 0.5rem;
    gap: 1rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Sidebar for Sections */
.sections-sidebar {
    width: 260px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    padding: 1.2rem 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

    .sections-sidebar h3 {
        padding: 0 1.2rem 0.8rem;
        font-size: 1rem;
        color: #475569;
        border-bottom: 1px solid #f1f5f9;
        margin-bottom: 0.8rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

.section-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.8rem;
}

.section-item {
    display: flex;
    align-items: center;
    padding: 0.65rem 0.8rem;
    margin-bottom: 0.4rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    color: #64748b;
    border: 1px solid transparent;
    user-select: none;
}

    .section-item:hover {
        background: #f1f5f9;
        color: #334155;
    }

    .section-item.active {
        background: #eff6ff;
        color: #1d4ed8;
        border-color: #dbeafe;
        font-weight: 600;
    }

.section-icon {
    margin-left: 0.7rem;
    font-size: 0.9rem;
    opacity: 0.8;
}

.section-count {
    margin-right: auto;
    font-size: 0.75rem;
    background: #e2e8f0;
    color: #475569;
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
}

/* Main Content Area - Videos List */
.videos-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    transition: all 0.3s ease;
}

/* حالت بدون انتخاب ویدئو (پیش‌فرض) */
.main-container:not(.video-selected) .videos-main-area {
    flex: 1;
}

/* حالت با انتخاب ویدئو */
.main-container.video-selected .videos-main-area {
    flex: 0 0 400px; /* عرض ثابت در حالت انتخاب شده */
}

/* View Toggle */
.view-toggle {
    display: flex;
    background: white;
    border-radius: 12px;
    padding: 0.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.view-btn {
    flex: 1;
    padding: 0.6rem;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

    .view-btn:hover {
        background: #f1f5f9;
    }

    .view-btn.active {
        background: #3b82f6;
        color: white;
        box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
    }

/* Videos List Container */
.videos-container {
    flex: 1;
    overflow-y: auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
}

/* Video Grid View */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.video-card {
    background: #ffffff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid #f1f5f9;
}

    .video-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
        border-color: #dbeafe;
    }

    .video-card.active {
        border-color: #3b82f6;
        box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
    }

.video-thumb {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 */
    background: #e2e8f0;
    overflow: hidden;
}

    .video-thumb img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        transition: transform 0.4s;
    }

.video-card:hover .video-thumb img {
    transform: scale(1.05);
}

.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.video-card:hover .play-overlay {
    opacity: 1;
}

.play-icon {
    font-size: 2.5rem;
    color: white;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.video-info {
    padding: 1rem;
}

.video-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1e293b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.8rem;
}

.video-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.has-description-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #e0f2fe;
    color: #0369a1;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-top: 0.3rem;
}

/* Video Player Area - فقط زمانی که ویدئو انتخاب شده */
.video-player-area {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s ease;
}

.main-container.video-selected .video-player-area {
    display: flex;
    opacity: 1;
    transform: translateX(0);
    animation: fadeInRight 0.4s ease-out;
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Video Player Container */
.video-player-container {
    background: #0f172a;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    padding-top: 56.25%; /* 16:9 */
    margin: 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

    .video-player-container iframe,
    .video-player-container video {
        position: absolute;
        top: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border: none;
    }

/* Video Info Panel */
.video-info-panel {
    flex: 1;
    overflow-y: auto;
    padding: 0 1.5rem 1.5rem;
}

    .video-info-panel h2 {
        font-size: 1.4rem;
        color: #1e293b;
        margin-bottom: 1rem;
        line-height: 1.4;
        padding: 0 0.5rem;
    }

.video-meta-large {
    display: flex;
    gap: 1.5rem;
    color: #64748b;
    font-size: 0.9rem;
    padding: 0 0.5rem 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

    .video-meta-large div {
        display: flex;
        align-items: center;
        gap: 0.4rem;
    }

.description-box {
    background: #f8fafc;
    border-radius: 10px;
    padding: 1.2rem;
    margin-top: 1rem;
}

    .description-box h4 {
        color: #475569;
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .description-box p {
        color: #475569;
        font-size: 0.9rem;
        line-height: 1.7;
    }

.close-player {
    position: absolute;
    left: 1.5rem;
    top: 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #475569;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
    transition: all 0.2s;
}

    .close-player:hover {
        background: white;
        color: #dc2626;
        transform: scale(1.05);
    }

/* Scrollbar styling */
.section-list::-webkit-scrollbar,
.videos-container::-webkit-scrollbar,
.video-info-panel::-webkit-scrollbar {
    width: 6px;
}

.section-list::-webkit-scrollbar-track,
.videos-container::-webkit-scrollbar-track,
.video-info-panel::-webkit-scrollbar-track {
    background: transparent;
}

.section-list::-webkit-scrollbar-thumb,
.videos-container::-webkit-scrollbar-thumb,
.video-info-panel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

    .section-list::-webkit-scrollbar-thumb:hover,
    .videos-container::-webkit-scrollbar-thumb:hover,
    .video-info-panel::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: #3b82f6;
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
}

/* Responsive */
@media (max-width: 1200px) {
    .main-container.video-selected .videos-main-area {
        flex: 0 0 350px;
    }

    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 992px) {
    .main-container {
        flex-wrap: wrap;
        height: auto;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }

    .sections-sidebar {
        width: 100%;
        height: auto;
        margin-bottom: 1rem;
        order: 1;
    }

    .section-list {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    .section-item {
        flex-shrink: 0;
        white-space: nowrap;
        margin-bottom: 0;
    }

    .videos-main-area {
        order: 2;
        width: 100%;
    }

    /* در موبایل: نمایش پخش‌کننده به صورت مودال/تمام صفحه */
    .video-player-area {
        position: fixed;
        top: 80px;
        left: 0;
        width: 100%;
        height: calc(100vh - 80px);
        border-radius: 0;
        z-index: 100;
        display: none !important;
    }

    .main-container.video-selected .video-player-area {
        display: flex !important;
        animation: slideUp 0.4s ease-out;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    .main-container.video-selected .videos-main-area {
        flex: 1 !important;
        opacity: 0.3;
        filter: blur(2px);
        pointer-events: none;
    }

    .mobile-menu-btn {
        display: flex;
    }
}

@media (max-width: 768px) {
    .page-header {
        padding: 0.8rem 1rem;
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 0.8rem;
    }

    .header-text h1 {
        font-size: 1.4rem;
    }

    .search-box {
        max-width: 100%;
    }

    .view-toggle {
        flex-direction: column;
        gap: 0.3rem;
    }

    .view-btn {
        padding: 0.8rem;
    }

    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 1rem;
    }

    .videos-container {
        padding: 1rem;
    }

    .video-player-container {
        margin: 1rem;
    }
}

@media (max-width: 576px) {
    .video-grid {
        grid-template-columns: 1fr;
    }

    .video-info-panel {
        padding: 0 1rem 1rem;
    }

        .video-info-panel h2 {
            font-size: 1.2rem;
        }

    .video-meta-large {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.video-card {
    animation: fadeIn 0.3s ease-out;
}

/* حالت لیستی برای نمایش ویدئوها */
.list-view .video-grid {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.list-view .video-card {
    display: flex;
    align-items: center;
}

.list-view .video-thumb {
    width: 120px;
    padding-top: 67.5px; /* 16:9 ratio */
    flex-shrink: 0;
    margin-left: 1rem;
    border-radius: 8px;
    overflow: hidden;
}

.list-view .video-info {
    flex: 1;
    padding: 0.8rem 0.8rem 0.8rem 0;
}

.list-view .video-title {
    height: auto;
    margin-bottom: 0.3rem;
}
