/* Global resets và cài đặt chung */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    width: 100%; /* Đảm bảo body chiếm toàn bộ chiều rộng */
    background-color: #f0f2f5; /* Nền nhẹ nhàng hơn */
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 100vh; /* Đảm bảo body có chiều cao tối thiểu để chatbot nổi đúng vị trí */
}

/* HEADER */
.header-warp {
    z-index: 100; /* Đảm bảo header luôn ở trên cùng */
    width: 100%;
    height: 60px; /* Chiều cao cố định vẫn ổn cho header */
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0; /* Đặt header cố định ở trên cùng */
    background: radial-gradient(
        circle at center,
        transparent 50%,
        #fff 0 60%,
        transparent 0
    ) 0 0/60px 60px #ffd;
    border-radius: 10px;
    box-shadow: 0 2px 2px 0 rgba(36, 117, 104, 0.5);
    border-top: 5px solid grey;
    padding: 0 20px; /* Thêm padding ngang cho desktop */
}

/* Ẩn hamburger icon trên desktop */
.menu-toggle {
    display: none;
}

.main-nav {
    height: 100%;
}

.menu {
    display: inline-flex;
    height: 100%;
    align-items: center;
    padding: 0; /* Đã có padding ở .header-warp */
    list-style: none;
}

.menu-list {
    height: 100%;
    display: flex;
    position: relative;
    justify-content: center;
    align-items: center;
}

.menu-item {
    display: flex;
    position: relative;
    text-decoration: none;
    font-weight: bolder;
    text-transform: uppercase;
    padding: 0 15px;
    line-height: 60px;
    color: rgb(63, 63, 170);
    white-space: nowrap; /* Giữ các mục menu trên một dòng */
}

.menu-list:hover .menu-item {
    background-color: rgb(216, 208, 94);
    color: #fff;
    pointer-events: auto;
    font-weight: bolder;
    clip-path: polygon(0 10%, 95% 10%, 100% 50%, 95% 90%, 0 90%, 5% 50%);
}

.arrow-menu {
    display: inline-block;
    width: 80%;
    height: 10px;
    top: 70%;
    left: 10%;
    position: absolute;
    background-color: rgb(63, 63, 170);
    clip-path: polygon(0 0, 50% 50%, 100% 0, 50% 100%);
    transition: transform 0.5s ease;
}

.menu-list:hover .arrow-menu {
    background-color: aliceblue;
    transform: translateY(5px);
    pointer-events: auto;
}

.menu-dropdown {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 95%;
    width: 100%;
    border-radius: 10px;
    list-style: none;
    align-items: center;
    box-shadow: 1px 1px 5px rgb(63, 63, 170);
    background-color: #ffd; /* Thêm màu nền cho dropdown */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.5s ease, visibility 0.5s ease, transform 0.5s ease;
}

.dropdown-warp {
    width: 100%;
    height: 30px;
    margin: 2px 0;
    background-color: transparent;
}

.dropdown-item {
    text-decoration: none;
    outline: 1px solid;
    border-radius: 8px;
    height: 30px;
    padding-top: 4px;
    display: block;
    text-align: center;
    color: rgb(63, 63, 170);
    background-color: #ffd;
    font-weight: bolder;
    transition: transform 0.5s ease;
}

.dropdown-warp:hover .dropdown-item {
    background-color: azure;
    border-radius: 8px;
    transform: translateX(5px);
    pointer-events: auto;
}

