/* ================= 1. THIẾT LẬP NỀN CHUNG ================= */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url('background.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed; 
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); } 
    to { opacity: 1; transform: translateY(0); }
}

/* ================= 2. TRANG CHỦ ================= */
#trang-chu { text-align: center; padding: 50px 20px; animation: fadeIn 0.8s ease; }

.main-header {
    text-align: center; margin: 0 auto 40px auto; padding: 40px 20px; max-width: 900px;
    background: rgba(255, 255, 255, 0.15); border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3); backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.main-title {
    font-size: 46px; font-weight: 900; margin: 0 0 15px 0; text-transform: uppercase;
    background: linear-gradient(45deg, #0d6efd, #ff007f, #8a2be2);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.sub-title {
    font-size: 16px; font-weight: bold; color: #ffffff;
    background: linear-gradient(90deg, #00c6ff 0%, #0072ff 100%);
    display: inline-block; padding: 10px 30px; border-radius: 50px; margin-bottom: 30px;
}

.btn-start {
    display: block; margin: 20px auto 0; padding: 15px 40px;
    background: linear-gradient(45deg, #ff007f, #8a2be2); color: white;
    border: none; border-radius: 50px; font-size: 18px; font-weight: bold;
    cursor: pointer; box-shadow: 0 10px 20px rgba(138, 43, 226, 0.3); transition: 0.3s;
}
.btn-start:hover { transform: scale(1.1); box-shadow: 0 15px 25px rgba(138, 43, 226, 0.5); }

/* ================= LƯỚI TÍNH NĂNG (ÉP KÍCH THƯỚC CHUẨN) ================= */
.features-grid {
    display: grid;
    /* Tạo 3 cột cố định, mỗi cột rộng đúng 280px */
    grid-template-columns: repeat(3, 280px); 
    justify-content: center;
    gap: 30px;
    margin-top: 40px;
}

.feature-card {
    background: rgba(255, 255, 255, 0.95); 
    padding: 25px; 
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2); 
    cursor: pointer;
    transition: 0.3s; 
    text-align: center; 
    border: 2px solid transparent;
    
    /* 2 Lệnh ép thẻ lấp đầy ô lưới, không bị teo nhỏ */
    width: 100%; 
    box-sizing: border-box; 
}

.feature-card:hover { 
    transform: translateY(-10px); 
    border-color: #0d6efd; 
}

.feature-card.grayed { 
    opacity: 0.6; 
    cursor: not-allowed; 
    filter: grayscale(1); 
}

.feature-card .icon { 
    font-size: 50px; 
    margin-bottom: 15px; 
}

/* Đảm bảo giao diện vẫn mượt trên màn hình nhỏ (iPad) */
@media screen and (max-width: 950px) {
    .features-grid {
        grid-template-columns: repeat(2, 280px); /* Thu về 2 cột */
    }
}
/* ================= 3. BẢNG TUẦN HOÀN & THANH ĐIỀU HƯỚNG ================= */
#trang-tinh-nang { padding: 20px; animation: fadeIn 0.5s ease; }

.nav-container {
    display: flex; gap: 15px; margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.9); padding: 15px;
    border-radius: 15px; box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    max-width: 1400px; margin-left: auto; margin-right: auto;
}

.btn-nav {
    padding: 10px 20px; border: none; border-radius: 10px; color: white;
    font-weight: bold; cursor: pointer; transition: 0.3s;
    display: flex; align-items: center; gap: 8px; font-size: 14px;
}
.btn-home { background: #2c3e50; } 
.btn-quiz { background: #8e44ad; } 
.btn-balance { background: #2980b9; } 
.btn-nav:hover { transform: translateY(-3px); filter: brightness(1.1); box-shadow: 0 4px 10px rgba(0,0,0,0.2); }

.container { display: flex; gap: 25px; max-width: 1400px; margin: 0 auto; }
.grid-table { flex: 3; display: grid; grid-template-columns: repeat(18, 1fr); gap: 6px; }

.element-box {
    border-radius: 6px; padding: 10px 5px; text-align: center;
    cursor: pointer; box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    transition: 0.3s; border: 1px solid rgba(255,255,255,0.4);
}
.element-box:hover { transform: scale(1.15); z-index: 10; background-color: #fff !important; border-color: #0d6efd; }

.info-panel {
    flex: 1; background-color: rgba(255, 255, 255, 0.98); padding: 25px;
    border-radius: 15px; box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    height: fit-content; position: sticky; top: 20px;
}

/* Màu nhóm hóa học */
.bg-phi-kim { background-color: #fce883; } .bg-khi-hiem { background-color: #c0ffff; }
.bg-kim-loai-kiem { background-color: #ffb5b5; } .bg-kim-loai-kiem-tho { background-color: #ffdead; }
.bg-a-kim { background-color: #cccc99; } .bg-halogen { background-color: #ffffcc; }
.bg-kim-loai { background-color: #c2d6d6; } .bg-kim-loai-chuyen-tiep { background-color: #ffc0cb; }
.bg-lantan { background-color: #ffbfff; } .bg-actini { background-color: #ff99cc; }
.bg-mac-dinh { background-color: #e0e0e0; }

/* ================= 4. TRANG CÂN BẰNG ================= */
#trang-can-bang-doc-lap {
    display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px;
}

.can-bang-card {
    background: #ffffff; max-width: 800px; width: 100%; padding: 40px;
    border-radius: 30px; box-shadow: 0 25px 70px rgba(0, 0, 0, 0.5);
    text-align: center; border: 1px solid #ddd; animation: fadeIn 0.6s ease;
}

.main-title-dark { color: #1a1a1a; font-size: 34px; margin-bottom: 10px; font-weight: 800; }
.sub-text { color: #555; margin-bottom: 30px; }

.input-group { display: flex; gap: 12px; margin-bottom: 25px; }
#input-pt {
    flex: 1; padding: 18px 25px; border-radius: 50px;
    border: 2px solid #ddd; font-size: 18px; outline: none;
}

.btn-action {
    background: linear-gradient(45deg, #0d6efd, #00c6ff); color: white;
    border: none; padding: 0 35px; border-radius: 50px; font-weight: bold; cursor: pointer;
}

.result-box {
    background: #f8f9fa; border: 2px dashed #0d6efd; padding: 30px;
    border-radius: 15px; min-height: 80px; display: flex;
    align-items: center; justify-content: center; font-size: 26px; font-weight: bold; color: #212529;
}

.huong-dan-box {
    margin-top: 30px; text-align: left; background: #e7f1ff; padding: 20px; border-radius: 15px; color: #084298;
}

.btn-back-small {
    background: #6c757d; color: white; border: none; padding: 8px 20px;
    border-radius: 10px; cursor: pointer; font-size: 14px; margin-bottom: 15px;
}

/* ================= 5. TRỢ LÝ ẢO ================= */
.chatbot-toggler {
    position: fixed; bottom: 30px; right: 30px; background: #0d6efd; color: white;
    padding: 15px 25px; border-radius: 50px; cursor: pointer; font-weight: bold; z-index: 1000;
}

.chatbot-window {
    position: fixed; bottom: 90px; right: 30px; width: 320px; background: #fff;
    border-radius: 15px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); z-index: 1000;
    overflow: hidden; display: flex; flex-direction: column; border: 1px solid #e0e0e0;
}
/* ================= 6. GIAO DIỆN ĐỐ VUI HÓA HỌC ================= */
#trang-do-vui-doc-lap {
    display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px;
}

.quiz-card {
    background: #ffffff; max-width: 700px; width: 100%; padding: 40px;
    border-radius: 25px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    text-align: center; border: 1px solid #ddd; animation: fadeIn 0.5s ease;
}

.quiz-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 2px dashed #ddd; padding-bottom: 15px; margin-bottom: 30px;
}

.question-container {
    background: #f8f9fa; padding: 30px 20px; border-radius: 15px;
    border-left: 5px solid #0d6efd; margin-bottom: 30px;
}

#cau-hoi { color: #1a1a1a; margin: 0; font-size: 24px; font-weight: normal; }
#cau-hoi b { color: #d35400; font-size: 28px; } /* Nhấn mạnh từ khóa */

.options-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 15px;
}

.btn-option {
    background: #ffffff; border: 2px solid #0d6efd; color: #0d6efd;
    padding: 15px; border-radius: 15px; font-size: 20px; font-weight: bold;
    cursor: pointer; transition: 0.2s;
}

.btn-option:hover:not(:disabled) {
    background: #0d6efd; color: white; transform: translateY(-3px); box-shadow: 0 5px 15px rgba(13, 110, 253, 0.3);
}

.btn-option:disabled { cursor: not-allowed; opacity: 0.8; }

/* Hiệu ứng khi trả lời */
.btn-option.correct { background: #27ae60 !important; color: white !important; border-color: #27ae60 !important; }
.btn-option.wrong { background: #e74c3c !important; color: white !important; border-color: #e74c3c !important; }

.feedback-box {
    margin-top: 25px; padding: 15px; border-radius: 10px; font-size: 16px; text-align: left;
}
.fb-correct { background: #e8f8f5; border-left: 5px solid #27ae60; color: #1e8449; }
.fb-wrong { background: #fdedec; border-left: 5px solid #e74c3c; color: #c0392b; }

/* Responsive cho điện thoại */
@media (max-width: 600px) {
    .options-grid { grid-template-columns: 1fr; }
    .quiz-header { flex-direction: column; gap: 10px; }
}
/* ================= CSS CHO GIẤY CHỨNG NHẬN VÀ KẾT QUẢ ================= */
.certificate {
    background: #fffcf0;
    border: 8px double #f1c40f;
    padding: 40px 20px;
    border-radius: 15px;
    margin: 20px 0;
    box-shadow: 0 10px 30px rgba(241, 196, 15, 0.2);
    animation: fadeIn 0.8s ease;
}

.certificate h2 { color: #f39c12; font-size: 32px; margin-top: 0; text-transform: uppercase;}
.certificate p { font-size: 18px; color: #444; margin-bottom: 20px;}

.cert-score {
    display: inline-block;
    background: #e74c3c;
    color: white;
    font-size: 24px;
    font-weight: bold;
    padding: 10px 30px;
    border-radius: 50px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

.cert-footer {
    border-top: 2px dashed #ccc;
    padding-top: 20px;
    margin-top: 20px;
    font-family: 'Courier New', Courier, monospace;
    color: #7f8c8d;
    font-weight: bold;
}

.failed-screen {
    background: #fdf2e9;
    border: 3px dashed #e67e22;
    padding: 40px 20px;
    border-radius: 15px;
    margin: 20px 0;
}
/* --- NÚT ĐỌC ÂM THANH IUPAC --- */
.btn-audio {
    background: #eef2f3;
    border: 1px solid #bdc3c7;
    color: #2c3e50;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-audio:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.btn-audio:active {
    transform: scale(0.95); /* Hiệu ứng lún xuống khi click */
}
/* ================= CSS CHO PHÒNG THÍ NGHIỆM ĐA NĂNG ================= */
/* Phá vỡ giới hạn 800px, ép khung mở rộng lên tới 1300px */
.lab-card {
    max-width: 1300px !important; 
    width: 95%;
    padding: 30px;
}

/* Thanh menu chọn thí nghiệm */
.lab-menu {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-lab {
    background: #f1f3f5;
    border: 2px solid #dee2e6;
    color: #495057;
    padding: 12px 25px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.btn-lab:hover { background: #e2e6ea; transform: translateY(-2px); }

.btn-lab.active {
    background: #0d6efd;
    color: white;
    border-color: #0d6efd;
    box-shadow: 0 5px 15px rgba(13, 110, 253, 0.3);
}

/* Khung hiển thị siêu lớn */
.iframe-container-large {
    width: 100%;
    height: 75vh; /* Cao bằng 75% chiều cao của màn hình thiết bị */
    min-height: 550px; /* Không bao giờ được thấp hơn 550px */
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border: 4px solid #3498db;
    background: #fff; /* Nền trắng lúc chờ tải */
}

.iframe-container-large iframe {
    width: 100%;
    height: 100%;
    border: none;
}
/* ================= 7. GIAO DIỆN ĐIỆN THOẠI (RESPONSIVE) ================= */
/* Kích hoạt khi màn hình nhỏ hơn 768px (Điện thoại và Tablet nhỏ) */
@media screen and (max-width: 768px) {
    
    /* 1. TRANG CHỦ: Thu nhỏ chữ và xếp thẻ thành 1 cột dọc */
    .main-header { padding: 25px 15px; margin-bottom: 20px; }
    .main-title { font-size: 32px; }
    .features-grid { 
        display: flex; 
        flex-direction: column; 
        align-items: center; 
        margin-top: 20px;
    }
    .feature-card { width: 90%; max-width: 350px; padding: 20px; }

    /* 2. BẢNG TUẦN HOÀN: Cuộn ngang bảng và đẩy khung chi tiết xuống dưới */
    .container { 
        flex-direction: column; 
        padding: 10px;
    }
    .grid-table { 
        display: flex; 
        flex-wrap: nowrap; 
        overflow-x: auto; /* Cho phép dùng tay vuốt ngang */
        padding-bottom: 15px;
        -webkit-overflow-scrolling: touch; /* Vuốt mượt trên iOS */
    }
    .element-box { 
        min-width: 50px; /* Giữ kích thước ô vuông không bị bóp méo */
        margin-right: 5px;
    }
    .info-panel { 
        position: relative; /* Hủy chế độ trôi (sticky) */
        top: 0; 
        width: 100%; 
        box-sizing: border-box;
        margin-top: 15px;
    }

    /* 3. THANH ĐIỀU HƯỚNG: Chuyển các nút thành hàng dọc cho ngón tay dễ bấm */
    .nav-container { 
        flex-direction: column; 
        gap: 10px; 
        padding: 15px;
    }
    .btn-nav { justify-content: center; width: 100%; padding: 12px; }

    /* 4. CÁC TRANG CÔNG CỤ (Cân bằng, PTK, Đố vui) */
    .can-bang-card, .quiz-card { 
        width: 95%; 
        padding: 25px 15px; 
        margin: 10px auto; 
    }
    .main-title-dark { font-size: 24px; }
    .input-group { flex-direction: column; }
    .btn-action { width: 100%; padding: 15px; margin-top: 10px; }
    
    /* 5. TRỢ LÝ ẢO: Mở rộng khung chat chiếm phần lớn màn hình */
    .chatbot-window {
        width: 90vw; /* Rộng 90% màn hình */
        right: 5vw;  /* Cách mép phải 5% */
        bottom: 80px;
        height: 60vh; /* Cao 60% màn hình */
    }
    .chatbot-toggler {
        bottom: 15px; right: 15px; padding: 12px 20px; font-size: 14px;
    }
}
.mindmap-container {
    display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin: 30px 0;
}
.node-link { display: flex; align-items: center; gap: 10px; background: #f8f9fa; padding: 10px 20px; border-radius: 50px; border: 1px solid #0d6efd; }
.node { font-weight: bold; color: #0d6efd; font-size: 18px; }
.arrow { color: #e67e22; font-weight: bold; }
.reaction-item { text-align: left; background: #e7f1ff; padding: 15px; border-radius: 10px; margin-bottom: 10px; border-left: 5px solid #0d6efd; }
.failed-screen h2 { color: #d35400; font-size: 28px; margin-top: 0;}
.failed-screen p { font-size: 18px; color: #333;}
/* ================= BỘ LỌC CHUỖI PHẢN ỨNG ================= */
.filter-group {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}

.btn-filter {
    background: #ffffff;
    border: 2px solid #ced4da;
    color: #6c757d;
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.btn-filter:hover {
    background: #e9ecef;
}

.btn-filter.active {
    background: #e74c3c;
    color: white;
    border-color: #e74c3c;
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.3);
}
/* ================= HỘP CẢNH BÁO LỖI (WARNING BOX) ================= */
.warning-box {
    background-color: #fff3cd;
    color: #856404;
    border-left: 6px solid #ffc107;
    padding: 20px 25px;
    border-radius: 10px;
    text-align: left;
    margin: 20px auto;
    max-width: 600px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    animation: fadeIn 0.4s ease;
}

.warning-box h3 {
    margin-top: 0;
    color: #d39e00;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.warning-box p {
    margin-bottom: 10px;
    font-size: 16px;
    line-height: 1.5;
}
/* ================= GIẤY NHÁP LỜI GIẢI (CÔNG CỤ NỒNG ĐỘ) ================= */
.solution-paper {
    background-color: #fdfbf7; /* Màu giấy hơi vàng cổ điển */
    border: 1px solid #d1d8e0;
    border-left: 8px solid #27ae60;
    padding: 25px;
    border-radius: 10px;
    text-align: left;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    font-size: 16px;
    animation: fadeIn 0.5s ease;
    background-image: repeating-linear-gradient(#fdfbf7 0px, #fdfbf7 29px, #e1e8ed 30px); /* Kẻ sọc ngang như vở học sinh */
    line-height: 30px;
}
/* Nút Trợ lý Hóa học (Nằm trên) */
.chatbot-toggler {
    position: fixed;
    right: 20px;
    bottom: 85px; /* Đẩy lên trên để nhường chỗ cho nút info */
    height: 45px;
    padding: 0 20px;
    background: #0d6efd;
    color: white;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    font-weight: bold;
    transition: 0.3s;
}

/* Nút Thông tin dự án (Nằm dưới cùng) */
.info-toggler {
    position: fixed;
    right: 20px;
    bottom: 20px; /* Đưa xuống vị trí thấp nhất */
    height: 45px;
    padding: 0 20px;
    background: #27ae60;
    color: white;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    font-weight: bold;
    transition: 0.3s;
}

/* Điều chỉnh vị trí khung Chat và khung Intro khi mở ra */
.chatbot-window {
    position: fixed;
    right: 20px;
    bottom: 150px; /* Cả hai khung đều mở phía trên các nút bấm */
    width: 350px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header { background: #0d6efd; color: white; padding: 15px; display: flex; justify-content: space-between; }
.chat-body { height: 320px; padding: 15px; overflow-y: auto; background: #f8f9fa; display: flex; flex-direction: column; gap: 12px; }
.message { max-width: 85%; padding: 10px 15px; border-radius: 15px; font-size: 14px; }
.bot-message { background: #e9ecef; align-self: flex-start; }
.user-message { background: #0d6efd; color: white; align-self: flex-end; }