/* Overlay chỉ cho modal avatar */
.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.25);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease;
    z-index: 1100; /* below avatar-popup (1200) */
}
.popup-overlay.show { opacity: 1; visibility: visible; }
.avatar-change-popup {
    display: none !important;
    transition: none !important; /* Disable transition initially */
}
.avatar-change-popup.show {
    display: flex !important;
}
/* Popup đổi ảnh đại diện */
.avatar-change-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    z-index: 1202;
}
.avatar-change-content {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    padding: 32px 32px 24px 32px;
    min-width: 340px;
    max-width: 90vw;
    text-align: center;
    position: relative;
}
.close-avatar-popup {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #222;
    cursor: pointer;
    z-index: 1;
}
.avatar-change-content h2 {
    margin-top: 0;
    margin-bottom: 24px;
    font-size: 1.4rem;
    font-weight: 700;
    color: #222;
}
.avatar-change-img-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
}
.avatar-preview-img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid #b6d43a;
    object-fit: cover;
    background: #f5f5f5;
}
.avatar-upload-btn {
    display: none !important;
}
.camera-icon {
    display: none !important;
}
.upload-avatar-btn {
    background: #b6d43a;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
}
.upload-avatar-btn:hover {
    background: #a0be2e;
}
/* Basic body styles */
body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Ẩn hoàn toàn các style liên quan đến giáo viên ở ngoài header */
.teacher-info, .avatar-container, .teacher-details, .status-indicator, .status-dot {
    display: none !important;
}

/* Header chỉ còn logo và menu */
.header {
    background-color: #f5f4f9;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    min-height: 85px;
    position: relative;
}
.logo-container {
    margin-right: 10px;
}
.logo {
    height: 50px;
    width: auto;
}
.menu-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    z-index: 1101;
}
.menu-line {
    width: 30px;
    height: 4px;
    background-color: #333;
    border-radius: 2px;
    transition: all 0.3s;
}
.menu-button.active .menu-line {
    background-color: #8bc34a;
}

/* Popup avatar (ẩn mặc định, dùng visibility để tránh chớp) */
.avatar-popup {
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
    z-index: 1200;
    max-width: 95vw;
    padding-bottom: 10px;
    width: 320px;
}
.avatar-popup.show {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0);
}
.popup-header {
    padding: 24px 24px 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid #f0f0f0;
}
.popup-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2.5px solid #8bc34a;
    object-fit: cover;
    background: #f5f4f9;
}
.popup-teacher-info h3 {
    font-size: 22px;
    color: #222;
    margin-bottom: 4px;
    font-weight: 700;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.popup-teacher-code {
    font-size: 16px;
    color: #222;
    font-weight: 500;
}
.popup-menu {
    padding: 10px 0 0 0;
}
.popup-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    color: #222;
    text-decoration: none;
    font-size: 17px;
    font-weight: 400;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 0.2s;
    cursor: pointer;
    border-radius: 8px;
}
.popup-menu-item:hover {
    background-color: #f5f4f9;
}
.popup-menu-item.with-toggle {
    padding-right: 18px;
}
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #8bc34a;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-left: 12px;
}
.toggle-switch::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
}
.toggle-switch.off {
    background-color: #e0e0e0;
}
.toggle-switch.off::before {
    transform: translateX(20px);
}
.language-text {
    color: #3b7ddd;
    font-weight: 500;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-style: italic;
}


/* Menu Popup */
.menu-popup {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    width: 260px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1203;
    margin-top: 8px;
    max-height: 90vh;
    overflow: visible;
}

.menu-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-popup-content {
    padding: 8px 0;
}

.menu-popup-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    color: #333;
    text-decoration: none;
    font-size: 15px;
    font-weight: 400;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    border-radius: 8px;
    margin: 2px 8px;
}

.menu-popup-item:hover {
    background-color: #f0f8ff;
    color: #a4d65e;
}

