/* =========================================
   GIAO DIỆN THI AZOTA - REVIEW MODE V8
   ========================================= */

/* 1. Khung bao ngoài */
.exam-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  background: #f0f2f5;
  color: #333;
  font-family: "Segoe UI", sans-serif;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
}

/* 2. Cột Trái */
.exam-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
}

.exam-toolbar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

.exam-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 40px;
  scroll-behavior: smooth;
  background: #f5f7fa;
  font-size: 16px;
}

/* 3. Cột Phải: Sidebar */
.exam-sidebar {
  width: 320px;
  flex-shrink: 0;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10000;
}

/* Header Sidebar (Chứa chữ "Danh sách..." hoặc ĐIỂM SỐ) */
.exam-sidebar-header {
  padding: 15px;
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60px;
}
.header-title {
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  font-size: 14px;
}

/* Điểm số (Hiện sau khi nộp) */
.exam-score-display {
  font-size: 28px;
  font-weight: 900;
  color: #3b82f6;
  line-height: 1;
  margin-top: 5px;
}
.exam-score-label {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
}

/* Lưới ô số */
.exam-grid {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  align-content: start;
}

.exam-submit-box {
  padding: 15px;
  border-top: 1px solid #f0f0f0;
  background: #fff;
}

/* --- TRẠNG THÁI Ô SỐ (QUAN TRỌNG) --- */
.exam-grid-item {
  aspect-ratio: 1.2;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: #64748b;
  cursor: pointer;
  background: #fff;
}
.exam-grid-item:hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

/* Đang làm (Xanh dương) */
.exam-grid-item.done {
  background: #eff6ff;
  color: #2563eb;
  border-color: #2563eb;
}

/* Đúng (Xanh lá) */
.exam-grid-item.correct {
  background: #dcfce7 !important;
  color: #166534 !important;
  border-color: #166534 !important;
}
/* Sai (Đỏ) */
.exam-grid-item.wrong {
  background: #fee2e2 !important;
  color: #991b1b !important;
  border-color: #991b1b !important;
}

/* --- KHUNG GIẢI THÍCH (Mặc định ẩn) --- */
.exam-explain-box {
  margin-top: 15px;
  padding: 15px;
  background: #fffbeb; /* Vàng nhạt */
  border: 1px solid #fcd34d;
  border-radius: 8px;
  color: #92400e;
  font-size: 14px;
  line-height: 1.5;
  display: none; /* Ẩn đi chờ JS kích hoạt */
  animation: fadeIn 0.5s;
}
.explain-label {
  font-weight: 800;
  margin-bottom: 5px;
  display: block;
  text-transform: uppercase;
  font-size: 12px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- CÁC STYLE CŨ (Giữ nguyên) --- */
.exam-question-card {
  background: #fff;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}
.exam-q-badge {
  display: inline-block;
  background: #0f172a;
  color: #fff;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 12px;
}
.exam-q-text {
  font-size: 16px;
  margin-bottom: 25px;
  line-height: 1.6;
  color: #1e293b;
}
.exam-q-text img {
  max-width: 100%;
  border-radius: 6px;
  margin-top: 10px;
  border: 1px solid #eee;
}

/* Đúng Sai */
.exam-tf-row {
  display: flex;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 10px;
  gap: 15px;
}
.exam-tf-content {
  flex: 1;
}
.exam-tf-actions {
  flex-shrink: 0;
  display: flex;
  gap: 5px;
}
.btn-exam-tf {
  padding: 6px 15px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  min-width: 60px;
  color: #64748b;
}
.btn-exam-tf.selected[onclick*="true"] {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}
.btn-exam-tf.selected[onclick*="false"] {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

/* Trắc nghiệm & Input */
.exam-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.exam-opt-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
}
.exam-opt-item.selected {
  background: #eff6ff;
  border-color: #3b82f6;
}
.exam-opt-char {
  width: 28px;
  height: 28px;
  background: #f1f5f9;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.exam-opt-item.selected .exam-opt-char {
  background: #3b82f6;
  color: #fff;
}
.exam-input-box input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  outline: none;
}

.exam-group-label {
  grid-column: 1/-1;
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  margin-top: 15px;
  text-transform: uppercase;
}
.btn-submit-exam {
  width: 100%;
  padding: 12px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}
.exam-timer {
  font-size: 18px;
  font-weight: 800;
  color: #0284c7;
  background: #e0f2fe;
  padding: 6px 15px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.btn-tool-zoom {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #ddd;
  cursor: pointer;
  background: #fff;
}
.exam-btn-exit {
  padding: 6px 15px;
  border: 1px solid #ef4444;
  color: #ef4444;
  background: #fff;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}

/* ======================================================
   STYLE EXAM - FIX 22.0 (NO OVERLAY + SCROLL OK)
   ====================================================== */

/* 1. MẶC ĐỊNH ẨN CÁC NÚT MOBILE TRÊN PC */
.mobile-only {
  display: none !important;
}

/* 2. ẨN MENU CHÍNH KHI ĐANG THI (QUAN TRỌNG) */
body.in-exam-mode .nav,
body.in-exam-mode .sidebar-pro,
body.in-exam-mode .mobile-menu-trigger,
body.in-exam-mode .controls,
body.in-exam-mode .user-profile,
body.in-exam-mode #floatingBell {
  display: none !important;
}

/* 3. QUY ĐỊNH CHUNG CHO GIAO DIỆN THI (PC) */
.exam-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  background: #f0f2f5;
  color: #333;
  font-family: "Segoe UI", sans-serif;
  overflow: hidden;
  position: fixed; /* PC ghim cứng */
  top: 0;
  left: 0;
  z-index: 9999;
}

.exam-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.exam-toolbar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

.exam-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 40px;
  scroll-behavior: smooth;
  background: #f5f7fa;
}

