:root {
    --neon-purple: #8b5cf6;
    --neon-blue: #1E90FF;
    --neon-green: #219653;
}

#lobby-container.teacher-active .teacher-config-panel {
    opacity: 1;
    visibility: visible;
    animation: slideInLeft 0.5s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

.teacher-config-panel {
    position: absolute;
    top: 50%;
    left: 30px;
    width: calc(100% - 552px);
    height: calc(0.9 * (100% - 60px));
    transform: translateY(-50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(40px);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    border-radius: 40px;
    padding: 40px;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    display: flex;
    flex-direction: column;
    transition: 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    box-shadow: 0 0 50px rgba(255, 255, 255, 0.1);
}

.teacher-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 800;
    color: white;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Nút quay lại danh sách bài trong bảng cấu hình */
.teacher-panel-header .btn-config-back {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: 0.2s;
}

.teacher-panel-header .btn-config-back:hover {
    background: rgba(255, 255, 255, 0.25);
}

.teacher-panel-header .btn-config-back .material-icons-round {
    font-size: 20px;
}

.teacher-panel-body .form-group {
    margin-bottom: 20px;
}

.teacher-panel-body label {
    display: block;
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 8px;
}

.teacher-panel-body input {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 12px 16px;
    color: white;
    outline: none;
    transition: 0.3s;
}

.teacher-panel-body input:focus {
    border-color: var(--neon-purple);
    background: rgba(255,255,255,0.1);
}

.btn-run-test {
    width: 100%;
    background: #bb2649;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 0 20px rgba(187, 38, 73, 0.3);
    transition: 0.3s;
}

.btn-run-test:hover {
    transform: scale(1.02);
    box-shadow: 0 0 35px rgba(187, 38, 73, 0.5);
}

@keyframes slideInLeft {
    from { transform: translateY(-50%) translateX(-100px); opacity: 0; }
    to { transform: translateY(-50%) translateX(0); opacity: 1; }
}

#lobby-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 9999;
    background: #020617;
    overflow: hidden;
    display: none; /* Controlled by simulations.js */
    font-family: 'Be Vietnam Pro', sans-serif;
}

#threejs-render-target {
    pointer-events: auto;
}

#lobby-container .hud-overlay, 
#lobby-container .lobby-nav-top {
    pointer-events: none;
}

#lobby-container .hud-overlay > *, 
#lobby-container .lobby-nav-top > * {
    pointer-events: auto;
}

#lobby-container.active {
    display: block;
}

/* ===== Điều hướng "đến đối diện từng bàn" ===== */
#lobby-nav {
    position: absolute;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    width: max-content;
    max-width: calc(100vw - 24px);
}
#lobby-nav .lobby-nav-hint {
    pointer-events: none;
    color: rgba(255,255,255,0.85);
    background: rgba(2,6,23,0.55);
    backdrop-filter: blur(6px);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.12);
}
#lobby-nav .lobby-nav-row {
    pointer-events: auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    background: rgba(2,6,23,0.55);
    backdrop-filter: blur(10px);
    padding: 8px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
#lobby-nav .lobby-nav-btn {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.14);
    padding: 9px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: 0.2s;
    font-family: inherit;
}
#lobby-nav .lobby-nav-btn .nav-short { display: none; }
#lobby-nav .lobby-nav-btn:hover { background: rgba(255,255,255,0.18); }
#lobby-nav .lobby-nav-btn.active {
    background: #bb2649;
    border-color: #bb2649;
    box-shadow: 0 4px 14px rgba(187,38,73,0.5);
}
#lobby-container.hud-active #lobby-nav,
#lobby-container.teacher-active #lobby-nav { display: none; }

/* Thông báo đổi đèn: nổi ở phía trên, không đè lên hàng nút điều hướng dưới đáy */
#lobby-notice {
    position: absolute;
    top: max(78px, calc(env(safe-area-inset-top, 0px) + 66px));
    left: 50%;
    transform: translate(-50%, -8px);
    z-index: 300;
    background: rgba(255, 255, 255, 0.96);
    color: #1e293b;
    font-weight: 700;
    font-size: 14px;
    padding: 9px 18px;
    border-radius: 22px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