.menu-list:hover .menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.sub-nav {
    padding-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login {
    display: flex;
    color: rgb(5, 5, 146);
    height: 100%;
    text-decoration: none;
    font-weight: bolder;
    text-transform: uppercase;
}

.login-item {
    display: inline-flex;
    padding-left: 1px;
    width: 15px;
    height: 20px;
    margin-right: 15px;
    transition: transform 0.3s ease;
}

.login:hover {
    color: black;
    pointer-events: auto;
}

.login:hover .login-item {
    transform: translateX(-3px);
    pointer-events: auto;
}

.search-item {
    width: 60px;
    height: 100%;
    padding: 20px 20px;
    cursor: pointer;
    transition: rotate 0.5s ease;
}

.search-item:hover {
    rotate: 90deg;
}
/* HEADER END */

/* BANNER */
.banner-main {
    position: relative;
    display: flex;
    max-height: 90vh;
    width: calc(100% - 20px); /* Lấy 100% trừ đi margin */
    margin: 70px 10px 0 10px; /* margin trên bằng chiều cao header + 10px */
    z-index: 0;
    background-color: aliceblue;
    border-radius: 20px; /* Thêm border-radius cho banner-main */
    overflow: hidden; /* Đảm bảo mọi thứ bên trong banner không tràn ra ngoài */
}

.card-banner {
    position: relative;
    width: 100%;
    display: flex;
    border-radius: 20px;
    overflow: hidden;
    border: 10px solid #ffd;
}

.card-img {
    border-radius: 20px;
    width: 70%; /* Chiếm 70% trên desktop */
    aspect-ratio: 3/2;
    object-fit: cover;
    cursor: pointer;
    box-shadow: 0 0 0 10px #ffd;
    transform: translateX(45%);
    transition: transform 0.8s ease;
}

.card-img:hover {
    transform: translateX(0);
    pointer-events: auto;
}

.note-img {
    height: 100%;
    width: 30%; /* Chiếm 30% trên desktop */
    font-size: 1.2em;
    padding: 10px 20px;
    text-align: justify;
    text-indent: 30px;
    border-radius: 20px;
    box-shadow: 0 0 0 10px #ffd;
    overflow-y: auto; /* Thêm cuộn nếu nội dung quá dài */
}

.note-img h1 {
    font-weight: bolder;
}

.choice-img {
    position: absolute;
    border-radius: 20px;
    width: 150px;
    text-align: center;
    padding: 30px 0;
    font-weight: bolder;
    color: #fff;
    box-shadow: 3px 3px 5px 0 rgb(221, 221, 38);
    height: 80px;
    background-color: rgb(20, 129, 202);
    left: 30px;
    top: 45%;
    user-select: none;
    cursor: pointer;
}

.choice-img:hover {
    background-color: rgb(21, 48, 66);
    pointer-events: auto;
}

/* BANNER END */

/* MAIN */
.main-body {
    display: flex;
    z-index: 0;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: calc(100% - 20px); /* Giữ margin hai bên */
    min-height: 96vh;
    margin: 20px 10px; /* Margin trên/dưới 20px, trái/phải 10px */
    background-color: bisque;
    border-radius: 20px;
    border: 10px solid #ffd;
    padding: 20px 0; /* Thêm padding bên trong main-body */
}

.teacher-info,
.math-info {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%; /* Chiếm 100% của main-body */
    
    border-radius: 10px;
    margin-bottom: 20px; /* Khoảng cách giữa các section */
}
.teacher-info {
     padding: 20px; /* Thêm padding cho teacher-info */
     max-height: 96vh; 
}


.math-info {
    position: relative;
    display: flex;
    min-height: 96vh;
    gap: 20px; /* Giảm gap để có thể điều chỉnh trên mobile */
    background-color: rgb(155, 207, 207);
    padding: 20px; /* Thêm padding */
}
.warp-math {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    width: 25%; /* Khoảng 4 mục trên 1 hàng, trừ gap */
    aspect-ratio: 2/3;
    background-color: rgb(155, 207, 207);
    margin: 0; /* Xóa margin cố định */
}
.math-img {
    width: 100%; /* Chiếm 100% của warp-math */
    z-index: 1;
    aspect-ratio: 2/3;
    border-radius: 20px;
    border: 10px solid #ff0;
    transform: skewX(0);
    transition: transform 0.3s ease;
}

.warp-math:hover .math-img {
    transform: skewX(-10deg);
}

.warp-math:hover .note-math {
    transform: translateY(85px);
}

.teacher-img {
    width: 60vw; /* Giảm kích thước ảnh giáo viên để phù hợp hơn */
    aspect-ratio: 3/2;
    object-fit: cover;
    border-radius: 20px;
    border: 10px solid white;
    z-index: 0;
    max-width: 100%; /* Đảm bảo không tràn */
    height: auto;
}

.note-info {
    width: 60vw; /* Giảm kích thước */
    height: auto; /* Thay thế height cố định bằng auto */
    min-height: 30px; /* min-height để đảm bảo không quá nhỏ */
    margin: 10px 0;
    padding: 5px 10px; /* Thêm padding */
    text-align: center;
    font-weight: bolder;
    color: rgb(55, 22, 99);
    border-radius: 10px;
    box-shadow: 0 0 2px 1px #000;
    background: conic-gradient(
        at center,
        green 90deg,
        yellow 120deg,
        white 240deg
    );
}

.btn-left,
.btn-right {
    position: absolute;
    width: 40px;
    height: 40px;
    background: #e21414;
    opacity: 0.4;
    top: 50%; /* Căn giữa theo chiều dọc */
    transform: translateY(-50%); /* Dịch chuyển ngược lại 50% chiều cao của nút */
    cursor: pointer;
    transition: transform 0.5s ease, opacity 0.5s ease;
    z-index: 1; /* Đảm bảo nút nằm trên ảnh */
}

.btn-right {
    right: 5%; /* Cách 5% từ mép phải của teacher-info */
    clip-path: polygon(0 0, 100% 50%, 0 100%, 50% 50%);
}

.btn-left {
    left: 5%; /* Cách 5% từ mép trái của teacher-info */
    clip-path: polygon(0 50%, 100% 0, 50% 50%, 100% 100%);
}

.btn-left:hover {
    opacity: 1;
    transform: translateX(-2px) translateY(-50%); /* Giữ căn giữa dọc */
}

.btn-right:hover {
    opacity: 1;
    transform: translateX(2px) translateY(-50%); /* Giữ căn giữa dọc */
}

.btn-left:active {
    transform: translateX(-10px) translateY(-50%); /* Giữ căn giữa dọc */
}

.btn-right:active {
    transform: translateX(10px) translateY(-50%); /* Giữ căn giữa dọc */
}

.note-math {
    margin-top: -80px;
    padding: 22px 0;
    background: #ffd;
    text-align: center;
    font-family: Arial, Helvetica, sans-serif;
    width: 100%; /* Chiếm 100% của warp-math */
    height: 8vh; /* Vẫn giữ vh cho chiều cao */
    font-weight: bolder;
    border-radius: 20px;
    cursor: pointer;
    border: 2px solid #ff0;
    transition: transform 0.3s ease;
}
/* MAIN END */

/* FOOTER */
.warp-footer {
    width: 100%;
    height: 100px; /* Chiều cao cố định */
    background-color: #333;
    margin-top: 20px;
    border-radius: 10px;
}


/* --- CHATBOT CSS (Đã có sẵn responsive) --- */
/* Container chính của chatbot */
#chatbot-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 500px; /* Giới hạn chiều rộng tối đa */
    height: 80vh; /* Chiều cao tương đối để phù hợp trên nhiều màn hình */
    max-height: 700px; /* Giới hạn chiều cao tối đa */
    background-color: #ffffff;
    border-radius: 1.5rem; /* Góc bo tròn lớn hơn */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); /* Bóng đổ mềm mại */
    overflow: hidden; /* Đảm bảo nội dung không tràn ra ngoài */

    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out,
        transform 0.3s ease-in-out;

    position: fixed; /* Cố định vị trí trên màn hình */
    bottom: 90px; /* Cách nút mở chatbot một khoảng */
    right: 20px;
    z-index: 1000; /* Đảm bảo chatbot nằm trên các nội dung khác */
}

