/* 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;
}

.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;
}

.menu-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.menu-line {
    width: 30px;
    height: 4px;
    background-color: #333;
    border-radius: 2px;
}

.teacher-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    margin-left: 30px;
}

.avatar-container {
    position: relative;
}

.avatar {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: 3px solid #a4d65e;
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.status-indicator {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    background-color: #333;
    border-radius: 50%;
    border: 2px solid #f5f4f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-dots {
    display: flex;
    gap: 1px;
}

.status-dot {
    width: 2px;
    height: 2px;
    background-color: white;
    border-radius: 50%;
}

.teacher-details h2 {
    font-size: 28px;
    color: #333;
    margin-bottom: 5px;
    font-weight: 700;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    letter-spacing: -0.5px;
}

.teacher-code {
    font-size: 20px;
    color: #333;
    font-weight: 500;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.logo-container {
    margin-right: 10px;
}

.logo {
    height: 50px;
    width: auto;
}

/* Avatar Popup Menu */
.avatar-popup {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    width: 280px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    margin-top: 10px;
    max-height: 90vh;
    overflow-y: auto;
}

.avatar-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.popup-header {
    padding: 20px 20px 15px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.popup-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #a4d65e;
    object-fit: cover;
}

.popup-teacher-info h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 2px;
    font-weight: 600;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.popup-teacher-code {
    font-size: 14px;
    color: #666;
    font-weight: 400;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.popup-menu {
    padding: 8px 0;
}

.popup-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    font-size: 15px;
    font-weight: 400;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.popup-menu-item:hover {
    background-color: #f8f9fa;
}

.popup-menu-item.with-toggle {
    padding-right: 15px;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #a4d65e;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.toggle-switch::before {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.toggle-switch.off {
    background-color: #e0e0e0;
}

.toggle-switch.off::before {
    transform: translateX(-20px);
}

.language-text {
    color: #a4d65e;
    font-weight: 500;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* 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: 1001;
    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: 1001;
    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;
}

.menu-button {
    position: relative;
}

/* Overlay */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
}

.popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 12px 16px;
        min-height: 75px;
    }

    .teacher-info {
        margin-left: 20px;
        gap: 12px;
    }

    .avatar {
        width: 55px;
        height: 55px;
        border: 2.5px solid #a4d65e;
    }

    .status-indicator {
        width: 16px;
        height: 16px;
        bottom: 3px;
        right: 3px;
    }

    .teacher-details h2 {
        font-size: 17px;
        font-weight: 700;
        margin-bottom: 3px;
    }

    .teacher-code {
        font-size: 13px;
        font-weight: 500;
    }

    .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: 260px;
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(-10px);
        position: fixed;
        top: 80px;
        margin-top: 0;
    }
    
    .avatar-popup.show {
        transform: translateX(-50%) translateY(0);
    }
    
    .popup-header {
        padding: 16px 18px 12px;
    }
    
    .popup-avatar {
        width: 45px;
        height: 45px;
    }
    
    .popup-teacher-info h3 {
        font-size: 15px;
    }
    
    .popup-teacher-code {
        font-size: 13px;
    }
    
    .popup-menu-item {
        padding: 10px 18px;
        font-size: 14px;
    }
}

/* 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;
    }

    .teacher-info {
        margin-left: 15px;
        gap: 10px;
    }

    .avatar {
        width: 50px;
        height: 50px;
    }

    .teacher-details h2 {
        font-size: 15px;
        line-height: 1.2;
    }

    .teacher-code {
        font-size: 12px;
    }

    .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: 240px;
        margin-top: 0;
        position: fixed;
        top: 75px;
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(-10px);
    }
    
    .popup-header {
        padding: 14px 16px 10px;
        gap: 10px;
    }
    
    .popup-avatar {
        width: 40px;
        height: 40px;
    }
    
    .popup-teacher-info h3 {
        font-size: 14px;
    }
    
    .popup-teacher-code {
        font-size: 12px;
    }
    
    .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: 220px;
        top: 70px;
    }
    
    .popup-header {
        padding: 12px 14px 8px;
        gap: 8px;
    }
    
    .popup-avatar {
        width: 35px;
        height: 35px;
    }
    
    .popup-teacher-info h3 {
        font-size: 13px;
    }
    
    .popup-teacher-code {
        font-size: 11px;
    }
    
    .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;
    }
}