.menu-popup-item.has-submenu:hover {
    background-color: #f0f8ff;
    color: #a4d65e;
}

.menu-popup-item.has-submenu:hover .menu-arrow {
    color: #a4d65e;
    transform: translateX(2px);
}

.menu-arrow {
    color: #666;
    font-size: 12px;
    transition: all 0.2s ease;
}

.menu-popup-item .menu-arrow {
    transform: translateX(0);
}

/* Submenu Styles */
.submenu {
    position: absolute;
    left: 100%;
    top: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 240px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.3s ease;
    z-index: 1203;
    margin-left: 15px;
    overflow: visible;
}

.submenu.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.menu-popup-item.has-submenu:hover .submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.menu-popup-item.active {
    background-color: #a4d65e !important;
    color: white !important;
}

.menu-popup-item.active .menu-arrow {
    color: white !important;
    transform: translateX(2px);
}

.submenu-item {
    display: block;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 0.2s ease;
    border-radius: 8px;
    margin: 4px 8px;
    text-align: left;
    white-space: nowrap;
}

.submenu-item:hover {
    background-color: #f0f8ff;
    color: #a4d65e;
    text-align: left;
}

.submenu-item:first-child {
    margin-top: 8px;
}

.submenu-item:last-child {
    margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 12px 16px;
        min-height: 75px;
    }

    .logo {
        height: 42px;
    }

    .menu-line {
        width: 26px;
        height: 3px;
    }

    .menu-popup {
        width: 220px;
        position: absolute;
        top: 100%;
        left: 0;
        right: auto;
        transform: translateY(-10px);
        margin-top: 8px;
        max-width: calc(50vw - 16px);
    }
    
    .menu-popup.show {
        transform: translateY(0);
    }
    
    .menu-popup-item {
        padding: 12px 16px;
        font-size: 14px;
        white-space: nowrap;
    }
    
    .submenu {
        width: 180px;
        left: 100% !important;
        right: auto !important;
        top: 0;
        position: absolute;
        margin-left: 10px !important;
        margin-right: 0 !important;
    }
    
    .submenu-item {
        padding: 12px 16px;
        font-size: 14px;
        text-align: left;
        white-space: nowrap;
    }

    .avatar-popup {
        width: 98vw;
        min-width: 0;
        right: 0;
        left: auto;
        top: 100%;
        padding-bottom: 8px;
    }
    
    .popup-header {
        padding: 16px 10px 8px 10px;
        gap: 10px;
    }
    
    .popup-avatar {
        width: 40px;
        height: 40px;
    }
    
    .popup-menu-item {
        padding: 10px 10px;
        font-size: 15px;
    }
}

/* Xử lý khi menu popup có thể tràn ra ngoài màn hình */
@media (max-width: 768px) {
    .menu-button {
        position: relative;
    }
    
    /* Nếu button ở gần cạnh phải màn hình, menu sẽ hiện về bên trái */
    .menu-button:has(.menu-popup) {
        position: relative;
    }
    
    /* Kiểm tra và điều chỉnh vị trí menu khi gần cạnh phải */
    @supports (width: max(0px)) {
        .menu-popup {
            left: max(0px, min(0px, calc(100vw - 100% - 320px)));
        }
    }
}