.exam-sidebar {
  width: 320px;
  flex-shrink: 0;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Style cho Câu hỏi và Đáp án */
.exam-question-card {
  background: #fff;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}
.exam-q-text img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 10px auto;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  cursor: zoom-in;
}
.exam-opt-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
}
.exam-opt-item.selected {
  background: #eff6ff;
  border-color: #3b82f6;
}
.exam-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* -----------------------------------------------------------
   MOBILE RESPONSIVE (MÀN HÌNH ĐIỆN THOẠI)
   ----------------------------------------------------------- */
@media (max-width: 768px) {
  /* --- A. MỞ KHÓA CUỘN (SCROLL UNLOCK) --- */
  html,
  body {
    overflow: auto !important;
    height: auto !important;
    min-height: 100% !important;
  }

  body.in-exam-mode {
    overflow-y: auto !important;
    position: static !important;
    touch-action: pan-y !important;
  }

  .exam-container {
    position: relative !important;
    display: block !important;
    height: auto !important;
    min-height: 100vh !important;
    overflow: visible !important;
    padding-top: 60px !important; /* Chừa chỗ cho Header */
  }

  .exam-main {
    height: auto !important;
    overflow: visible !important;
    display: block !important;
  }

  .exam-scroll-area {
    height: auto !important;
    overflow: visible !important;
    padding: 15px 10px 80px 10px !important;
  }

  /* --- B. HEADER CỐ ĐỊNH --- */
  .exam-toolbar {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #fff !important;
    z-index: 99999 !important;
    padding: 0 10px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  }

  /* Ẩn/Hiện nút */
  .mobile-only {
    display: flex !important;
  }
  .pc-only,
  .btn-tool-zoom,
  .exam-btn-exit {
    display: none !important;
  }

  /* Style nút Mobile */
  .btn-mobile-exit {
    background: #fee2e2 !important;
    color: #ef4444 !important;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: none;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .exam-timer {
    font-size: 19px !important;
    font-weight: 800;
    color: #1e293b !important;
  }
  .btn-mobile-submit {
    background: #3b82f6 !important;
    color: #fff !important;
    padding: 8px 16px !important;
    border-radius: 8px;
    border: none;
    font-weight: 700;
    margin-right: 8px;
  }
  .btn-mobile-grid {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
  }

  /* --- C. MENU CÂU HỎI (FULL MÀN HÌNH - KHÔNG OVERLAY) --- */
  .exam-sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    height: 100vh !important;
    background: #fff !important; /* Nền trắng tuyệt đối */
    z-index: 2147483647 !important; /* Cao nhất vũ trụ */
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .exam-sidebar.active {
    transform: translateY(0);
  }

  /* [FIX] TẮT HOÀN TOÀN LỚP MỜ ĐỂ KHÔNG CHE NÚT */
  .mobile-overlay,
  .mobile-overlay.active {
    display: none !important;
  }

  .exam-sidebar-header {
    height: 60px !important;
    border-bottom: 1px solid #f1f5f9;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: #f8fafc !important;
    flex-shrink: 0;
    position: relative;
  }
  .btn-close-full-menu {
    position: absolute;
    right: 15px;
    font-size: 28px;
    background: none;
    border: none;
    color: #94a3b8;
  }

  /* Lưới câu hỏi */
  .exam-grid {
    padding: 20px !important;
    overflow-y: auto !important;
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 10px !important;
  }
  .exam-grid-item {
    font-size: 16px !important;
    height: 50px !important;
    border-radius: 8px !important;
  }

  /* --- D. TINH CHỈNH NỘI DUNG --- */
  .exam-question-card {
    padding: 15px !important;
    border-radius: 10px !important;
  }
  .exam-options-grid {
    grid-template-columns: 1fr !important;
  }
  .exam-tf-row {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    padding: 15px 0 !important;
    border-bottom: 1px solid #f1f5f9;
  }
  .exam-tf-content {
    width: 70% !important;
    flex: none !important;
  }
  .exam-tf-actions {
    width: 85px !important;
    flex: none !important;
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .btn-exam-tf {
    width: 100% !important;
    padding: 8px 0 !important;
    font-size: 11px !important;
  }
  .exam-score-display {
    font-size: 60px !important;
    margin: 20px 0 !important;
  }
}

/* Modal Zoom Ảnh */
.exam-img-zoom-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999999;
  background: rgba(0, 0, 0, 0.95);
  align-items: center;
  justify-content: center;
}
.exam-img-zoom-overlay img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
