/* ==================================================
   CUSTOM EDUCATION THEME — LESSON DETAIL
   صفحه‌ی جزئیات درس
   - تب‌ها با radio (بدون JS)
   - offcanvas لیست فصل‌ها در موبایل (با JS)
   ================================================== */

/* ============ LAYOUT ============ */
.custom-education-theme-lesson-detail-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px 0 24px;
}

/* ============ SIDEBAR ============ */
.custom-education-theme-lesson-detail-sidebar {
    background: var(--card-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--glass-shadow);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    max-height: 85vh;
    transition: var(--transition);
    order: 1;
}

/* ============ MAIN ============ */
.custom-education-theme-lesson-detail-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
    order: 2;
}

/* ============ PLAYER ============ */
.custom-education-theme-lesson-detail-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--glass-border);
}

.custom-education-theme-lesson-detail-player iframe,
.custom-education-theme-lesson-detail-player video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.custom-education-theme-lesson-detail-player-poster {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
}

.custom-education-theme-lesson-detail-player-poster::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
}

.custom-education-theme-lesson-detail-play-btn {
    position: relative;
    z-index: 2;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    background: var(--accent-gradient);
    color: #fff;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 40px var(--accent-glow-45);
    transition: var(--transition);
}

.custom-education-theme-lesson-detail-play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 14px 50px var(--accent-glow-60);
}

/* ============ INFO ============ */
.custom-education-theme-lesson-detail-info {
    background: var(--card-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.custom-education-theme-lesson-detail-info-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.5;
}

.custom-education-theme-lesson-detail-info-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.custom-education-theme-lesson-detail-info-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.custom-education-theme-lesson-detail-info-meta i {
    color: var(--accent);
    font-size: 0.9rem;
}

.custom-education-theme-lesson-detail-info-text {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.9;
    font-size: 0.92rem;
}

/* ==================================================
   TABS (با radio — بدون JS)
   ================================================== */

.custom-education-theme-lesson-detail-tabs-wrapper {
    position: relative;
}

/* radio مخفی */
.custom-education-theme-lesson-detail-tab-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

/* ============ TAB BAR ============ */
.custom-education-theme-lesson-detail-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--glass-shadow);
    margin-bottom: 16px;
}

/* ============ TAB (label) ============ */
.custom-education-theme-lesson-detail-tab {
    flex: 1 1 auto;
    min-width: 100px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    user-select: none;
}

.custom-education-theme-lesson-detail-tab i {
    color: var(--accent);
    font-size: 0.9rem;
    transition: var(--transition);
}

.custom-education-theme-lesson-detail-tab:hover {
    color: var(--accent);
    background: var(--accent-glow-08);
}

