.exercise-integration {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.lesson-header {
  background: linear-gradient(
    to right,
    rgba(15, 23, 42, 0.98),
    rgba(30, 64, 175, 0.9)
  );
  border: none;
  border-top: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 0;
  padding: 1.2rem 2rem;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  margin-top: 30px;
  /* Match the parent padding exactly to avoid horizontal scroll */
  margin-left: -1rem;
  margin-right: -1rem;
  margin-bottom: 0px;
  position: sticky;
  bottom: 0px;
  z-index: 100;
  order: 10;
}

@container (max-width: 900px) {
  .lesson-header {
    margin-left: -1rem;
    margin-right: -1rem;
    margin-bottom: 0px;
    margin-top: 0 !important;
    bottom: 0px;
    padding: 0.8rem 1rem !important;
  }
}

@container (max-width: 768px) {
  .lesson-header {
    padding: 2px 0.5rem !important;
  }
  .lesson-header h2 {
    display: none;
  }
  .audio-player-wrapper {
    flex-wrap: nowrap;
    gap: 0.4rem;
    padding: 0.1rem !important;
    background: transparent !important;
  }
  .player-controls {
    flex-wrap: nowrap;
    gap: 8px;
    width: 100%;
  }
  .btn-icon {
    width: 28px;
    height: 28px;
  }
  .btn-icon-sub {
    width: 28px;
    height: 28px;
  }
  #time-display {
    font-size: 0.7rem;
    min-width: 60px;
  }
}

@media (max-width: 480px) {
  .btn-icon {
    width: 28px;
    height: 28px;
  }
  .btn-icon-sub {
    width: 24px;
    height: 24px;
  }
  .progress-container {
    height: 4px;
  }
  #time-display {
    font-size: 0.65rem;
    min-width: 50px;
  }
}

@container (max-width: 600px) {
  .lesson-header {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    width: calc(100% + 1rem);
  }
}

@media (max-width: 480px) {
  .player-controls {
    justify-content: center;
    gap: 10px;
  }
}

.lesson-header h2 {
  font-size: 1.4rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

/* Glass Panel */
.glass-panel {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

@keyframes slideIn {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.badge {
  display: inline-block;
  padding: 6px 14px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--primary);
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

h2 {
  font-size: 2.2rem;
  margin-bottom: 1rem;
  font-weight: 800;
}

/* Audio Player - Compact version */
.audio-player-wrapper {
  background: rgba(15, 23, 42, 0.5);
  border-radius: 12px;
  padding: 0.8rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.player-visualizer {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 25px;
  width: 40px;
}

.bar {
  width: 4px;
  background: var(--primary);
  border-radius: 2px;
  animation: bars 1.2s infinite ease-in-out;
}

.bar:nth-child(2) {
  animation-delay: 0.2s;
  height: 60%;
}
.bar:nth-child(3) {
  animation-delay: 0.4s;
  height: 100%;
}
.bar:nth-child(4) {
  animation-delay: 0.1s;
  height: 80%;
}
.bar:nth-child(5) {
  animation-delay: 0.3s;
  height: 50%;
}

@keyframes bars {
  0%,
  100% {
    transform: scaleY(0.3);
  }
  50% {
    transform: scaleY(1);
  }
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
}

.btn-icon {
  background: var(--primary);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 10px var(--primary-glow);
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon svg,
.btn-icon-sub svg {
  width: 20px;
  height: 20px;
  display: block;
}

.btn-icon-sub svg {
  width: 16px;
  height: 16px;
}

.btn-icon:hover {
  transform: scale(1.1);
}

.btn-icon-sub {
  background: transparent;
  border: 1px solid var(--glass-border);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.btn-icon-sub:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.btn-icon-sub.active {
  background: var(--primary-glow);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 10px var(--primary-glow);
}

.progress-container {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
}

.progress {
  width: 0%;
  height: 100%;
  background: linear-gradient(to right, var(--primary), var(--secondary));
}

#time-display {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 80px;
}

/* Tabs System */
.tabs-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding-bottom: 15px;
  justify-content: center; /* Căn giữa các tab */
}

.tab-btn {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.3s;
  font-size: 0.9rem;
}

#tab-content-area {
  flex: 1;
}

.exercise-card {
  padding: 1.5rem;
}

@container (max-width: 600px) {
  .exercise-card {
    padding: 0.8rem;
  }
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 15px var(--primary-glow);
}

.tab-btn .score-badge {
  margin-left: 8px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Question List */
.question-item {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--glass-border);
}

.question-item:last-child {
  border-bottom: none;
}

.question-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: block;
}

.q-num {
  color: var(--primary);
  display: inline-block;
  min-width: 25px;
  margin-right: 5px;
}

/* Questions Styles */
.exercise-body {
  margin-top: 1rem;
  font-size: 1.1rem;
  line-height: 1.6;
  line-height: 1.6;
  padding-bottom: 2rem;
}

/* Tùy chỉnh thanh cuộn cho mượt và đẹp (Webkit) */
.exercise-body::-webkit-scrollbar {
  width: 10px;
}
.exercise-body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
.exercise-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.exercise-body::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
  background-clip: border-box;
}

/* MCQ Options */
.options-grid {
  display: grid;
  gap: 12px;
  margin-top: 1.5rem;
}

.option-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  padding: 16px 20px;
  border-radius: 12px;
  color: var(--text);
  text-align: left;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.option-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
}

