/* --- IELTS Quiz Screen Layout --- */
.iot-quiz-screen {
    position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: 100% !important; height: 100% !important; z-index: 999999 !important;
    display: flex; flex-direction: column; background: #fff;
    overflow: hidden !important; /* Khóa cuộn màn hình ngoài */
    overscroll-behavior: none !important; /* Chặn vuốt nảy toàn màn hình */
}

/* GRADIENT CHO LOGO VÀ CÁC NÚT BẤM */
.iot-logo .logo {
    font-size: 18px; font-weight: 900;
    background: linear-gradient(135deg, #2563EB, #7C3AED);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.iot-start-btn, .iot-btn-submit-ielts, .iot-view-answers-btn, .iot-btn-primary {
    background: linear-gradient(135deg, #2563EB, #7C3AED) !important;
    border: none !important; color: #fff !important; transition: opacity 0.3s;
}
.iot-start-btn:hover, .iot-btn-submit-ielts:hover { opacity: 0.9; }

.iot-ielts-header {
    display: flex; justify-content: space-between; align-items: center;
    background: #fff; padding: 10px 20px; border-bottom: 1px solid #ddd; flex-shrink: 0;
}
.iot-timer-center { font-size: 16px; color: #333; display: flex; align-items: center; gap: 8px; }
.iot-header-actions { display: flex; align-items: center; }
.iot-btn-icon { background: none; border: none; cursor: pointer; color: #555; margin-right: 15px; position: relative; display: flex; align-items: center; justify-content: center; }
.iot-notepad-dot { position: absolute; top: -2px; right: -2px; width: 8px; height: 8px; background: #dc2626; border-radius: 50%; }
.iot-btn-submit-ielts { padding: 8px 20px; border-radius: 20px; font-weight: bold; cursor: pointer; font-size: 15px; display: flex; align-items: center; }

/* --- Body Chia Cột & Resizer --- */
.iot-body { display: flex; flex: 1 1 0%; min-height: 0 !important; height: 100%; background: #fff; position: relative; overflow: hidden !important; }
.iot-passage-pane, .iot-questions-pane { 
    padding: 30px 40px; overflow-y: auto !important; height: 100% !important; box-sizing: border-box !important; 
    overscroll-behavior: none !important; /* Triệt tiêu hoàn toàn hiệu ứng nảy (rubber-banding) trên Mobile/Tablet */
    -webkit-overflow-scrolling: touch; /* Giữ độ mượt khi cuộn trên iOS */
}
.iot-passage-pane { font-size: 16px; line-height: 1.8; }
.iot-questions-pane { background: #fafafa; }
.iot-resizer {
    width: 10px; background: #e2e8f0; display: flex; align-items: center; justify-content: center;
    cursor: col-resize; flex-shrink: 0; user-select: none; transition: background 0.2s; position: relative;
}
.iot-resizer:hover, .iot-resizer:active { background: #94a3b8; }

/* Icon Kéo thả thay cho SVG (Dùng SVG Base64 chuẩn, không cần tải file font) */
.iot-resizer::after {
    content: '';
    position: absolute;
    z-index: 9;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 24px;
    /* Dùng 2 đường kẻ sọc dọc (Grip) chuẩn UI/UX thay cho font lỗi */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 24' width='8' height='24'%3E%3Cpath d='M2.5 4v16M5.5 4v16' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

/* --- Cột Notepad Sidebar --- */
.iot-notepad-sidebar {
    width: 320px; flex-shrink: 0; background: #fff; border-left: 1px solid #ddd;
    display: flex; flex-direction: column; box-shadow: -2px 0 10px rgba(0,0,0,0.05);
}
.iot-notepad-header { padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; background: #fff; }
.iot-notepad-close { background: none; border: none; cursor: pointer; padding: 0; display: flex; }
.iot-notepad-search { padding: 15px 20px; border-bottom: 1px solid #eee; }
.iot-notepad-search input { 
    width: 100%; height: 40px !important; padding: 10px 15px; border: 1px solid #cbd5e1; 
    border-radius: 20px; outline: none; font-size: 14px !important; font-family: Arial, sans-serif !important; box-sizing: border-box;
}
.iot-notepad-list { flex: 1; overflow-y: auto; padding: 10px 20px; }
.iot-note-item { border-bottom: 1px solid #f1f5f9; padding: 12px 0; }
.iot-note-title { font-weight: bold; text-decoration: underline; color: #2563EB; margin-bottom: 5px; display: block; font-size: 15px; cursor: pointer; }
.iot-note-content { color: #333; font-size: 14px; line-height: 1.5; }

/* --- Tooltip & Note Popup --- */
.iot-tooltip-popup {
    position: absolute; background: #1e293b; border-radius: 6px; padding: 6px 10px;
    display: flex; align-items: center; gap: 8px; z-index: 99999; box-shadow: 0 5px 15px rgba(0,0,0,0.2) !important;
}
.iot-tooltip-popup::after {
    content: ''; position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%);
    border-width: 5px 5px 0; border-style: solid; border-color: #1e293b transparent transparent transparent;
}
.iot-tt-btn { background: none; border: none; color: #fff; font-size: 15px !important; font-weight: 500; cursor: pointer; padding: 6px 12px !important; }
.iot-tt-btn:hover { color: #93c5fd; }
.iot-tt-divider { width: 1px; height: 16px; background: #475569; }

.iot-note-input-popup {
    position: absolute; width: 280px; background: #fff; border: 1px solid #cbd5e1;
    border-radius: 8px; padding: 15px; z-index: 99999; box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.iot-note-input-popup textarea {
    width: 100%; height: 100px; padding: 10px; border: 1px solid #e2e8f0; border-radius: 4px;
    font-size: 14px; font-family: inherit; resize: none; outline: none; box-sizing: border-box; margin-bottom: 10px;
}
.iot-note-popup-actions { display: flex; justify-content: center; gap: 10px; }
.iot-btn-save-note, .iot-btn-cancel-note { padding: 6px 16px; border-radius: 4px; font-size: 14px; cursor: pointer; border: 1px solid #cbd5e1; background: #fff; }
.iot-btn-save-note { border-color: #2563EB; color: #2563EB; }
.iot-highlighted { background-color: #fef08a; padding: 2px 0; border-radius: 2px; }

/* --- IELTS Footer Navigation --- */
.iot-ielts-footer {
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; padding: 10px 20px; border-top: 1px solid #ddd; flex-shrink: 0;
}
.iot-parts-container { display: flex; gap: 15px; overflow-x: auto; padding-bottom: 5px;}
.iot-part-nav-group {
    display: flex; align-items: center; gap: 10px; background: #fff; 
    padding: 6px 15px; border-radius: 25px; border: 1px solid #ccc; opacity: 0.6; transition: all 0.2s;
}
.iot-part-nav-group.active { opacity: 1; border-color: #2563EB; }
.iot-part-btn { font-weight: bold; color: #333; background: none; border: none; padding: 0; }
.iot-q-circles { display: flex; gap: 6px; }

.iot-circle {
    display: flex; justify-content: center; align-items: center;
    width: 26px; height: 26px; border-radius: 50%;
    border: 1px solid #ccc; font-size: 12px; background: #fff; color: #333; cursor: pointer;
}
.iot-circle.answered { background: #d1e7dd; border-color: #d1e7dd; color: #0f5132; font-weight: bold; }

.iot-part-inactive-view {border-radius: 25px; color: #475569; font-size: 14px;}
.iot-part-inactive-view strong { color: #1e293b; }

.iot-nav-arrows { display: flex; gap: 10px; }
.iot-nav-circle-btn {
    width: 36px; height: 36px; border-radius: 50%; border: 1px solid #2563EB;
    background: #fff; color: #2563EB; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.iot-nav-circle-btn:hover { background: #2563EB; color: #fff; }
.iot-nav-circle-btn[style*="visibility: hidden"] { display: none !important; }

/* HIỆU ỨNG LÀM SÁNG CÂU HỎI (ACTIVE QUESTION) */
.iot-q-text { transition: all 0.3s ease; border-radius: 6px; padding: 2px; }
.iot-q-text-active { background-color: #f0f8ff !important; border-left: 4px solid #2563EB !important; padding: 10px 15px !important; box-shadow: 0 2px 10px rgba(37,99,235,0.1); }

/* TÔ MÀU VÒNG TRÒN DƯỚI FOOTER KHI XEM ĐÁP ÁN */
.iot-circle.iot-circle-correct { background: #16a34a !important; border-color: #16a34a !important; color: #fff !important; font-weight: bold; }
.iot-circle.iot-circle-wrong { background: #dc2626 !important; border-color: #dc2626 !important; color: #fff !important; font-weight: bold; }
.iot-circle.iot-circle-yellow { background: #ffc107 !important; border-color: #ffc107 !important; color: #fff !important; font-weight: bold; }

/* CSS TOÀN CỤC CHO SỐ THỨ TỰ CÂU HỎI (Áp dụng mọi Module) */
.iot-q-num {
    display: inline-flex; justify-content: center; align-items: center;
    width: 26px; height: 26px; border-radius: 50%;
    border: 1px solid #ccc; font-size: 12px; background: #fff; color: #333;
    margin-right: 5px; margin-left: 5px; vertical-align: middle; transition: all 0.2s; font-weight: normal; flex-shrink: 0;
}
.iot-q-num.active {
    background: #2563EB !important; border-color: #2563EB !important; color: #fff !important; font-weight: bold;
}
/* Khoảng cách đệm an toàn trên cùng khi cuộn đến câu hỏi */
.iot-q-block {
    scroll-margin-top: 30px;
}

/* Overlay cho bảng kết quả hiển thị đè lên màn hình thi */
.iot-result-overlay {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    z-index: 9999999 !important;
    background: rgba(15, 23, 42, 0.85) !important;
    backdrop-filter: blur(5px);
}

/* --- BẢN VÁ LỖI VỠ GIAO DIỆN TRÊN IPAD / IOS SAFARI --- */
/* Dùng 100dvh (Dynamic Viewport) để giao diện tự co giãn khớp với thanh URL của Safari */
.iot-quiz-screen, .iot-result-overlay {
    height: 100vh !important; /* Fallback cho trình duyệt cũ */
    height: 100dvh !important; /* Chuẩn mới */
    min-height: -webkit-fill-available !important; /* Fix lỗi khoảng trắng đáy của Apple */
}

/* Class khóa chặt website gốc, chống kéo nảy (rubber-band) 100% */
body.iot-ios-locked {
    position: fixed !important;
    width: 100% !important;
    overflow: hidden !important;
    overscroll-behavior: none !important;
}