/* =========================================
   GHI ĐÈ MÀU MẶC ĐỊNH CỦA BOOTSTRAP (BLUE -> PINK)
   ========================================= */
:root {
    /* Màu hồng neon nhạt / Hồng phấn */
    --bs-primary: #ff6fa5;
    --bs-primary-rgb: 255, 111, 165;
}

/* Ép các nút bấm đổi màu Hồng và chữ màu trắng */
.btn-primary {
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
    color: #ffffff !important;
}

    /* Màu khi di chuột vào nút (Đậm hơn một chút) */
    .btn-primary:hover, .btn-primary:focus, .btn-primary:active {
        background-color: #e65c92 !important;
        border-color: #e65c92 !important;
        color: #ffffff !important;
    }

/* Đổi màu các đoạn text, icon dùng class text-primary */
.text-primary {
    color: var(--bs-primary) !important;
}

/* ========================================= */

/* Đổi màu mặc định của tất cả các đường link (a) */
a {
    color: var(--bs-primary);
    text-decoration: none;
}

    a:hover {
        color: #e65c92;
    }

/* Đổi màu cho các Tabs (Photos / Videos) */
.nav-tabs .nav-link {
    color: #6c757d; /* Xám tối cho tab chưa chọn để dễ nhìn */
    font-weight: 500;
}

    .nav-tabs .nav-link.active {
        color: var(--bs-primary) !important; /* Hồng phấn cho tab đang chọn */
        font-weight: bold;
        border-color: #dee2e6 #dee2e6 #f0f2f5 !important; /* Đồng màu với nền xám nhạt */
    }

    .nav-tabs .nav-link:hover {
        color: var(--bs-primary);
    }

/* Reset cơ bản */
body, html {
    margin: 0;
    padding: 0;
    height: 100vh; /* Chiều cao bằng đúng cửa sổ trình duyệt */
    overflow: hidden; /* Cấm cuộn toàn trang */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f4f5;
}

/* Container chính chia 3 cột */
.app-container {
    display: flex;
    height: 100%;
    width: 100%;
}

/* Cột Trái: Menu Điều hướng */
.sidebar-left {
    width: 280px;
    background-color: #ffffff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Cho phép cuộn dọc nội dung bên trong */
}

/* Cột Giữa: Khung hiển thị nội dung (Giống khung Chat) */
.main-content {
    flex: 1;
    /* Xóa bỏ hình nền chat-bg nếu có để tránh rối mắt */
    background-image: none;
    /* Màu xám nhạt cực kỳ thanh lịch, làm nổi bật thẻ card màu trắng */
    background-color: #f0f2f5;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 20px;
    position: relative;
}

/* Cột Phải: Menu Phụ (Lịch & Thumbnail) */
.sidebar-right {
    width: 320px;
    background-color: #ffffff;
    border-left: 1px solid #e0e0e0;
    display: flex; /* Mặc định có thể set là 'none' và dùng JS để bật/tắt */
    flex-direction: column;
    overflow-y: auto;
    transition: width 0.3s ease;
}

/* Tùy chỉnh thanh cuộn cho đẹp giống app */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #bdbdbd;
    border-radius: 4px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }

/* =========================================
   GLOBAL MEDIA LIGHTBOX (PLAYER KHUNG NỔI)
   ========================================= */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.95); /* Đen mờ 95% */
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

    /* Kích hoạt khi bật Player */
    .lightbox-overlay.active {
        opacity: 1;
        visibility: visible;
    }

/* Nút Đóng */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    z-index: 10000;
}

/* Khu vực hiển thị nội dung (Video/Ảnh) */
.lightbox-content-wrapper {
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

    .lightbox-content-wrapper video,
    .lightbox-content-wrapper img {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 8px;
        box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    }

/* Khung hiển thị thông báo chặn (Yêu cầu VIP) */
.lightbox-locked-message {
    background: #1a1a1a;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    color: white;
    border: 1px solid #333;
}

/* =========================================
   TELEGRAM STYLE GALLERY COLLAGE
   ========================================= */
.tg-gallery {
    display: grid;
    gap: 4px; /* Khoảng cách giữa các ảnh cực nhỏ giống Telegram */
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
}

    /* Trường hợp có 2 ảnh */
    .tg-gallery.grid-2 {
        grid-template-columns: 1fr 1fr;
        height: 250px;
    }

    /* Trường hợp có 3 ảnh (1 lớn, 2 nhỏ) */
    .tg-gallery.grid-3 {
        grid-template-columns: 2fr 1fr;
        grid-template-rows: 1fr 1fr;
        height: 300px;
    }

        .tg-gallery.grid-3 img:nth-child(1) {
            grid-row: span 2;
        }

    .tg-gallery img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        cursor: pointer;
        transition: opacity 0.2s;
    }

        .tg-gallery img:hover {
            opacity: 0.9;
        }

