/**
 * =====================================================
 * SIDEBAR TABS - Lesson Page
 * File: sidebar-tabs.css
 * Mục đích: Style cho tabs (Bài học, Mới nhất, Đã lưu, Bài viết)
 * =====================================================
 */

/* ========== CSS Variables (fallback, override bởi --brand-color từ page) ========== */
:root {
    --sidebar-tab-active-color: var(--brand-color, #754ffe);
    --sidebar-tab-hover-color: color-mix(in srgb, var(--brand-color, #754ffe) 10%, transparent);
    --sidebar-tab-text-color: #6b7280;
    --sidebar-tab-active-text: var(--brand-color, #754ffe);
    --sidebar-tab-border-color: #e5e7eb;
    --sidebar-tab-badge-bg: var(--brand-color, #754ffe);
    --sidebar-tab-badge-text: #fff;
}

/* ========== Sidebar Container Override ========== */
.course-playing-sidebar {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 95px);
    overflow: hidden; /* Container không scroll, chỉ content bên trong scroll */
    width: 100%; /* Đảm bảo không bị co */
}

/* ========== Tabs Navigation - Sticky trên cùng ========== */
.sidebar-tabs-nav {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--sidebar-tab-border-color);
    padding: 0 12px;
    background: #fff;
    flex-shrink: 0; /* Không co lại */
    z-index: 10;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    width: 100%; /* Đảm bảo chiều rộng đầy đủ */
}

.sidebar-tabs-nav::-webkit-scrollbar {
    display: none;
}

.sidebar-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--sidebar-tab-text-color);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    position: relative;
}

.sidebar-tab-btn:hover {
    color: var(--sidebar-tab-active-text);
    background: var(--sidebar-tab-hover-color);
}

.sidebar-tab-btn.active {
    color: var(--sidebar-tab-active-text);
    border-bottom-color: var(--sidebar-tab-active-color);
}

.sidebar-tab-btn i {
    font-size: 12px;
}

/* Badge count trên tab */
.sidebar-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 700;
    color: var(--sidebar-tab-badge-text);
    background: var(--sidebar-tab-badge-bg);
    border-radius: 9px;
    line-height: 1;
}

.sidebar-tab-badge:empty {
    display: none;
}

.sidebar-tab-badge.hidden {
    display: none;
}

/* ========== Tab Content Area - Scrollable ========== */
.sidebar-tabs-content {
    flex: 1 1 auto; /* Grow và shrink theo nội dung */
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0; /* Quan trọng để flex item có thể scroll */
    scroll-behavior: auto; /* Không smooth để reset scroll ngay lập tức */
    width: 100%; /* Tránh sidebar bị co lại khi tab có ít content */
}

.sidebar-tab-pane {
    display: none;
    animation: fadeIn 0.2s ease;
    width: 100%;
}

.sidebar-tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== Loading Skeleton ========== */
.sidebar-tab-loading {
    padding: 16px;
}

.skeleton-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background: #f9fafb;
    border-radius: 8px;
    animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-thumb {
    width: 80px;
    height: 45px;
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    border-radius: 6px;
    animation: shimmer 1.5s infinite;
}

.skeleton-content {
    flex: 1;
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    border-radius: 4px;
    margin-bottom: 8px;
    animation: shimmer 1.5s infinite;
}

.skeleton-line:last-child {
    width: 60%;
    margin-bottom: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ========== Empty State ========== */
.sidebar-tab-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.sidebar-tab-empty-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 50%;
    margin-bottom: 16px;
}

.sidebar-tab-empty-icon i {
    font-size: 28px;
    color: #9ca3af;
}