/* Khi chatbot hiển thị */
#chatbot-container.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Header của chatbot */
#chatbot-header {
    padding: 1.5rem; /* p-6 */
    background-image: linear-gradient(
        to right,
        #2563eb,
        #4f46e5
    ); /* from-blue-600 to-indigo-600 */
    color: white;
    text-align: center;
    border-top-left-radius: 1.5rem; /* rounded-t-3xl */
    border-top-right-radius: 1.5rem; /* rounded-t-3xl */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06); /* shadow-lg */
    position: relative; /* Cho phép nút đóng định vị tuyệt đối */
}

#chatbot-header h1 {
    font-size: 2.25rem; /* text-3xl */
    font-weight: 700; /* font-bold */
}

#chatbot-header p {
    font-size: 0.875rem; /* text-sm */
    opacity: 0.9; /* opacity-90 */
    margin-top: 0.25rem; /* mt-1 */
}

/* Nút đóng chatbot */
#close-chatbot-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s ease-in-out;
}

#close-chatbot-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Khu vực tin nhắn có thể cuộn */
#messages {
    flex-grow: 1; /* flex-grow */
    overflow-y: auto; /* overflow-y-auto */
    padding: 1.5rem; /* p-6 */
    display: flex;
    flex-direction: column;
    gap: 1rem; /* gap-4 */
    background-color: #f9fafb; /* bg-gray-50 */
}

