/* ============================================================
   RESPONSIVE — Website Học Tập Đại Học
   ============================================================ */

/* ---------- Laptop (≤1199px) ---------- */
@media (max-width: 1199px) {
  .layout-with-toc {
    grid-template-columns: 1fr;
  }

  .toc {
    display: none;
  }

  .grid-4 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Tablet (≤991px) ---------- */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: var(--z-sidebar);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .app-content {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: flex;
  }

  .main {
    padding: var(--space-5) var(--space-6);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .page-title {
    font-size: var(--text-2xl);
  }

  .lesson-title {
    font-size: var(--text-2xl);
  }

  .playground-editors {
    flex-direction: column;
  }

  .playground-editor-pane {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    min-height: 150px;
  }

  .quiz-results-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .true-false-options {
    gap: var(--space-3);
  }
}

/* ---------- Mobile (≤767px) ---------- */
@media (max-width: 767px) {
  :root {
    --space-6: 1.25rem;
    --space-8: 1.5rem;
    --text-3xl: 1.953rem;
    --text-4xl: 2.441rem;
  }

  .header {
    padding: 0 var(--space-4);
    height: 56px;
  }

  .header-title {
    font-size: var(--text-base);
  }

  .main {
    padding: var(--space-4);
  }

  .page-title {
    font-size: var(--text-xl);
  }

  .page-subtitle {
    font-size: var(--text-sm);
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .grid-auto-fit,
  .grid-auto-fill {
    grid-template-columns: 1fr;
  }

  /* Lesson */
  .lesson-title {
    font-size: var(--text-xl);
  }

  .lesson-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .lesson-nav {
    flex-direction: column;
    gap: var(--space-3);
  }

  .lesson-nav-btn {
    max-width: 100%;
    width: 100%;
  }

  /* Section titles */
  .section-title {
    font-size: var(--text-lg);
  }

  .lesson-section-title {
    font-size: var(--text-lg);
  }

  /* Cards */
  .card {
    padding: var(--space-4);
  }

  .question-card {
    padding: var(--space-5);
  }

  /* Buttons */
  .btn-lg {
    width: 100%;
  }

  /* Quiz */
  .quiz-results-stats {
    grid-template-columns: 1fr;
  }

  .true-false-options {
    flex-direction: column;
  }

  .flashcard-container {
    max-width: 100%;
  }

  .flashcard {
    min-height: 220px;
  }

  /* Concept Flow */
  .concept-flow {
    flex-wrap: wrap;
    justify-content: center;
  }

  /* Toast */
  .toast-container {
    left: var(--space-4);
    right: var(--space-4);
  }

  .toast {
    min-width: auto;
    max-width: 100%;
  }

  /* Breadcrumb */
  .breadcrumb {
    display: none;
  }

  /* Progress Ring */
  .progress-ring-text {
    font-size: var(--text-lg);
  }

  /* Stat cards */
  .stat-card-value {
    font-size: var(--text-2xl);
  }

  /* Modal */
  .modal {
    max-height: 95vh;
    margin: var(--space-3);
    border-radius: var(--radius-lg);
  }

  .modal-header {
    padding: var(--space-4);
  }

  .modal-body {
    padding: var(--space-4);
  }

  .modal-footer {
    padding: var(--space-3) var(--space-4);
    flex-direction: column;
  }

  .modal-footer .btn {
    width: 100%;
  }

  /* Search */
  .search-shortcut {
    display: none;
  }

  /* Playground */
  .playground {
    height: auto;
    min-height: auto;
  }

  .playground-editors {
    flex-direction: column;
    max-height: none;
  }

  .playground-editor-pane {
    min-height: 120px;
  }

  .playground-textarea {
    min-height: 120px;
  }

  .inline-playground .playground-editors {
    max-height: none;
  }

  /* Bottom Nav visible on mobile */
  .mobile-bottom-nav {
    display: flex;
  }

  body {
    padding-bottom: 64px;
  }
}

/* ---------- Small Mobile (≤480px) ---------- */
@media (max-width: 480px) {
  .header-right .btn span {
    display: none;
  }

  .tabs {
    gap: 0;
  }

  .tab {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
  }

  .chapter-card-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }

  .quiz-dots {
    flex-wrap: wrap;
    justify-content: center;
  }

  .quiz-nav {
    flex-direction: column;
    gap: var(--space-4);
    align-items: stretch;
  }
}

/* ---------- Print ---------- */
@media print {
  .sidebar,
  .sidebar-overlay,
  .header,
  .toc,
  .lesson-nav,
  .mark-complete,
  .playground,
  .inline-playground,
  .quick-quiz,
  .toast-container {
    display: none !important;
  }

  .app-content {
    margin-left: 0 !important;
  }

  .main {
    padding: 0;
  }

  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }

  .card {
    border: 1px solid #ccc;
    box-shadow: none;
    break-inside: avoid;
  }

  a { color: #000; text-decoration: underline; }
}

/* ---------- High Contrast ---------- */
@media (prefers-contrast: high) {
  :root {
    --border-color: var(--color-neutral-400);
    --border-color-strong: var(--color-neutral-600);
    --text-secondary: var(--color-neutral-800);
    --text-tertiary: var(--color-neutral-700);
  }

  .btn-outline {
    border-width: 3px;
  }

  .answer-option {
    border-width: 3px;
  }
}