.option-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 4px 15px var(--primary-glow);
}

/* Feedback Styles */
.option-btn.correct {
  background: var(--success) !important;
  border-color: var(--success) !important;
  color: white !important;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4) !important;
}

.option-btn.incorrect {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: white !important;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4) !important;
}

.gap-input.correct {
  color: var(--success) !important;
  border-bottom-color: var(--success) !important;
}

.gap-input.incorrect {
  color: var(--danger) !important;
  border-bottom-color: var(--danger) !important;
}

/* Dictation Styles */
.dictation-item {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.hint-box {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
  font-style: italic;
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 12px;
  border-radius: 8px;
  display: inline-block;
}

.dictation-textarea {
  width: 100%;
  min-height: 80px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: var(--text);
  padding: 1rem;
  font-family: inherit;
  font-size: 1.1rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: all 0.3s;
}

.dictation-textarea:focus {
  border-color: var(--primary);
  background: rgba(30, 41, 59, 0.8);
}

.dictation-feedback {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
}

.perc-badge {
  font-size: 0.9rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
}

.perc-badge.excellent {
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}
.perc-badge.good {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}
.perc-badge.low {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* Gap Filling */
.gap-input {
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--text-muted);
  color: var(--primary);
  font-size: inherit;
  font-weight: 600;
  width: 100px;
  text-align: center;
  outline: none;
  transition: border-color 0.3s;
}

.gap-input:focus {
  border-color: var(--primary);
}

/* Actions Top Bar */
.exercise-actions-top {
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 1.5rem;
  padding-bottom: 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

@container (max-width: 700px) {
  .exercise-actions-top {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
  }

  .exercise-actions-top > div,
  .exercise-actions-bottom {
    display: flex;
    justify-content: space-between;
    width: 100%;
  }

  .btn-primary,
  .btn-orange,
  .btn-secondary,
  .btn-green {
    padding: 8px 4px;
    font-size: 0.85rem;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .tab-score-display {
    text-align: center;
    width: 100%;
    margin-bottom: 5px;
  }
}

.exercise-actions-bottom {
  margin-top: 2rem;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--glass-border);
  padding-top: 1rem;
}

.tab-score-display {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0;
  transform: translateX(10px);
  transition: all 0.4s ease;
}

.tab-score-display.show {
  opacity: 1;
  transform: translateX(0);
}

.tab-score-display .highlight {
  color: var(--primary);
  font-size: 1.4rem;
  font-weight: 800;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 10px 20px var(--primary-glow);
  transition: all 0.3s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px var(--primary-glow);
}

.btn-orange {
  background: #f97316;
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(249, 115, 22, 0.4);
  transition: all 0.3s;
}

.btn-orange:hover {
  background: #ea580c;
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(249, 115, 22, 0.5);
}

.btn-green {
  background: var(--success);
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(16, 185, 129, 0.4);
  transition: all 0.3s;
}

.btn-green:hover {
  background: #059669; /* Darker emerald */
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(16, 185, 129, 0.5);
}

/* Loading Spinner */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 100px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--glass-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85); /* Darker, no blur for performance */
  backdrop-filter: none;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  max-width: 500px;
  width: 90%;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header h3 {
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 1rem;
}

.modal-body p {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 2rem;
}

.modal-footer {
  display: flex;
  justify-content: center;
  gap: 15px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  padding: 14px 28px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.playlist-container {
  padding-bottom: 160px;
}

.support-card {
  max-width: 600px;
  margin: 2rem auto;
  cursor: default;
  padding: 2.5rem;
}

@media (max-width: 600px) {
  .support-card {
    padding: 1.2rem;
    margin: 1rem;
  }
}