#lobby-notice.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

#threejs-render-target {
    width: 100%;
    height: 100%;
    transition: filter 0.5s ease, transform 0.5s ease;
}

#lobby-container.hud-active #threejs-render-target {
    filter: blur(15px) brightness(0.6);
    transform: scale(1.05);
}

/* Spatial HTML Labels - 3D Card Style */
.spatial-label {
    position: absolute;
    pointer-events: none;
    z-index: 100;
    will-change: transform;
    opacity: 0;
    transition: opacity 0.5s ease;
}
.spatial-label.visible {
    opacity: 1;
}

.label-card-3d {
    width: 200px;
    height: 280px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 32px;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 30px 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    text-align: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.label-card-3d .card-icon {
    font-size: 56px;
    margin-bottom: 5px;
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.3));
}

.label-card-3d .card-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 6px;
}

.label-card-3d .card-sub {
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    line-height: 1.4;
    font-weight: 500;
}

.label-card-3d .card-btn {
    margin-top: auto;
    background: transparent;
    border: 1.5px solid white;
    color: white;
    padding: 6px 20px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Main Navigation Buttons */
.lobby-nav-top {
    position: absolute;
    top: 30px;
    left: 30px;
    z-index: 10500 !important;
    display: flex !important;
    gap: 15px;
}

.btn-lobby-main {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 10px 20px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-lobby-main:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ef4444;
    transform: translateY(-2px);
}

.btn-lobby-back {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 10px 20px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    transition: 0.3s;
}

#lobby-container.hud-active .btn-lobby-back {
    display: flex;
}

.btn-lobby-back:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 35px rgba(255, 255, 255, 0.4);
}

#lobby-container.hud-active .hud-overlay {
    display: flex;
}

.hud-overlay {
    position: absolute;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: flex-end;
    padding: 30px;
}