/* Kiểu tin nhắn của người dùng */
.user-message {
    background-color: #3b82f6; /* bg-blue-500 */
    color: white;
    align-self: flex-end; /* self-end */
    padding: 0.75rem 1rem; /* px-4 py-3 */
    border-radius: 1.25rem 0.5rem 1.25rem 1.25rem; /* rounded-xl rounded-bl-sm rounded-br-xl rounded-tr-sm */
    max-width: 80%; /* max-w-4/5 */
    word-wrap: break-word; /* break-words */
}

/* Kiểu tin nhắn của bot */
.bot-message {
    background-color: #e5e7eb; /* bg-gray-200 */
    color: #1e6ef0; /* text-gray-700 */
    font-style: italic;
    font-weight: bold;
    outline:1px solid #1e6ef0;
    align-self: flex-start; /* self-start */
    padding: 0.75rem 1rem; /* px-4 py-3 */
    border-radius: 0.5rem 1.25rem 1.25rem 1.25rem; /* rounded-xl rounded-bl-xl rounded-br-sm rounded-tr-xl */
    max-width: 80%; /* max-w-4/5 */
    word-wrap: break-word; /* break-words */
}

/* Styling cho nội dung Markdown trong tin nhắn bot */
.bot-message strong {
    font-weight: bold;
}

.bot-message em {
    font-style: italic;
}

.bot-message ul {
    list-style-type: disc;
    margin-left: 1.25rem;
    padding-left: 0.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.bot-message ol {
    list-style-type: decimal;
    margin-left: 1.25rem;
    padding-left: 0.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.bot-message li {
    margin-bottom: 0.25rem;
}

.bot-message a {
    color: #3b82f6;
    text-decoration: underline;
}

/* Vùng nhập liệu */
#input-area {
    display: flex;
    padding: 1rem 1.5rem; /* p-4 px-6 */
    gap: 0.75rem; /* gap-3 */
    border-top: 1px solid #e5e7eb; /* border-t border-gray-200 */
    background-color: #ffffff; /* bg-white */
}

#user-input {
    flex-grow: 1; /* flex-grow */
    padding: 0.75rem 1rem; /* px-4 py-3 */
    border-radius: 0.75rem; /* rounded-xl */
    border: 1px solid #d1d5db; /* border border-gray-300 */
    outline: none; /* outline-none */
    font-size: 1rem;
    transition: border-color 0.2s ease-in-out;
}

#user-input:focus {
    border-color: #3b82f6; /* focus:ring-2 focus:ring-blue-500 */
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25); /* Thêm bóng đổ cho focus */
}

#send-button {
    background-color: #2563eb; /* bg-blue-700 */
    color: white; /* text-white */
    padding: 0.75rem 1.5rem; /* px-6 py-3 */
    border-radius: 0.75rem; /* rounded-xl */
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600; /* font-semibold */
    transition: background-color 0.2s ease-in-out, transform 0.1s ease-in-out;
}

#send-button:hover {
    background-color: #1d4ed8; /* hover:bg-blue-800 */
    transform: translateY(-1px); /* hover:translate-y-px */
}

#send-button:active {
    transform: translateY(0); /* active:translate-y-0 */
}

/* Hiển thị chỉ báo tải */
#loading-indicator {
    display: none; /* Mặc định ẩn */
    text-align: center;
    padding: 0.5rem;
    color: #6b7280; /* text-gray-500 */
    font-size: 0.9rem; /* text-sm */
}

/* Animation cho loading spinner */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid #3b82f6; /* border-blue-500 */
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

#loading-indicator p {
    margin-top: 0.5rem; /* mt-2 */
}

/* Nút mở chatbot nổi */
#open-chatbot-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s ease-in-out, transform 0.1s ease-in-out;
    z-index: 1001; /* Đảm bảo nút này nằm trên chatbot khi nó ẩn */
}

#open-chatbot-btn:hover {
    background-color: #1d4ed8;
    transform: scale(1.05);
}

#open-chatbot-btn:active {
    transform: scale(1);
}

/* --- MEDIA QUERIES --- */

