/* ===============================
   TOEIC Speaking Layout
   =============================== */

.ai-loading {
  text-align: center;
  margin: 30px auto;
  color: #555;
  animation: fadeIn 0.4s ease;
}
.ai-loading img.ai-gif {
  width: 70px;
  height: auto;
  display: block;
  margin: 0 auto 10px;
  border-radius: 50%;
}
@keyframes fadeIn {
  from {opacity: 0; transform: scale(0.95);}
  to {opacity: 1; transform: scale(1);}
}

.toeic-controls .toeic-relisten-btn {
  background: #4f46e5;
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.toeic-controls .toeic-relisten-btn:hover {
  background: #4338ca;
  color: #fff;
}

.toeic-debug {
  margin-top: 16px;
  background: #6b7280;
  color: #fff;
}
.toeic-debug:hover { background: #4b5563; }

/* ===== Sóng âm khi ghi âm (Recording Wave) ===== */
.toeic-rec-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-left: 10px;
  vertical-align: middle;
}

.mon-pro-wave {
  width: 30px;
  height: 18px;
  overflow: hidden;
}

.toeic-timer {
  font-weight: 600;
  font-size: 15px;
  color: #374151;
  min-width: 30px;
}

/* [V3.1] Highlight màu */

#toeic-colored h3 {
  margin-top: 20px;
  font-size: 16px;
  font-weight: 600;
  color: #1e40af;
  border-left: 4px solid #3b82f6;
  padding-left: 8px;
}

#toeic-colored .toeic-original {
  background: #f9fafb;
  padding: 10px 12px;
  border-radius: 6px;
  font-style: italic;
}

#toeic-colored .toeic-colored-text {
  background: #fff;
  padding: 10px 12px;
  border-radius: 6px;
}

#toeic-feedback {
  background: #f8fafc;
  padding: 12px 14px;
  border-radius: 6px;
  margin-top: 10px;
  border-left: 3px solid #3b82f6;
  margin-bottom: 120px;
}