.hud-panel {
    width: 480px;
    height: 90%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 40px;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 50px rgba(0,0,0,0.5);
    animation: slideInRight 0.5s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

@keyframes slideInRight {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.hud-header {
    padding: 35px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.hud-title {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 1px;
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

/* Accordion Specifics */
.accordion-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 30px 40px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.accordion-item {
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    overflow: hidden;
    transition: 0.3s;
}

.accordion-item.active { background: rgba(255, 255, 255, 0.05); border-color: rgba(255,255,255,0.2); }

.accordion-item-header {
    padding: 22px 24px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
}

.accordion-item.active .accordion-content { max-height: 1000px; }

.lesson-li {
    padding: 12px 24px;
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    transition: 0.2s;
    display: flex; align-items: center;
}

.lesson-li:hover {
    background: rgba(255,255,255,0.05);
    color: white;
    padding-left: 32px;
}

/* Split View Layout */
.split-view-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #020617;
    display: none;
    flex-direction: column;
}

.split-view-overlay.active {
    display: flex;
}

.split-view-header {
    height: 60px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.split-view-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.left-sim-col {
    flex: 6;
    background: #000;
    position: relative;
    border-right: 1px solid rgba(255,255,255,0.1);
}

/* Thông báo khi bài học chưa gắn mô phỏng (thay vì màn hình đen trống) */
.sim-empty-state {
    display: none;
    position: absolute;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.55);
    text-align: center;
    padding: 20px;
    pointer-events: none;
}

.sim-empty-state .material-icons-round {
    font-size: 46px;
}

.sim-empty-state p {
    margin: 0;
    font-size: 14px;
}

.right-content-col {
    flex: 4;
    background: white;
    color: #1e293b;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

#lesson-view-title {
    color: white !important;
    font-weight: 800;
}

#lesson-editor-container {
    flex: 1;
    padding: 20px;
}

#quill-editor {
    height: auto;
    min-height: 500px;
    /* Ưu tiên 2 font đã tải sẵn từ Google (có đủ nét thường 400 và nét đậm 700)
       thay vì phụ thuộc font cài trong máy — nhờ vậy nút Bold ăn thua rõ rệt. */
    font-family: 'Be Vietnam Pro', 'Inter', 'Aptos Display', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    font-weight: 400;
    border: none !important;
}

/* MS Word Style Toolbar Customization */
.ql-toolbar.ql-snow {
    border: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 10px 20px !important;
}

.ql-container.ql-snow {
    border: none !important;
}

.youtube-footer {
    padding: 20px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.yt-link-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
}

.yt-player-container {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    margin-top: 15px;
    border-radius: 12px;
    overflow: hidden;
}

.btn-save-all {
    background: #219653;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close-split {
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}
.btn-close-split .close-split-x { display: none; }

/* Mobile Adjustments */
@media (max-width: 1100px) {
    /* Xếp dọc: mô phỏng ở trên, nội dung ở dưới; toàn bộ vùng thân được cuộn */
    .split-view-body {
        flex-direction: column;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .left-sim-col {
        flex: 0 0 auto;
        width: 100%;
        height: 60vh;
        min-height: 320px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .right-content-col {
        flex: 0 0 auto;
        width: 100%;
        overflow-y: visible;
    }

    #quill-editor { min-height: 260px; }
}

/* Điện thoại dọc: khung mô phỏng thấp hơn để còn thấy phần nội dung */
@media (max-width: 640px) {
    .left-sim-col {
        height: 52vh;
        min-height: 260px;
    }
}

/* Chỉ ĐIỆN THOẠI (<=640px): chừa safe-area phía trên để tiêu đề bài học không bị đồng hồ/tai thỏ đè */
@media (max-width: 640px) {
    .split-view-header {
        height: auto;
        min-height: 56px;
        padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px 16px;
        gap: 10px;
    }
    .split-view-header > div:first-child {
        min-width: 0;
        flex: 1;
    }
    #lesson-view-title {
        font-size: 15px !important;
        line-height: 1.25;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        word-break: break-word;
    }
    /* Nút đóng bài học: chỉ còn dấu X nhỏ ở góc phải, để tiêu đề không bị chèn */
    .btn-close-split {
        flex-shrink: 0;
        white-space: nowrap;
        width: 38px;
        height: 38px;
        padding: 0;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255,255,255,0.15);
    }
    .btn-close-split .close-split-text { display: none; }
    .btn-close-split .close-split-x { display: inline-flex; font-size: 22px; }

    /* ==== Phòng thí nghiệm ảo — chỉ điện thoại ==== */
    /* Nút Về trang chủ / Quay lại không gian: chỉ còn icon */
    .lobby-nav-top {
        top: max(10px, env(safe-area-inset-top, 0px));
        left: 12px;
        gap: 8px;
    }
    .lobby-nav-top .lobby-btn-label { display: none; }
    .lobby-nav-top .btn-lobby-main,
    .lobby-nav-top .btn-lobby-back {
        width: 44px;
        height: 44px;
        padding: 0;
        justify-content: center;
        gap: 0;
        border-radius: 12px;
    }
    /* Nút ngôi nhà: nền đỏ Wisdemy cho dễ nhìn (không trùng màu phòng trắng) */
    .lobby-nav-top .btn-lobby-main {
        background: #bb2649 !important;
        color: #fff !important;
        border: none !important;
        box-shadow: 0 4px 12px rgba(187,38,73,0.35);
    }

    /* Thanh chọn góc camera: 10 / 11 / 12 + icon toàn màn hình, luôn 1 hàng */
    #lobby-nav .nav-full { display: none; }
    #lobby-nav .lobby-nav-btn .nav-short { display: inline-flex; align-items: center; }
    #lobby-nav .lobby-nav-row { flex-wrap: nowrap; gap: 6px; padding: 7px; }
    #lobby-nav .lobby-nav-btn { padding: 9px 0; min-width: 52px; justify-content: center; font-size: 14px; }
    #lobby-nav .lobby-nav-btn .nav-short .material-icons-round { font-size: 20px; }

    /* Khung danh sách bài nhỏ lại & lùi xuống để không bị 2 nút phía trên đè lên */
    .hud-overlay { padding: 14px; align-items: stretch; justify-content: center; }
    .hud-panel {
        width: 100%;
        max-width: 520px;
        height: auto;
        max-height: calc(100% - 108px);
        margin-top: 92px;
        border-radius: 24px;
    }
    .hud-header { padding-top: 20px !important; }

    /* ==== Bảng "Cấu hình Bài học" (GV) — chỉ điện thoại — sửa 2026-07-27 ====
       Lỗi cũ: width: calc(100% - 552px) → trên điện thoại ra số ÂM nên khung
       bị bóp còn vài chục px, chữ dựng đứng và đè lên danh sách bài phía sau. */
    .teacher-config-panel {
        top: calc(env(safe-area-inset-top, 0px) + 66px) !important;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 16px) !important;
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        height: auto !important;
        max-height: none !important;
        transform: none !important;
        animation: none !important;
        padding: 18px 16px !important;
        border-radius: 24px !important;
        background: rgba(15, 23, 42, 0.98) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    #lobby-container.teacher-active .teacher-config-panel {
        animation: none !important;
        transform: none !important;
    }

    /* Ẩn hẳn danh sách chương/bài phía sau để không bị chồng chữ */
    #lobby-container.teacher-active .hud-overlay {
        display: none !important;
    }

    .teacher-config-panel .teacher-panel-header {
        font-size: 12px !important;
        letter-spacing: 1px !important;
        gap: 8px !important;
        margin-bottom: 18px !important;
        padding-bottom: 12px !important;
        white-space: nowrap !important;
    }

    .teacher-config-panel .teacher-panel-header .material-icons-round {
        font-size: 20px !important;
        flex-shrink: 0 !important;
    }

    .teacher-config-panel .teacher-panel-body {
        justify-content: flex-start !important;
    }

    .teacher-config-panel .hud-title {
        font-size: clamp(17px, 5.6vw, 26px) !important;
        margin-bottom: 18px !important;
        line-height: 1.25 !important;
        word-break: break-word !important;
    }

    .teacher-config-panel .form-group {
        margin-bottom: 20px !important;
    }

    .teacher-config-panel input {
        padding: 12px 14px !important;
        font-size: 14px !important;
        box-sizing: border-box !important;
    }

    .teacher-config-panel .btn-run-test {
        padding: 14px 10px !important;
        font-size: 13px !important;
        border-radius: 12px !important;
        white-space: nowrap !important;
    }
}