/* Thiết bị có chiều rộng từ 768px trở xuống (Tablets và Mobile) */
@media (max-width: 768px) {
    .header-warp {
        height: 50px; /* Chiều cao cố định nhỏ hơn */
        flex-direction: row; /* Giữ các mục trên một hàng */
        justify-content: space-between; /* Đẩy các mục ra hai bên */
        padding: 0 15px; /* Thêm padding ngang */
        border-radius: 0; /* Bỏ bo tròn trên mobile */
    }

    /* Hiển thị hamburger icon */
    .menu-toggle {
        display: flex; /* Hiển thị hamburger */
        width: 30px;
        height: 30px;
        flex-direction: column;
        justify-content: space-around;
        cursor: pointer;
        z-index: 101; /* Cao hơn nav menu */
        margin-right: 15px; /* Khoảng cách với sub-nav */
    }

    .menu-toggle .bar {
        width: 100%;
        height: 3px;
        background-color: rgb(63, 63, 170);
        border-radius: 5px;
        transition: all 0.3s ease-in-out;
    }

    /* Animation cho hamburger khi menu mở */
    .menu-toggle.open .bar:nth-child(1) {
        transform: translateY(10px) rotate(45deg);
    }
    .menu-toggle.open .bar:nth-child(2) {
        opacity: 0;
    }
    .menu-toggle.open .bar:nth-child(3) {
        transform: translateY(-10px) rotate(-45deg);
    }


    .main-nav {
        position: fixed; /* Đặt menu cố định, trượt ra */
        top: 50px; /* Bắt đầu từ dưới header */
        left: -100%; /* Mặc định ẩn ở ngoài màn hình */
        width: 80%; /* Chiếm 80% chiều rộng màn hình */
        height: calc(70vh - 50px); /* Chiều cao đầy đủ trừ header */
        background-color: #ffd; /* Màu nền cho menu trượt */
        box-shadow: 2px 0 5px rgba(0,0,0,0.2);
        transition: left 0.3s ease-in-out;
        z-index: 99; /* Nằm dưới header, trên nội dung */
        flex-direction: column; /* Xếp các mục menu theo cột */
        padding-top: 20px; /* Khoảng cách từ trên */
        overflow-y: auto; /* Cho phép cuộn nếu menu dài */
    }

    .main-nav.active {
        left: 0; /* Trượt vào màn hình */
    }

    .menu {
        flex-direction: column; /* Xếp các mục menu chồng lên nhau */
        align-items: flex-start; /* Căn chỉnh văn bản sang trái */
        padding: 0;
        width: 100%;
    }

    .menu-list {
        width: 100%;
        border-bottom: 1px solid #eee; /* Đường phân cách giữa các mục menu */
    }
    .menu-list:last-child {
        border-bottom: none; /* Mục cuối cùng không có đường kẻ */
    }

    .menu-item {
        line-height: 50px; /* Tăng chiều cao mục menu để dễ chạm */
        width: 100%;
        padding: 0 20px; /* Tăng padding để dễ chạm */
        background-color: transparent;
        color: rgb(63, 63, 170);
        clip-path: none;
    }
    .menu-list:hover .menu-item { /* Đảm bảo hover không ghi đè */
        background-color: transparent;
        color: rgb(63, 63, 170);
        clip-path: none;
    }
    .menu-item:active { /* Hiệu ứng chạm */
        background-color: rgba(216, 208, 94, 0.2);
    }


    .arrow-menu {
        display: none; /* Ẩn mũi tên dropdown */
    }

    .menu-dropdown {
        position: static; /* Cho phép nội dung chảy tự nhiên */
        width: 90%;
        box-shadow: none;
        background-color: transparent;
        padding-left: 20px; /* Thụt lề các mục con */
        display: none; /* Mặc định ẩn, sẽ hiển thị khi được click */
        flex-direction: column; /* Xếp các mục con theo cột */
        align-items: flex-start;
    }
    .menu-dropdown.open { /* Class để hiển thị dropdown khi được click */
        display: flex;
    }

    .dropdown-warp {
        height: auto; /* Chiều cao tự động */
        margin: 0 10px 0 0;
    }
    .dropdown-item {
        line-height: 40px; /* Điều chỉnh chiều cao cho mục con */
        text-align: left;
        padding:0 20px 20px 10px; /* Thụt lề thêm */
        border: none;
        background-color: transparent;
    }
    .dropdown-warp:hover .dropdown-item { /* Hiệu ứng hover cho mục con */
        transform: translateX(0); /* Bỏ hiệu ứng translateX */
        background-color: #e0e0e0; /* Nền xám nhạt khi hover */
    }
    .dropdown-item:active { /* Hiệu ứng chạm */
        background-color: #d0d0d0;
    }

    .sub-nav {
        padding-right: 0;
        justify-content: flex-end; /* Căn chỉnh sang phải */
        margin-top: 0;
    }
    .login {
        font-size: 0.8em;
        margin-right: 5px;
    }
    .login-item {
        width: 12px;
        height: 16px;
        margin-right: 5px;
    }
    .search-item {
        width: 40px;
        height: 40px;
        padding: 8px;
    }

    .banner-main {
        margin: 80px 5px 0 5px; /* Điều chỉnh margin cho mobile (từ header 50px + 30px) */
        width: calc(100% - 10px);
        min-height: auto; /* Tự động chiều cao */
        height: auto; /* Tự động chiều cao */
    }

    .card-banner {
        flex-direction: column; /* Xếp ảnh và chú thích chồng lên nhau */
        border: 5px solid #ffd; /* Giảm border */
    }

    .card-img {
        width: 100%; /* Ảnh chiếm toàn bộ chiều rộng */
        height: 40vh; /* Giới hạn chiều cao ảnh */
        transform: translateX(0); /* Bỏ transform */
        box-shadow: none; /* Bỏ shadow riêng của ảnh */
    }

    .card-img:hover {
        transform: translateX(0); /* Đảm bảo không có hiệu ứng hover */
    }

    .note-img {
        width: 100%; /* Chú thích chiếm toàn bộ chiều rộng */
        height: auto; /* Chiều cao tự động */
        box-shadow: none; /* Bỏ shadow riêng của chú thích */
        padding: 15px; /* Điều chỉnh padding */
        font-size: 1em; /* Giảm cỡ chữ */
        border-top: 5px solid #ffd; /* Thêm border top để ngăn cách ảnh */
    }

    .note-img br {
        display: none; /* Ẩn thẻ ngắt dòng trong chú thích trên mobile */
    }
    .note-img hr {
        margin: 10px auto; /* Điều chỉnh margin của hr */
    }

    .choice-img {
        width: 120px; /* Giảm kích thước nút đổi hình */
        height: 60px;
        padding: 10px 0;
        left: 50%; /* Căn giữa nút đổi hình */
        transform: translateX(-50%);
        top: 50%; /* Di chuyển lên giữa ảnh và chú thích */
        z-index: 10; /* Đảm bảo nút nằm trên ảnh */
    }

    .main-body {
        width: calc(100% - 10px);
        margin: 20px 5px;
        padding: 10px 0;
    }

    .teacher-info,
    .math-info {
        width: 95%; /* Chiếm toàn bộ chiều rộng có sẵn */
        min-height: auto; /* Tự động chiều cao */
        padding: 10px;
    }
    .teacher-info {
        flex-direction: column; /* Xếp ảnh và text info chồng lên nhau */
    }

    .teacher-img {
        width: 95%; /* Ảnh chiếm gần hết chiều rộng */
        height: auto;
        aspect-ratio: 4/3; /* Tỷ lệ khung hình mới cho ảnh giáo viên */
        margin-bottom: 10px;
    }

    .note-info {
        width: 95%; /* Note info chiếm gần hết chiều rộng */
        font-size: 0.9em;
        padding: 5px;
    }

    .btn-left,
    .btn-right {
        top: 50%; /* Giữ căn giữa dọc */
        width: 30px; /* Giảm kích thước nút */
        height: 30px;
    }
    .btn-left { left: 2%; } /* Cách mép 2% */
    .btn-right { right: 2%; } /* Cách mép 2% */

    .math-info {
        justify-content: flex-start;
        flex-direction: column; /* Xếp các mục toán học chồng lên nhau */
        gap: 60px; /* Giảm khoảng cách giữa các mục */
    }

    .warp-math {
        width: 90%; /* Mỗi mục chiếm 90% chiều rộng */
        aspect-ratio: 2/3;
        box-sizing: border-box;
    }

    .math-img {
        width: 100%;
        height: auto;
    }

    .note-math {
        width: 100%;
        margin-top: -60px; /* Điều chỉnh margin top */
        padding: 15px 0;
        height: auto;
        font-size: 0.9em;
    }
    .warp-math:hover .note-math {
        transform: translateY(65px); /* Điều chỉnh hiệu ứng hover */
    }
}

/* Responsive adjustments cho chatbot */
@media (max-width: 640px) {
    #chatbot-container {
        height: 95vh;
        border-radius: 0;
        box-shadow: none;
        max-width: 100%;
        bottom: 0;
        right: 0;
        left: 0;
    }
    body {
        padding: 0;
    }
    #messages {
        padding: 1rem;
        gap: 0.75rem;
    }
    #input-area {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    #user-input,
    #send-button {
        font-size: 0.9rem;
        padding: 0.6rem 1rem;
    }
    #chatbot-header {
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
    #open-chatbot-btn {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
        bottom: 15px;
        right: 15px;
    }
}
