/* =================================================================== */
/* == CSS TÙY CHỈNH CHO TÍNH NĂNG PHỤ ĐỀ (PHIÊN BẢN HOÀN CHỈNH)     == */
/* =================================================================== */

/* =================================================================== */
/* == PHẦN 1: SỬA LỖI & GHI ĐÈ GIAO DIỆN GỐC CỦA THEME              == */
/* =================================================================== */

/* --- Sửa lỗi hiển thị thời gian của Video.js --- */
.video-js .vjs-remaining-time { display: none !important; }
.video-js .vjs-current-time,
.video-js .vjs-time-divider,
.video-js .vjs-duration {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 !important;
    padding: 0 2px !important;
    vertical-align: middle;
}
.video-js .vjs-time-control {
    padding: 0 4px !important;
    min-width: auto !important;
}

/* --- Sửa lỗi layout playlist gốc của theme không cuộn được --- */
/* Bắt buộc cột sidebar phải là một flex container theo chiều dọc */
#pt-sidebar-wrapper.play-list-cont-wrapper {
    display: flex !important;
    flex-direction: column !important;
}
/* Bắt buộc nội dung bên trong phải tự dãn ra và có thanh cuộn riêng */
#pt-sidebar-wrapper.play-list-cont-wrapper .original-sidebar-content {
    flex-grow: 1 !important;
    overflow-y: auto !important;
    min-height: 0; /* Mẹo flexbox để overflow hoạt động đúng */
}


/* =================================================================== */
/* == PHẦN 2: GIAO DIỆN CHÍNH CỦA PANEL PHỤ ĐỀ                      == */
/* =================================================================== */

/* --- Khung chung của Panel --- */
.subtitle-panel {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e1e8ed;
    height: 100%;       /* Chiều cao được JS kiểm soát */
    width: 100%;        /* Sửa lỗi: Luôn rộng 100% container cha */
    max-width: 100%;    /* Đảm bảo không tràn ra ngoài */
}

.subtitle-panel .pt-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    padding: 10px 15px;
    font-weight: 600;
    font-size: 16px;
    border-bottom: 1px solid #e1e8ed;
    background-color: #f7f7f7;
}

.subtitle-panel .pt-panel-body {
    flex-grow: 1;
    overflow-y: auto !important;
    min-height: 0;
}

/* --- Dòng phụ đề (Chế độ xem) --- */
.subtitle-panel .subtitle-line {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color .2s ease-in-out;
}
.subtitle-panel .subtitle-line:hover {
    background-color: #f6f8fa;
}
.subtitle-panel .subtitle-line.active {
    background-color: #e6f7ff !important;
    border-left: 3px solid #0366d6;
    padding-left: 12px;
}
.subtitle-panel .subtitle-time {
    color: #0366d6;
    font-size: 12px;
    font-family: monospace;
}
.subtitle-panel .subtitle-text {
    font-size: 15px;
    line-height: 1.5;
    color: #333;
    word-wrap: break-word;
}

/* --- Dòng phụ đề (Chế độ sửa) --- */
.subtitle-panel .subtitle-edit-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid #eee;
}
.subtitle-panel .time-inputs {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.subtitle-panel .subtitle-edit-line input {
    width: 110px;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 8px;
    font-family: monospace;
    font-size: 13px;
}
.subtitle-panel .subtitle-edit-line textarea {
    flex-grow: 1;
    min-height: 58px;
    resize: vertical;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 14px;
    line-height: 1.4;
}
.subtitle-panel .editor-actions {
    padding: 15px;
    text-align: right;
    border-top: 1px solid #ddd;
    background-color: #f7f7f7;
}
.subtitle-panel .editor-actions .btn {
    margin-left: 5px;
}


/* =================================================================== */
/* == PHẦN 3: LOGIC ẨN/HIỆN KHI KÍCH HOẠT PANEL                    == */
/* =================================================================== */

/* Khi JS thêm class 'subtitle-mode-active' vào body... */

/* ...ẩn hoàn toàn sidebar gốc của Playtube. */
body.subtitle-mode-active #pt-sidebar-wrapper {
    display: none !important;
}

/* ...và hiển thị container chứa panel phụ đề của chúng ta. */
body.subtitle-mode-active #subtitle-panel-container {
    display: flex !important;
}


/* =================================================================== */
/* == PHẦN 4: RESPONSIVE CHO THIẾT BỊ DI ĐỘNG                      == */
/* =================================================================== */

@media (max-width: 991px) {
    /* Style cho panel khi hiển thị trong slot mobile */
    #subtitle-viewer-panel,
    #subtitle-editor-panel {
        height: auto !important;
        max-height: 60vh !important;
        margin-top: 15px;
        margin-bottom: 15px;
    }

    /* Style cho slot mobile */
    #subtitle-panel-slot-mobile {
        width: 100%;
        padding: 0 15px;
    }

    /* Trên mobile, không cần dùng logic ẩn container desktop */
    body.subtitle-mode-active #subtitle-panel-container {
        display: none !important;
    }
}