/* ---------------------------------------------------------------------------
   FONT 'Aptos Display' — VÌ SAO PHẢI SỬA
   Khai báo cũ:
       src: local('Aptos Display'), local('Segoe UI Semibold'), local('Inter');
   không ghi font-weight nên trình duyệt hiểu mặc định là "chữ THƯỜNG = 400".
   Máy nào không cài Aptos Display (đa số máy Windows) sẽ rơi xuống
   'Segoe UI Semibold' — vốn là kiểu chữ ĐẬM SẴN — và dùng nó làm chữ thường.
   Hậu quả: soạn bài trong Phòng thí nghiệm ảo thì mọi chữ đều đậm, bấm nút
   Bold hay không cũng như nhau.
   Nay tách rõ: 400 lấy kiểu chữ thường, 700 mới lấy kiểu đậm.
--------------------------------------------------------------------------- */
@font-face {
    font-family: 'Aptos Display';
    src: local('Aptos Display'), local('Aptos'), local('Segoe UI'), local('Inter');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Aptos Display';
    src: local('Aptos Display Bold'), local('Aptos Bold'), local('Segoe UI Bold'), local('Inter Bold');
    font-weight: 700;
    font-style: normal;
}

/* Chốt thêm một lớp nữa ngay trong ô soạn thảo: chữ thường luôn là 400,
   chỉ phần được bôi đậm mới 700. Không phụ thuộc font máy học sinh có gì. */
#quill-editor .ql-editor,
.ql-container .ql-editor {
    font-weight: 400;
}

#quill-editor .ql-editor b,
#quill-editor .ql-editor strong,
.ql-container .ql-editor b,
.ql-container .ql-editor strong {
    font-weight: 700;
}

/* Tiêu đề trong bài vẫn đậm như bình thường */
#quill-editor .ql-editor h1,
#quill-editor .ql-editor h2,
#quill-editor .ql-editor h3 {
    font-weight: 700;
}