/* Nút tương tác (Like, Comment) dưới mỗi post */
.post-actions {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    border-top: 1px solid #f0f2f5;
    padding-top: 10px;
}

.post-action-btn {
    background: none;
    border: none;
    color: #6c757d;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s;
    cursor: pointer;
    padding: 0;
}

    .post-action-btn:hover {
        color: var(--bs-primary);
    }

/* Giao diện Telegram Custom Player */
.tg-player-container {
    width: 100%;
    height: 100%; /* Chiếm trọn chiều cao của Lightbox */
    background-color: #000;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-radius: 8px;
}

.tg-player-video {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Cứu tinh ở đây: Tự động zoom vừa khít bất chấp dọc hay ngang */
}

.tg-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 100%);
    display: flex;
    flex-direction: column;
    padding: 10px 15px;
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.tg-player-container.idle .tg-controls {
    opacity: 0; /* Tự động ẩn khi không di chuyển chuột */
}

/* Thanh tiến trình mỏng */
.tg-progress {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    cursor: pointer;
    margin-bottom: 10px;
    position: relative;
}

.tg-progress-filled {
    height: 100%;
    background: var(--bs-primary); /* Đổi sang màu Hồng Primary cho đẹp */
    border-radius: 2px;
    width: 0%;
    position: relative; /* Bắt buộc phải có để làm gốc cho cục Point */
}

    /* [THÊM MỚI]: Cục Point tròn tròn ở cuối thanh Progress */
    .tg-progress-filled::after {
        content: '';
        position: absolute;
        right: -6px; /* Tâm nằm ngay mép thanh chạy */
        top: 50%;
        transform: translateY(-50%);
        width: 12px;
        height: 12px;
        background-color: #fff;
        border-radius: 50%;
        box-shadow: 0 0 4px rgba(0,0,0,0.5);
        z-index: 2;
        transition: transform 0.1s ease;
    }

/* Phóng to cục Point một chút khi rê chuột vào thanh cuộn */
.tg-progress:hover .tg-progress-filled::after {
    transform: translateY(-50%) scale(1.3);
}

.tg-control-buttons {
    display: flex;
    align-items: center;
    gap: 15px;
    color: white;
}

.tg-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

    .tg-btn:hover {
        transform: scale(1.1);
    }

.tg-time {
    font-size: 0.85rem;
    font-family: monospace;
    user-select: none;
}

/* 1. Ép Lightbox bung to ra (90% màn hình) thay vì bị bó hẹp */
.lightbox-content {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    background-color: #000; /* Nền đen tuyền */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.tg-player-container {
    display: flex;
    flex-direction: column;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    background-color: #000;
}

.tg-player-video {
    width: auto;
    height: auto;
    max-width: 100%;
    /* Trừ đi khoảng 60px chiều cao của thanh điều khiển bên dưới để không bị lẹm */
    max-height: calc(100vh - 60px);
    object-fit: contain; /* Bí quyết giữ đúng tỷ lệ (ngang/dọc) không bị méo */
}

/* 3. CSS Tặng kèm cho cái Menu Chọn Chất Lượng (Bánh răng) */
.tg-quality-container {
    position: relative;
    display: flex;
    align-items: center;
}

.tg-quality-menu {
    display: none;
    position: absolute;
    bottom: 100%; /* [QUAN TRỌNG]: Ép menu xổ NGƯỢC lên trên thay vì đâm xuống dưới */
    right: -10px; /* Căn sát lề phải của nút bánh răng */
    margin-bottom: 12px; /* Cách nút bánh răng 1 khoảng nhỏ */
    background: rgba(28, 28, 28, 0.95);
    border-radius: 6px;
    padding: 8px 0;
    min-width: 100px;
    z-index: 1080; /* [QUAN TRỌNG]: Đẩy z-index lên cực cao để không bị thanh điều khiển nào đè lên */
    box-shadow: 0 -4px 12px rgba(0,0,0,0.5); /* Bóng đổ hướng lên trên */
}

.tg-quality-item {
    color: #fff;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: right;
}

    .tg-quality-item:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .tg-quality-item.active {
        color: var(--bs-primary); /* Đồng bộ dùng màu Hồng Primary thay vì màu xanh cũ */
    }

        .tg-quality-item.active::before {
            content: '✔ ';
        }

.tg-player-controls {
    position: relative !important; /* Gỡ bỏ absolute để nó không đè lên video */
    bottom: auto !important;
    width: 100%;
    background-color: #111; /* Màu xám đen tách biệt với video */
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 15px; /* Giãn cách các nút cho thoáng */
}