/* ============ تب فعال (با :has) ============ */
.custom-education-theme-lesson-detail-tabs-wrapper:has(#lesson-tab-details:checked)      .custom-education-theme-lesson-detail-tab[for="lesson-tab-details"],
.custom-education-theme-lesson-detail-tabs-wrapper:has(#lesson-tab-attachments:checked)  .custom-education-theme-lesson-detail-tab[for="lesson-tab-attachments"],
.custom-education-theme-lesson-detail-tabs-wrapper:has(#lesson-tab-exam:checked)         .custom-education-theme-lesson-detail-tab[for="lesson-tab-exam"],
.custom-education-theme-lesson-detail-tabs-wrapper:has(#lesson-tab-certificate:checked)  .custom-education-theme-lesson-detail-tab[for="lesson-tab-certificate"] {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 6px 18px var(--accent-glow-35);
}

.custom-education-theme-lesson-detail-tabs-wrapper:has(#lesson-tab-details:checked)      .custom-education-theme-lesson-detail-tab[for="lesson-tab-details"] i,
.custom-education-theme-lesson-detail-tabs-wrapper:has(#lesson-tab-attachments:checked)  .custom-education-theme-lesson-detail-tab[for="lesson-tab-attachments"] i,
.custom-education-theme-lesson-detail-tabs-wrapper:has(#lesson-tab-exam:checked)         .custom-education-theme-lesson-detail-tab[for="lesson-tab-exam"] i,
.custom-education-theme-lesson-detail-tabs-wrapper:has(#lesson-tab-certificate:checked)  .custom-education-theme-lesson-detail-tab[for="lesson-tab-certificate"] i {
    color: #fff;
}

/* ==================================================
   PANELS
   ================================================== */

.custom-education-theme-lesson-detail-panel {
    display: none;
}

/* نمایش پنل فعال با radio */
#lesson-tab-details:checked      ~ .custom-education-theme-lesson-detail-panels .custom-education-theme-lesson-detail-panel[data-custom-education-theme-lesson-detail-panel="details"],
#lesson-tab-attachments:checked  ~ .custom-education-theme-lesson-detail-panels .custom-education-theme-lesson-detail-panel[data-custom-education-theme-lesson-detail-panel="attachments"],
#lesson-tab-exam:checked         ~ .custom-education-theme-lesson-detail-panels .custom-education-theme-lesson-detail-panel[data-custom-education-theme-lesson-detail-panel="exam"],
#lesson-tab-certificate:checked  ~ .custom-education-theme-lesson-detail-panels .custom-education-theme-lesson-detail-panel[data-custom-education-theme-lesson-detail-panel="certificate"] {
    display: block;
    animation: customEducationThemeLessonDetailPanelFade 0.5s ease-in-out forwards;
}

@keyframes customEducationThemeLessonDetailPanelFade {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============ ATTACHMENTS ============ */
.custom-education-theme-lesson-detail-attachments {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 12px;
}

.custom-education-theme-lesson-detail-attachment {
    grid-column: span 12;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
    min-width: 0;
}

.custom-education-theme-lesson-detail-attachment:hover {
    border-color: var(--accent-glow-35);
    background: var(--accent-glow-08);
    transform: translateY(-2px);
    box-shadow: var(--glass-shadow-hover);
}

.custom-education-theme-lesson-detail-attachment-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    color: #fff;
    font-size: 1rem;
    box-shadow: 0 6px 16px var(--accent-glow-30);
}

.custom-education-theme-lesson-detail-attachment-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.custom-education-theme-lesson-detail-attachment-title {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-education-theme-lesson-detail-attachment-size {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.custom-education-theme-lesson-detail-attachment-download {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--accent);
    font-size: 0.85rem;
    transition: var(--transition);
}

.custom-education-theme-lesson-detail-attachment:hover .custom-education-theme-lesson-detail-attachment-download {
    background: var(--accent-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px var(--accent-glow-35);
}

/* ============ AUTO-GRID ضمیمه‌ها ============ */
.custom-education-theme-lesson-detail-attachments[data-count="1"]  .custom-education-theme-lesson-detail-attachment { grid-column: span 12; }
.custom-education-theme-lesson-detail-attachments[data-count="2"]  .custom-education-theme-lesson-detail-attachment { grid-column: span 6; }
.custom-education-theme-lesson-detail-attachments[data-count="3"]  .custom-education-theme-lesson-detail-attachment { grid-column: span 6; }
.custom-education-theme-lesson-detail-attachments[data-count="3"]  .custom-education-theme-lesson-detail-attachment:nth-child(3) { grid-column: span 12; }
.custom-education-theme-lesson-detail-attachments[data-count="4"]  .custom-education-theme-lesson-detail-attachment { grid-column: span 6; }
.custom-education-theme-lesson-detail-attachments[data-count="5"]  .custom-education-theme-lesson-detail-attachment { grid-column: span 6; }
.custom-education-theme-lesson-detail-attachments[data-count="5"]  .custom-education-theme-lesson-detail-attachment:nth-child(n+5) { grid-column: span 12; }
.custom-education-theme-lesson-detail-attachments[data-count="6"]  .custom-education-theme-lesson-detail-attachment { grid-column: span 4; }
.custom-education-theme-lesson-detail-attachments[data-count="7"]  .custom-education-theme-lesson-detail-attachment { grid-column: span 4; }
.custom-education-theme-lesson-detail-attachments[data-count="7"]  .custom-education-theme-lesson-detail-attachment:nth-child(n+7) { grid-column: span 12; }
.custom-education-theme-lesson-detail-attachments[data-count="8"]  .custom-education-theme-lesson-detail-attachment { grid-column: span 4; }
.custom-education-theme-lesson-detail-attachments[data-count="9"]  .custom-education-theme-lesson-detail-attachment { grid-column: span 4; }
.custom-education-theme-lesson-detail-attachments[data-count="10"] .custom-education-theme-lesson-detail-attachment { grid-column: span 4; }
.custom-education-theme-lesson-detail-attachments[data-count="11"] .custom-education-theme-lesson-detail-attachment { grid-column: span 4; }
.custom-education-theme-lesson-detail-attachments[data-count="12"] .custom-education-theme-lesson-detail-attachment { grid-column: span 4; }

/* ============ EMPTY ============ */
.custom-education-theme-lesson-detail-empty {
    text-align: center;
    padding: 40px 20px;
    background: var(--glass-bg);
    border: 1px dashed var(--glass-border);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.custom-education-theme-lesson-detail-empty i {
    display: block;
    font-size: 2rem;
    color: var(--accent);
    margin-bottom: 12px;
}

/* ============ SIDEBAR HEADER ============ */
.custom-education-theme-lesson-detail-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--glass-border);
}

.custom-education-theme-lesson-detail-sidebar-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.custom-education-theme-lesson-detail-sidebar-header h3 i {
    color: var(--accent);
}

.custom-education-theme-lesson-detail-sidebar-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.custom-education-theme-lesson-detail-sidebar-close:hover {
    background: linear-gradient(135deg, var(--danger), #c24242);
    color: #fff;
    border-color: transparent;
    transform: rotate(90deg);
}

/* ============ TOGGLE (mobile) ============ */
.custom-education-theme-lesson-detail-sidebar-toggle-wrapper {
    display: none;
    justify-content: center;
    padding: 0 16px;
    margin-bottom: 16px;
}

.custom-education-theme-lesson-detail-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--glass-shadow);
}

.custom-education-theme-lesson-detail-sidebar-toggle i {
    color: var(--accent);
}

.custom-education-theme-lesson-detail-sidebar-toggle:hover {
    background: var(--accent-gradient);
    color: #fff;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent-glow-35);
}

.custom-education-theme-lesson-detail-sidebar-toggle:hover i {
    color: #fff;
}

/* ============ OVERLAY ============ */
.custom-education-theme-lesson-detail-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    cursor: pointer;
}

.custom-education-theme-lesson-detail-sidebar-overlay.custom-education-theme-lesson-detail-sidebar-overlay-active {
    opacity: 1;
    visibility: visible;
}

/* ============ LESSON LINK ============ */
.custom-education-theme-lesson .custom-education-theme-lesson-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 0;
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

.custom-education-theme-lesson .custom-education-theme-lesson-link:hover {
    color: var(--accent);
}

.custom-education-theme-lesson.custom-education-theme-lesson-selected .custom-education-theme-lesson-link {
    color: var(--accent);
    font-weight: 700;
}

.custom-education-theme-lesson.custom-education-theme-lesson-selected {
    background: var(--accent-glow-12);
    border-radius: var(--radius-md);
    box-shadow: 0 0 0 1px var(--accent-glow-35) inset;
}

/* ==================================================
   RESPONSIVE — offcanvas در موبایل
   ================================================== */
@media (max-width: 992px) {
    .custom-education-theme-lesson-detail-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .custom-education-theme-lesson-detail-main {
        order: 1;
    }

    .custom-education-theme-lesson-detail-sidebar-toggle-wrapper {
        display: flex;
    }

    .custom-education-theme-lesson-detail-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        width: 340px;
        max-width: 85vw;
        max-height: 100vh;
        border-radius: 0;
        z-index: 2001;
        padding: 16px;
        background: var(--mobile-menu-bg);
        backdrop-filter: blur(30px) saturate(180%);
        -webkit-backdrop-filter: blur(30px) saturate(180%);
        order: initial;
        /* 👇 کلید حل مشکل: مخفی کامل در حالت بسته */
        display: none;
    }

    /* LTR: از چپ */
    .custom-education-theme-lesson-detail-sidebar {
        left: 0;
        right: auto;
        border-right: 1px solid var(--glass-border);
        border-left: none;
        box-shadow: 20px 0 60px rgba(0, 0, 0, 0.3);
        transform: translateX(-100%);
    }

    /* RTL: از راست */
    [dir="rtl"] .custom-education-theme-lesson-detail-sidebar {
        right: 0;
        left: auto;
        border-left: 1px solid var(--glass-border);
        border-right: none;
        box-shadow: -20px 0 60px rgba(0, 0, 0, 0.3);
        transform: translateX(100%);
    }

    /* 👇 حالت باز: اول display: flex، بعد اسلاید */
    .custom-education-theme-lesson-detail-sidebar.custom-education-theme-lesson-detail-sidebar-open {
        display: flex;
        flex-direction: column;
        animation: customEducationThemeLessonSidebarSlideIn 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    }

    .custom-education-theme-lesson-detail-sidebar-close {
        display: flex;
    }
}

/* 👇 کیفریم اسلاید ورود (LTR) */
@keyframes customEducationThemeLessonSidebarSlideIn {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

/* 👇 کیفریم اسلاید ورود (RTL) */
[dir="rtl"] .custom-education-theme-lesson-detail-sidebar.custom-education-theme-lesson-detail-sidebar-open {
    animation-name: customEducationThemeLessonSidebarSlideInRtl;
}

@keyframes customEducationThemeLessonSidebarSlideInRtl {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@media (max-width: 640px) {
    .custom-education-theme-lesson-detail-sidebar {
        width: 300px;
    }

    .custom-education-theme-lesson-detail-tab {
        flex: 1 1 calc(50% - 6px);
        font-size: 0.8rem;
        padding: 9px 12px;
    }

    .custom-education-theme-lesson-detail-info {
        padding: 16px 18px;
    }

    .custom-education-theme-lesson-detail-info-title {
        font-size: 1rem;
    }

    .custom-education-theme-lesson-detail-attachments[data-count] .custom-education-theme-lesson-detail-attachment {
        grid-column: span 12 !important;
    }
}

@media (max-width: 400px) {
    .custom-education-theme-lesson-detail-sidebar {
        width: 280px;
    }
}