@media (max-width: 480px) {
    .header {
        padding: 10px 12px;
        min-height: 70px;
    }

    .logo {
        height: 38px;
    }

    .menu-line {
        width: 24px;
        height: 3px;
    }

    .menu-popup {
        width: 200px;
        position: absolute;
        top: 100%;
        left: 0;
        right: auto;
        transform: translateY(-10px);
        margin-top: 8px;
        max-width: calc(50vw - 12px);
    }
    
    .menu-popup.show {
        transform: translateY(0);
    }
    
    .menu-popup-item {
        padding: 10px 14px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    .submenu {
        width: 160px;
        left: 100% !important;
        right: auto !important;
        top: 0;
        position: absolute;
        margin-left: 8px !important;
        margin-right: 0 !important;
    }
    
    .submenu-item {
        padding: 9px 12px;
        font-size: 12px;
        text-align: left;
        white-space: nowrap;
    }

    .avatar-popup {
        width: 98vw;
        min-width: 0;
        right: 0;
        left: auto;
        top: 100%;
        padding-bottom: 8px;
    }
    
    .popup-header {
        padding: 14px 16px 10px;
        gap: 10px;
    }
    
    .popup-avatar {
        width: 40px;
        height: 40px;
    }
    
    .popup-menu-item {
        padding: 9px 16px;
        font-size: 13px;
    }
}

@media (max-width: 360px) {
    .menu-popup {
        width: 180px;
        position: absolute;
        top: 100%;
        left: 0;
        right: auto;
        transform: translateY(-10px);
        margin-top: 8px;
        max-width: calc(50vw - 10px);
    }
    
    .menu-popup-item {
        padding: 8px 12px;
        font-size: 12px;
        white-space: nowrap;
    }
    
    .submenu {
        width: 180px;
        max-width: 180px;
        margin-left: 12px;
    }
    
    .submenu-item {
        padding: 7px 10px;
        font-size: 11px;
        text-align: left;
        white-space: nowrap;
    }

    .avatar-popup {
        width: 98vw;
        min-width: 0;
        right: 0;
        left: auto;
        top: 100%;
        padding-bottom: 8px;
    }
    
    .popup-header {
        padding: 12px 14px 8px;
        gap: 8px;
    }
    
    .popup-avatar {
        width: 35px;
        height: 35px;
    }
    
    .popup-menu-item {
        padding: 8px 14px;
        font-size: 12px;
    }
    
    .toggle-switch {
        width: 36px;
        height: 20px;
    }
    
    .toggle-switch::before {
        width: 16px;
        height: 16px;
    }
    
    .toggle-switch.off::before {
        transform: translateX(-16px);
    }
}

/* Mobile submenu positioning - đã được xử lý ở trên */

@media (max-width: 480px) {
    /* Đã được xử lý ở trên trong media query tổng quát */
}

@media (max-width: 360px) {
    .submenu {
        max-width: calc(50vw - 10px);
        min-width: 140px;
        width: 150px;
        left: 100% !important;
        right: auto !important;
        margin-left: 6px !important;
        margin-right: 0 !important;
    }
}

/* Đảm bảo menu không tràn trên mobile */
@media (max-width: 768px) {
    .menu-popup {
        /* Menu xuất hiện dưới button, giảm kích thước để có chỗ cho submenu */
        position: absolute;
        top: 100%;
        left: 0;
        right: auto;
        transform: translateY(-10px);
        max-width: calc(50vw - 20px);
        min-width: 200px;
        width: 220px;
    }
    
    .menu-popup.show {
        transform: translateY(0);
    }
    
    /* Submenu hiển thị bên phải trên mobile */
    .submenu {
        left: 100% !important;
        right: auto !important;
        margin-left: 10px !important;
        margin-right: 0 !important;
        max-width: calc(50vw - 20px);
        min-width: 160px;
        width: 180px;
    }
}

/* Desktop - submenu hiển thị bên phải */
@media (min-width: 769px) {
    .submenu {
        left: 100% !important;
        right: auto !important;
        margin-left: 15px !important;
        margin-right: 0 !important;
    }
}

@media (max-width: 480px) {
    .avatar-popup {
        position: fixed !important;
        top: 60px;
        right: 8px;
        left: auto;
        width: 50vw;
        max-width: 260px;
        min-width: 0;
        border-radius: 14px;
        padding-bottom: 4px;
        transform: none !important;
        z-index: 1200;
    }
    .popup-header {
        padding: 10px 6px 4px 6px;
        gap: 6px;
    }
    .popup-avatar {
        width: 52px;
        height: 52px;
    }
    .popup-menu-item {
        padding: 7px 7px;
        font-size: 13px;
    }
}