/* ==========================================
   VOLUME SLIDER CHUẨN (XỔ DỌC LÊN TRÊN)
   ========================================== */
.tg-volume-container {
    display: flex;
    align-items: center;
    position: relative;
}

/* Vỏ bọc nổi lên trên */
.tg-volume-slider-wrapper {
    position: absolute;
    bottom: 100%; /* Nhảy lên phía trên nút Loa */
    left: 50%;
    transform: translateX(-50%);
    height: 0;
    width: 32px;
    opacity: 0;
    overflow: hidden;
    transition: height 0.3s ease, opacity 0.3s ease, margin-bottom 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(20, 20, 20, 0.85); /* Nền tối mờ xịn xò */
    border-radius: 8px;
    margin-bottom: 5px;
    backdrop-filter: blur(4px);
}

    /* Khi hover chuột hoặc được click trên mobile */
    .tg-volume-container:hover .tg-volume-slider-wrapper,
    .tg-volume-slider-wrapper.active {
        height: 110px; /* Chiều cao khi xổ lên */
        opacity: 1;
        margin-bottom: 15px; /* Cách ra một chút cho đẹp */
    }

/* Biến thanh ngang thành thanh dọc */
.tg-volume-slider {
    -webkit-appearance: none;
    width: 90px; /* Bề ngang ảo (sẽ thành chiều cao khi xoay) */
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    transform: rotate(-90deg); /* Xoay 90 độ để dựng đứng */
}

    .tg-volume-slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background: #fff;
        cursor: pointer;
        box-shadow: 0 0 5px rgba(0,0,0,0.8);
    }

/* =========================================
   TELEGRAM CHAT BUBBLE STYLE
   ========================================= */
.chat-message-left {
    display: flex;
    justify-content: flex-start; /* Ép toàn bộ khối tấp vào lề trái */
    align-items: flex-end; /* Telegram thường để Avatar nằm sát mép dưới của bong bóng */
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
}

.chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.chat-bubble {
    background-color: #ffffff;
    padding: 12px 14px;
    /* Góc bẻ trái dưới: 18px 18px 18px 4px (Vuông ở góc dưới trái) */
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    max-width: 85%;
    min-width: 250px;
    width: fit-content; /* Ôm sát nội dung thay vì giãn 100% */
    position: relative;
}

/* Header của Bong bóng chat (Tên + Giờ) */
.chat-bubble-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.chat-bubble-time {
    font-size: 0.75rem;
    color: #9e9e9e;
    margin-left: auto;
    padding-left: 15px;
}

/* =========================================
   SMART AUTO-FIT GRID DÀNH CHO MEDIA
   ========================================= */
.smart-media-grid {
    display: grid;
    /* Tự động tính toán: chiều rộng ô tối thiểu 145px, dư chỗ thì chia đều */
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 12px;
    width: 100%;
}

/* =========================================
   SMART PRICING / DONATE GRID (CHỐNG ÉP CHỮ)
   ========================================= */
.smart-pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

.hover-card {
    cursor: pointer;
    transition: 0.3s;
}

    .hover-card:hover {
        transform: translateY(-8px);
        box-shadow: 0 1rem 3rem rgba(0,0,0,.175) !important;
    }

/* =========================================
   RESPONSIVE MOBILE (OFFCANVAS SIDEBAR)
   ========================================= */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
}

/* Chỉ kích hoạt khi màn hình nhỏ hơn 992px (Mobile / Tablet) */
@media (max-width: 991.98px) {
    .sidebar-left {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1050;
        background: white;
        transform: translateX(-100%);
        transition: transform 0.3s ease; /* Bổ sung hiệu ứng trượt cho Mobile */
    }

        .sidebar-left.show {
            transform: translateX(0);
        }

    .sidebar-right {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        z-index: 1050;
        background: white;
        transform: translateX(100%);
        display: flex !important;
        transition: transform 0.3s ease;
    }

        .sidebar-right.show {
            transform: translateX(0);
        }

    .mobile-overlay.show {
        display: block;
    }

    .mobile-footer-safe {
        padding-bottom: calc(env(safe-area-inset-bottom) + 15px) !important;
    }


    /* [ĐÃ SỬA]: Ép Padding-top về 0 để Navbar hít sát lên mép màn hình.
       Vì cấu trúc đang dùng Flex Column nên nó sẽ tự động đẩy nội dung xuống dưới mượt mà. */
    #main-content-area {
        padding-top: 0 !important;
    }
}

@media (min-width: 768px) {
    .border-end-md {
        border-right: 1px solid #dee2e6;
    }
}