.correct { color:#16a34a; font-weight:500; }
.word-ipa { color:#555; font-size:0.9em; margin-left:4px; }
.ai-word[data-type="missing"] { background: #e0f2ff; border-bottom: 2px dotted #2196f3; }
.ai-word[data-type="suggest"] { background: #e6ffe6; border-bottom: 2px solid #009900; }

.wrong-light {
  background-color: #fff3cd;  /* vàng nhạt */
  border-bottom: 2px dashed #f0ad4e;
  padding: 0 2px;
  border-radius: 3px;
  cursor: pointer;
  transition: background .2s;
}
.wrong-light:hover {
  background-color: #ffe082;
}

.wrong-heavy {
  background-color: #f8d7da;  /* đỏ nhạt */
  text-decoration: line-through;
  color: #b71c1c;
  font-weight: 600;
  border-bottom: 2px solid #f44336;
  padding: 0 2px;
  border-radius: 3px;
  cursor: pointer;
  transition: background .2s;
}
.wrong-heavy:hover {
  background-color: #ffcdd2;
}

/* [V3.1] Popup luyện lại từ sai của AI (class tách riêng, không trùng popup voice) */

.toeic-word-popup .popup-status { margin-top:8px; font-size:14px; color:#444; min-height:20px; }
.toeic-word-popup .popup-status .wave { display:inline-block; width:10px; height:10px; background:#2563eb;
  border-radius:50%; margin-right:6px; vertical-align:middle; transition:opacity 0.3s; }
.toeic-word-popup .popup-status .time { font-weight:600; }
.toeic-word-popup .popup-status .done { color:#16a34a; font-weight:600; }

.toeic-word-popup-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9998;
}
.toeic-word-popup {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: #fff; border-radius: 12px;
  padding: 18px 22px;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
  z-index: 9999; width: 260px;
}
.toeic-word-popup h3 { margin: 0 0 4px; font-size: 22px; font-weight: 600; }
.toeic-word-popup .ipa { color: #2563eb; font-weight: 600; margin: 0 0 14px; }
.toeic-word-popup .word-popup-btns button {
  margin: 4px; padding: 8px 10px;
  border: none; border-radius: 6px;
  color: #fff; font-weight: 600;
  cursor: pointer; font-size: 14px;
}
.toeic-word-popup .popup-play-mine { background: #6b4dfc; }
.toeic-word-popup .popup-play-right { background: #4f46e5; }
.toeic-word-popup .popup-record { background: #0ea5e9; }
.toeic-word-popup .popup-close { background: #999; color:#fff; border-radius:50%; padding:4px 8px; }

/* Wrapper */
.toeic-wrapper {
  margin:0px auto;
  max-width: 1200px; /* giữ max width đồng bộ với theme */
  width: 100%;       /* để không bị co lại */
}

/* Nút Record đang ghi */
#toeic-record.recording {
  background:#dc2626 !important;
  border-color:#b91c1c !important;
  color:#fff;
}
.toeic-timer { margin-left:8px; font-weight:700; color:#dc2626; }
.toeic-preview { margin-top: 12px; display:block; }

/* Tabs trên cùng */
.toeic-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.toeic-tabs .tab {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  text-decoration: none;
  color: #111;
  font-weight: 500;
  transition: all 0.2s;
}
.toeic-tabs .tab:hover {
  background: #f3f4f6;
}
.toeic-tabs .tab.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* Layout chính: sidebar + main */
.toeic-layout {
  display: grid;
  grid-template-columns: 300px 1fr; /* Sidebar 300px, main chiếm hết phần còn lại */
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  min-height: 500px;
}


/* Sidebar Task */
.toeic-sidebar {
  border-right: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 16px;
    /* thêm 2 dòng này */
  max-height: 600px;      /* hoặc vh = % chiều cao màn hình */
  overflow-y: auto;       /* bật scroll dọc */
}

/* Optional: custom scrollbar cho pro hơn */
.toeic-sidebar::-webkit-scrollbar {
  width: 8px;
}
.toeic-sidebar::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 8px;
}
.toeic-sidebar::-webkit-scrollbar-thumb {
  background: #9ca3af;
  border-radius: 8px;
}
.toeic-sidebar::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

.toeic-task {
  margin-bottom: 18px;
}
.toeic-task h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 8px;
  color: #6b7280;
  text-transform: uppercase;
}
.toeic-task ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.toeic-task li {
  margin-bottom: 6px;
}
.toeic-task .toeic-qbtn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: #111827;
  transition: all 0.2s;
}
.toeic-task .toeic-qbtn:hover {
  background: #f3f4f6;
}
.toeic-task .toeic-qbtn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* Main Content */
.toeic-main {
  padding: 20px;
  background: #fff;
  min-width: 0;        /* 🔑 tránh bị grid co về 0 */
  flex-grow: 1;        /* phòng trường hợp grid biến thành flex */
  display: block;      /* đảm bảo section là block element */
  border: 1px solid red;
  position: relative;
}
.toeic-main h2 {
  margin-top: 0;
  font-size: 20px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 12px;
}
.toeic-main p {
  font-size: 16px;
  line-height: 1.6;
  color: #374151;
  margin-bottom: 16px;
}

/* Nút điều khiển */
.toeic-controls {
  display: flex;
  gap: 12px;
  margin: 14px 0;
}
.toeic-controls .btn {
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}
.toeic-controls .btn-primary {
  background: #2563eb;
  color: #fff;
  border: 1px solid #2563eb;
}
.toeic-controls .btn-primary:hover {
  background: #1e40af;
  color: #fff;
}
.toeic-controls .btn-secondary {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
}
.toeic-controls .btn-secondary:hover {
  background: #e5e7eb;
}


.toeic-controls .toeic-btn {
  background: #f9fafb;
  border: 1px solid #ddd;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.toeic-controls .toeic-btn.recording {
  background: #fee2e2;
  border-color: #f87171;
  color: #b91c1c;
}

.toeic-player {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f3f4f6;
  border: 1px solid #ddd;
  padding: 6px 12px;
  border-radius: 6px;
}
.toeic-player.hidden { display:none; }
.toeic-play {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
}
.toeic-time {
  font-size: 14px;
  color: #374151;
}

/* [FIX] Nút “Tôi nói” hiển thị ngang hàng với NGHE/GHI ÂM */
.toeic-relisten-btn-inline {
  background: #4f46e5;
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 10px;
}

.toeic-relisten-btn-inline:hover {
  background: #4338ca;
}

/* Kết quả điểm */
#toeic-result {
  margin-top: 20px;
}

/* [FIX] Vòng tròn hiển thị đồng đều và căn giữa */
/* Vòng điểm */
.score-ring-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.score-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 140px;
  text-align: center;
}

.score-ring svg {
  width: 100%;
  height: auto;
}

.score-ring svg text {
  dominant-baseline: middle;
  fill: #111;
}

.toeic-total {
  text-align: center;
  font-weight: 700;
  margin-top: 15px;
  font-size: 18px;
}


/* ===============================
   Popup chọn voice
   =============================== */
.toeic-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: none;
}
body.single-toeic_speaking_test .toeic-popup-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
}
.toeic-popup-content {
  position: relative;
  z-index: 10000;
  max-width: 400px;
  margin: 20% auto;
  padding: 20px;
  background: #fff;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.toeic-popup-content h3 {
  margin-top: 0;
  font-size: 18px;
}
.voice-choice {
  display: block;
  width: 100%;
  margin: 10px 0;
  padding: 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.2s;
}
.voice-choice[data-voice*="Jenny"] {
  background: #f3f4f6;
}
.voice-choice[data-voice*="Guy"] {
  background: #e0f2fe;
}
.voice-choice:hover {
  background: #2563eb;
  color: #fff;
}

/* ===============================
   Gioi thieu chua co cau hoi
   =============================== */

.toeic-empty {
  padding: 0px 20px;
  color: #444;
  font-family: "Helvetica", sans-serif;
  max-height: 526px;
  overflow-y:auto;
}

.toeic-empty-img {
  width: 140px;
  opacity: 0.9;
  margin-bottom: 20px;
}

.toeic-empty h3 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #222;
}

.toeic-empty p {
  font-size: 15px;
  color: #666;
  margin: 5px 0;
}

.toeic-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  margin: 30px auto;
  max-width: 700px;
}

.toeic-feature {
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 15px;
  text-align: center;
  transition: all 0.3s ease;
}

.toeic-feature:hover {
  background: #f0f9ff;
  border-color: #cce5ff;
}

.toeic-feature .icon {
  font-size: 28px;
  display: block;
  margin-bottom: 8px;
}

.toeic-note {
  font-size: 14px;
  margin-top: 30px;
  color: #0073e6;
  font-weight: 500;
}

/* Voice choice rows */
.voice-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0;
}