.sidebar-tab-empty-title {
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.sidebar-tab-empty-text {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 16px;
    line-height: 1.5;
}

.sidebar-tab-empty-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: var(--sidebar-tab-active-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.sidebar-tab-empty-btn:hover {
    background: #6339e5;
    color: #fff;
    transform: translateY(-1px);
}

/* ========== Empty State (dùng trong JS render) ========== */
.sidebar-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    width: 100%;
}

.sidebar-empty-state i {
    font-size: 48px;
    color: #d1d5db;
    margin-bottom: 16px;
}

.sidebar-empty-state p {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* ========== Lesson Item trong Tab ========== */
.sidebar-lesson-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
    position: relative;
}

.sidebar-lesson-item:hover {
    background: #f9fafb;
}

.sidebar-lesson-item:last-child {
    border-bottom: none;
}

.sidebar-lesson-thumb {
    position: relative;
    width: 120px;
    min-width: 120px;
    aspect-ratio: 16/9;
    border-radius: 6px;
    overflow: hidden;
    background: #e5e7eb;
}

.sidebar-lesson-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-lesson-thumb-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sidebar-lesson-item:hover .sidebar-lesson-thumb-overlay {
    opacity: 1;
}

.sidebar-lesson-thumb-overlay i {
    color: #fff;
    font-size: 18px;
}

/* Duration badge trong thumbnail */
.sidebar-lesson-duration {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 3px;
    line-height: 1.2;
}

/* Badge Coming Soon */
.sidebar-lesson-badge.badge-coming-soon {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.sidebar-lesson-info {
    flex: 1;
    min-width: 0;
    padding-right: 28px; /* Khoảng trống cho nút bookmark + completion */
}

.sidebar-lesson-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.sidebar-lesson-badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 3px;
}

.sidebar-lesson-badge.badge-free {
    color: #fff;
    background: #10b981;
}

.sidebar-lesson-badge.badge-premium {
    color: #fff;
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.sidebar-lesson-badge.badge-new {
    color: #fff;
    background: #3b82f6;
}

.sidebar-lesson-title {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sidebar-lesson-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #9ca3af;
}

.sidebar-lesson-meta i {
    font-size: 10px;
}

.sidebar-lesson-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    bottom: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

/* ========== Bookmark Button ========== */
.lesson-bookmark-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: rgba(148, 163, 184, 0.2);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #64748b;
}

.lesson-bookmark-btn:hover {
    color: #f59e0b;
    background: rgba(251, 191, 36, 0.2);
}

.lesson-bookmark-btn.is-bookmarked {
    background: #fbbf24;
    color: #fff;
}

.lesson-bookmark-btn.is-bookmarked:hover {
    background: #f59e0b;
}

.lesson-bookmark-btn i {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.lesson-bookmark-btn:active i {
    transform: scale(1.2);
}

/* Completed indicator */
.sidebar-lesson-completed {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.2); /* Xám nhẹ - chưa hoàn thành */
    color: #64748b;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-lesson-completed:hover {
    background: rgba(var(--brand-color-rgb, 117, 79, 254), 0.2);
    color: var(--brand-color, #754ffe);
}

.sidebar-lesson-completed.is-completed {
    background: var(--brand-color, #754ffe);
    color: #fff;
}

.sidebar-lesson-completed.is-completed:hover {
    background: color-mix(in srgb, var(--brand-color, #754ffe) 85%, #000);
}

/* Locked indicator */
.sidebar-lesson-item.is-locked {
    opacity: 0.7;
    cursor: pointer;
}

.sidebar-lesson-item.is-locked:hover {
    opacity: 0.85;
    background: rgba(var(--brand-color-rgb, 117, 79, 254), 0.05);
}

.sidebar-lesson-item.is-locked .sidebar-lesson-thumb::after {
    content: '\f023';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 16px;
}

/* ========== Blog Item trong Tab ========== */
.sidebar-blog-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.sidebar-blog-item:hover {
    background: #f9fafb;
}

.sidebar-blog-item:last-child {
    border-bottom: none;
}

.sidebar-blog-thumb {
    width: 100px;
    min-width: 100px;
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
    background: #e5e7eb;
}

.sidebar-blog-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-blog-info {
    flex: 1;
    min-width: 0;
}

.sidebar-blog-category {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--sidebar-tab-active-color);
    margin-bottom: 4px;
}

.sidebar-blog-title {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sidebar-blog-date {
    font-size: 11px;
    color: #9ca3af;
}

/* ========== Blog Sections (Liên quan + Mới nhất) ========== */
.sidebar-blogs-section {
    padding: 0 0 8px 0;
}

.sidebar-blogs-section:not(:last-child) {
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 8px;
}

.sidebar-blogs-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px 8px;
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sidebar-blogs-section-header i {
    color: var(--sidebar-tab-active-color);
    font-size: 11px;
}

.sidebar-blogs-list {
    /* Container cho danh sách bài viết */
}

.sidebar-blogs-view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    margin: 4px 16px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--sidebar-tab-active-color);
    background: color-mix(in srgb, var(--sidebar-tab-active-color) 8%, transparent);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.sidebar-blogs-view-all:hover {
    background: color-mix(in srgb, var(--sidebar-tab-active-color) 15%, transparent);
    color: var(--sidebar-tab-active-color);
}

/* ========== Responsive ========== */
@media (max-width: 992px) {
    .sidebar-tabs-nav {
        padding: 0 8px;
    }
    
    .sidebar-tab-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .sidebar-lesson-item,
    .sidebar-blog-item {
        padding: 10px 12px;
    }
    
    .sidebar-lesson-thumb {
        width: 100px;
        min-width: 100px;
    }
    
    .sidebar-blog-thumb {
        width: 90px;
        min-width: 90px;
    }
}

/* ========== Toast Notification ========== */
.bookmark-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: #1f2937;
    color: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.bookmark-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.bookmark-toast i {
    font-size: 16px;
}

.bookmark-toast.toast-success i {
    color: #10b981;
}

.bookmark-toast.toast-removed i {
    color: #f59e0b;
}

.bookmark-toast.toast-error i {
    color: #ef4444;
}

.bookmark-toast.toast-info i {
    color: #3b82f6;
    animation: spin-slow 1s linear infinite;
}

@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
/* ========== Announcements Tab ========== */
.sidebar-announcements-list {
    padding: 8px 0;
    width: 100%; /* Đảm bảo chiều rộng đầy đủ */
    min-width: 100%;
}

.sidebar-announcement-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background 0.15s ease;
}

.sidebar-announcement-item:hover {
    background: #f9fafb;
}

.sidebar-announcement-item:last-child {
    border-bottom: none;
}

.sidebar-announcement-thumb {
    width: 56px;
    height: 56px;
    min-width: 56px;
    border-radius: 10px;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-announcement-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-announcement-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
}

.sidebar-announcement-info {
    flex: 1;
    min-width: 0;
}

.sidebar-announcement-title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sidebar-announcement-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sidebar-announcement-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.sidebar-announcement-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    background: var(--sidebar-tab-active-color);
    border-radius: 4px;
}

.sidebar-announcement-badge.pinned {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.sidebar-announcement-badge.global {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.sidebar-announcement-badge.new {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.sidebar-announcement-badge i {
    font-size: 9px;
}

.sidebar-announcement-date {
    font-size: 11px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 4px;
}

.sidebar-announcement-date i {
    font-size: 10px;
}

.sidebar-announcement-arrow {
    color: #d1d5db;
    font-size: 12px;
    transition: transform 0.2s ease;
}

.sidebar-announcement-item:hover .sidebar-announcement-arrow {
    color: var(--sidebar-tab-active-color);
    transform: translateX(4px);
}

/* Pinned item highlight */
.sidebar-announcement-item.is-pinned {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-left: 3px solid #f59e0b;
}

.sidebar-announcement-item.is-pinned:hover {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

/* Unread item styling */
.sidebar-announcement-item.is-unread {
    position: relative;
}

.sidebar-announcement-item.is-unread::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 4px;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: #ef4444;
    border-radius: 50%;
}

.sidebar-announcement-item.is-pinned.is-unread::before {
    left: -11px;
}

/* ========== Announcement Detail Modal ========== */
#announcementDetailModal .modal-dialog {
    max-width: 480px;
}

.announcement-modal-content {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.announcement-modal-header {
    background: var(--sidebar-tab-active-color, var(--brand-color, #754ffe));
    color: #fff;
    border: none;
    padding: 14px 16px;
}

.announcement-modal-header .modal-title {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.announcement-modal-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.announcement-modal-header .btn-close:hover {
    opacity: 1;
}

.announcement-modal-body {
    padding: 0;
}

.announcement-modal-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #f3f4f6;
}

.announcement-modal-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.announcement-modal-date {
    padding: 12px 16px 6px;
    font-size: 11px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 5px;
}

.announcement-modal-content-text {
    padding: 6px 16px 16px;
    font-size: 13px;
    line-height: 1.7;
    color: #374151;
}

.announcement-modal-content-text p {
    margin-bottom: 12px;
}

.announcement-modal-content-text p:last-child {
    margin-bottom: 0;
}

.announcement-modal-content-text a {
    color: var(--sidebar-tab-active-color);
}

.announcement-modal-content-text img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 12px 0;
}

/* Video embed trong thông báo */
.announcement-video-embed {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    margin: 16px 0;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

.announcement-video-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.announcement-modal-content-text video {
    max-width: 100%;
    border-radius: 8px;
    margin: 12px 0;
}

.announcement-modal-footer {
    border-top: 1px solid #f3f4f6;
    padding: 10px 16px;
}

.announcement-modal-footer .btn {
    font-size: 13px;
    padding: 6px 16px;
}

/* Responsive Announcements */
@media (max-width: 992px) {
    .sidebar-announcement-item {
        padding: 10px 12px;
    }
    
    .sidebar-announcement-thumb {
        width: 48px;
        height: 48px;
        min-width: 48px;
    }
    
    .sidebar-announcement-title {
        font-size: 13px;
    }
}