.voice-choice {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  background: #f3f4f6;
  transition: background .2s;
}

.voice-choice:hover {
  background: #2563eb;
  color: #fff;
}

.voice-preview {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.voice-preview:hover {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* --- Toggle button: ẩn desktop, hiện mobile --- */
.toeic-sidebar-toggle, .toeic-close { display: none !important; }
@media (max-width: 768px) {
  .toeic-sidebar-toggle {
    display: inline-block !important;
    background: #2563eb; color:#fff;
    padding: 10px 14px; border-radius: 6px;
    font-size: 14px; margin-bottom: 12px; cursor: pointer;
  }
}

/* --- Drawer & overlay (mobile) --- */
@media (max-width: 768px) {
  .toeic-layout { display:block;}

  /* Overlay nền tối */
  .toeic-overlay{
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    opacity: 0; pointer-events: none;
    transition: opacity .25s ease;
    z-index: 9998;
  }
  .toeic-overlay.active{ opacity:1; pointer-events:auto; }

  /* Sidebar ở dạng drawer */
  .toeic-sidebar{
    position: fixed;
    top: 0; left: 0;
    height: 100dvh;              /* tốt cho iOS */
    width: 82vw; max-width: 380px;
    background: #fff;
    z-index: 9999;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 2px 0 18px rgba(0,0,0,.2);
    transform: translateX(-105%);   /* Ẩn mặc định */
    visibility: hidden;
    transition: transform .28s ease, visibility 0s .28s;
    padding: 18px 16px 24px;
  }
  .toeic-sidebar.active{
    transform: translateX(0);
    visibility: visible;
    transition: transform .28s ease;
  }

  /* Nút đóng trong sidebar */
  .toeic-close{
    display: block !important;
    position: sticky; top: 0; right: 0;
    float: right;
    margin: -6px -6px 8px 0;
    width: 36px; height: 36px; line-height: 36px;
    text-align: center;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #fff; color:#111; font-size: 18px;
    z-index: 1;
  }
}

/* Khóa cuộn khi drawer mở */
html.toeic-locked, body.toeic-locked { overflow: hidden; touch-action: none; }

