/* ═══════════════════════════════════════════════════════════════════════════
   LMS — Mobile Responsive CSS
   IMPORTANT: This file contains ONLY media-query-scoped rules.
              Desktop styles are NOT modified here.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 0. GLOBAL MOBILE BASE ──────────────────────────────────────────────── */

/* Prevent horizontal overflow globally */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

/* Ensure images and embeds never overflow their container */
img, video, iframe, embed, object {
  max-width: 100%;
}

/* Minimum tap-target size for interactive elements (touch accessibility) */
@media (max-width: 768px) {
  a, button, .btn, [role="button"],
  .sidebar-nav-item, .list-group-item-action {
    min-height: 44px;
  }

  /* Make form inputs full-width by default on mobile */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px !important; /* Prevents iOS zoom on focus */
  }
}


/* ── 1. NAVBAR ──────────────────────────────────────────────────────────── */

@media (max-width: 991.98px) {
  .navbar-custom {
    padding: 0.65rem 0.85rem;
  }

  .navbar-custom .container {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
  }

  /* Brand Logo & Text on Mobile */
  .navbar-brand {
    font-size: 1.15rem !important;
    display: flex !important;
    align-items: center !important;
    margin-right: 0 !important;
    max-width: calc(100% - 60px) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .navbar-brand i,
  .navbar-brand img {
    height: 32px !important;
    width: 32px !important;
    flex-shrink: 0;
  }

  .navbar-brand span {
    display: inline-block !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Hamburger Toggle Button */
  .navbar-toggler {
    padding: 6px 10px !important;
    font-size: 1.15rem !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    color: #fff !important;
    margin-left: auto;
  }

  .navbar-toggler:focus {
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.4) !important;
    outline: none !important;
  }

  /* Expanded Menu Container (drops below brand and toggler) */
  .navbar-collapse {
    flex-basis: 100% !important;
    width: 100% !important;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 16px 14px;
    margin-top: 10px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
  }

  /* Search Input in Collapsed Menu */
  .navbar-collapse form.d-flex {
    max-width: 100% !important;
    width: 100% !important;
    margin: 4px 0 12px 0 !important;
  }

  .navbar-collapse form.d-flex .form-control {
    width: 100% !important;
    font-size: 14px !important;
  }

  /* Navigation Links */
  .navbar-collapse .navbar-nav {
    margin-bottom: 8px !important;
    gap: 2px;
  }

  .navbar-collapse .navbar-nav .nav-item {
    width: 100%;
  }

  .navbar-collapse .navbar-nav .nav-link {
    padding: 10px 14px !important;
    margin: 0 !important;
    border-radius: 8px;
    font-size: 0.95rem;
    display: block;
    color: #e2e8f0 !important;
    font-weight: 500;
  }

  .navbar-collapse .navbar-nav .nav-link:hover,
  .navbar-collapse .navbar-nav .nav-link.active {
    background: rgba(56, 189, 248, 0.1);
    color: #38bdf8 !important;
    transform: none !important;
  }

  /* Auth & Language Switcher Group */
  .navbar-collapse .d-flex.align-items-center.gap-2 {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 4px;
  }

  .navbar-collapse .dropdown {
    width: 100%;
    margin-left: 0 !important;
  }

  .navbar-collapse .dropdown > button {
    width: 100%;
    justify-content: center;
    padding: 9px 16px;
    font-size: 0.9rem;
    border-radius: 50rem;
  }

  .navbar-collapse .dropdown-menu {
    width: 100%;
    margin-top: 4px;
  }

  .navbar-collapse .btn-outline-custom,
  .navbar-collapse .btn-primary-custom {
    width: 100%;
    text-align: center;
    margin: 0 !important;
    padding: 9px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
  }
}

@media (max-width: 575.98px) {
  .navbar-brand {
    font-size: 1.05rem !important;
  }

  .navbar-brand i {
    font-size: 1.25rem !important;
  }

  .navbar-brand span {
    font-size: 1.05rem !important;
  }
}


/* ── 2. HERO SECTION ────────────────────────────────────────────────────── */

@media (max-width: 991.98px) {
  .hero-section {
    padding: 3.5rem 0 4rem 0;
  }
  .hero-slider-wrapper {
    aspect-ratio: 16 / 9;
    max-height: 380px;
    margin-top: 0.5rem;
  }
  .hero-slide-caption {
    padding: 1.25rem 1.4rem;
  }
  .hero-slide-title {
    font-size: 1.2rem;
  }
}

@media (max-width: 767.98px) {
  .hero-section {
    padding: 2.5rem 0 3rem 0;
    text-align: center;
  }

  .hero-title {
    font-size: 2rem !important;
    line-height: 1.2;
    margin-bottom: 1rem;
  }

  .hero-subtitle {
    font-size: 1rem;
    margin-bottom: 1.5rem;
    max-width: 100%;
  }

  /* Hero search bar: stack button below input on small screens */
  .hero-section .bg-white.p-2.rounded-pill .input-group {
    flex-wrap: wrap;
    border-radius: 1rem !important;
  }

  .hero-section .bg-white.p-2.rounded-pill {
    border-radius: 1rem !important;
    padding: 0.75rem !important;
  }

  .hero-section .btn-primary-custom[type="submit"] {
    width: 100%;
    border-radius: 50rem !important;
    margin-top: 0.5rem;
  }

  .hero-section .input-group .input-group-text {
    border-radius: 50rem 0 0 50rem;
  }

  /* CTA buttons */
  .hero-content .d-flex.flex-wrap.align-items-center.gap-3 {
    justify-content: center;
  }

  .hero-content .btn-primary-custom.btn-lg,
  .hero-content .btn-outline-custom.btn-lg {
    width: 100%;
    text-align: center;
  }

  /* Hero badge announcement */
  .hero-content .d-inline-flex {
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
  }

  /* Hero slider on tablet/mobile */
  .hero-slider-wrapper {
    aspect-ratio: 16 / 10;
    max-height: 320px;
  }
  .hero-slide-caption {
    padding: 1rem 1.15rem;
    text-align: left;
  }
  .hero-slide-title {
    font-size: 1.05rem;
  }
  .hero-slide-desc {
    font-size: 0.8rem;
    max-width: 100%;
  }
}

@media (max-width: 575.98px) {
  .hero-title {
    font-size: 1.7rem !important;
  }

  /* Stat badges: ensure 2 per row */
  .hero-section .col-6 .stat-badge {
    padding: 0.75rem 0.75rem;
  }

  .stat-number {
    font-size: 1.4rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  /* Hero slider small mobile */
  .hero-slider-wrapper {
    border-radius: 1rem;
    max-height: 250px;
  }
  .hero-slider-arrow {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
  }
  .hero-slider-prev {
    left: 8px;
  }
  .hero-slider-next {
    right: 8px;
  }
  .hero-slide-caption {
    padding: 0.75rem 0.85rem;
  }
  .hero-slide-title {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
  }
  .hero-slide-desc {
    display: none;
  }
  .hero-slide-btn {
    padding: 0.35rem 0.8rem;
    font-size: 0.75rem;
  }
  .hero-slider-dots {
    bottom: 8px;
    right: 10px;
  }
}


/* ── 3. SECTION TITLES & SPACING ────────────────────────────────────────── */

@media (max-width: 767.98px) {
  .section-padding {
    padding: 3rem 0;
  }

  .section-title-wrapper {
    margin-bottom: 2rem;
  }

  .section-main-title {
    font-size: 1.65rem;
  }
}

@media (max-width: 575.98px) {
  .section-padding {
    padding: 2.25rem 0;
  }

  .section-main-title {
    font-size: 1.4rem;
  }
}


/* ── 4. COURSE CARDS ────────────────────────────────────────────────────── */

@media (max-width: 575.98px) {
  /* Full width on very small screens */
  .course-card .course-card-body {
    padding: 1.1rem;
  }

  .course-thumb-container {
    height: 170px;
  }

  /* Course meta — allow wrapping */
  .course-meta {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Course action buttons */
  .course-card .d-flex.gap-2 {
    gap: 0.4rem !important;
  }
}


/* ── 5. CATEGORY CARDS ──────────────────────────────────────────────────── */

@media (max-width: 575.98px) {
  .category-card {
    padding: 1.25rem 1rem;
  }

  .category-icon {
    width: 50px;
    height: 50px;
    font-size: 1.3rem;
    margin-bottom: 0.85rem;
  }
}


/* ── 6. COURSE LIST PAGE ────────────────────────────────────────────────── */

@media (max-width: 767.98px) {
  /* Filter bar: ensure label text in select doesn't overflow */
  .course-list-filter-bar .form-select,
  .course-list-filter-bar .form-control {
    width: 100%;
  }

  /* Hero banner on course list */
  .bg-dark.text-white.py-5.mb-5 h1.display-4 {
    font-size: 2rem !important;
  }

  .bg-dark.text-white.py-5.mb-5 p.lead {
    font-size: 1rem;
  }
}


/* ── 7. COURSE DETAIL PAGE ──────────────────────────────────────────────── */

@media (max-width: 991.98px) {
  /* Hero: enrollment card comes first on mobile (order flip) */
  .course-detail-hero .col-lg-8 {
    order: 2;
  }

  .course-detail-hero .col-lg-4 {
    order: 1;
  }

  /* Instructor sidebar: remove sticky on mobile to avoid scroll trapping */
  .col-lg-4 > .bg-white.sticky-top {
    position: relative !important;
    top: auto !important;
    z-index: auto !important;
  }
}

@media (max-width: 767.98px) {
  /* Hero heading */
  .bg-dark.text-white.py-5 h1.display-5 {
    font-size: 1.65rem !important;
  }

  .bg-dark.text-white.py-5 p.lead {
    font-size: 0.95rem;
  }

  /* Course meta flex row in hero — allow wrapping */
  .bg-dark .d-flex.flex-wrap.align-items-center.gap-4 {
    gap: 0.75rem !important;
  }

  /* Lesson list items: flex wrap for small screens */
  .list-group-item.d-flex.align-items-center.justify-content-between {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Accordion section badge — prevent overflow */
  .accordion-button .badge.ms-auto.me-3 {
    margin-right: 0.5rem !important;
    margin-left: auto !important;
  }
}

@media (max-width: 575.98px) {
  .bg-dark.text-white.py-5 h1.display-5 {
    font-size: 1.45rem !important;
  }

  /* Enrollment card padding */
  .card-body.p-4 {
    padding: 1.25rem !important;
  }

  /* Review section heading + badge row */
  .bg-white .d-flex.flex-wrap.align-items-center.justify-content-between {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem;
  }
}


/* ── 8. STUDENT LEARN PAGE ──────────────────────────────────────────────── */

@media (max-width: 991.98px) {
  /* Lock Header to the top on mobile */
  .navbar.sticky-top,
  .navbar-custom {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 1050 !important;
  }

  /* Fix the FULL video workspace section at the top of mobile screen below header */
  .learn-main-col {
    order: 1 !important;
    position: fixed !important;
    top: 56px !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    z-index: 1040 !important;
    padding: 6px 10px 4px 10px !important;
    background: #f8fafc !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
    margin-bottom: 0 !important;
  }

  .learn-main-col .learn-workspace-card {
    margin-bottom: 0 !important;
    border-radius: 14px !important;
    padding: 10px 10px !important;
  }

  .learn-main-col .learn-workspace-card .tab-content {
    max-height: 90px;
    overflow-y: auto;
    scrollbar-width: thin;
  }

  /* The lower syllabus section: independent scroll container from below video to bottom */
  .learn-sidebar-col {
    order: 2 !important;
    position: fixed !important;
    top: 420px; /* Fallback until dynamic JS sets exact bottom of video */
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    z-index: 1030 !important;
    padding: 6px 10px 40px 10px !important;
    background: #f8fafc !important;
    margin: 0 !important;
  }

  .learn-sidebar-col > div,
  .learn-sidebar-card {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
    border-radius: 1rem !important;
    border: 1px solid #e2e8f0 !important;
    margin-bottom: 2rem !important;
  }

  #sidebarSyllabus,
  .learn-syllabus-scroll-area {
    overflow-y: visible !important;
    max-height: none !important;
    height: auto !important;
  }

  /* Full-width footer inside mobile scroll area */
  .learn-sidebar-col .footer-custom {
    margin-left: -10px !important;
    margin-right: -10px !important;
    margin-top: 1.5rem !important;
    margin-bottom: 0 !important;
    padding: 2.5rem 1rem 1.5rem 1rem !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
  }
}

@media (max-width: 767.98px) {
  /* Learn page wrapper: reduce huge outer padding */
  .learn-page-container {
    padding: 8px 8px 24px 8px !important;
  }

  .learn-workspace-card {
    padding: 14px 12px !important;
    border-radius: 14px !important;
    margin-bottom: 14px !important;
  }

  .learn-sidebar-card {
    padding: 14px 12px !important;
    border-radius: 14px !important;
  }

  .learn-video-box {
    border-radius: 10px !important;
    margin-bottom: 12px !important;
    /* Do NOT set overflow:hidden — it clips touch events on iOS */
  }

  .learn-video-box iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    z-index: 1 !important;
    pointer-events: auto !important;
    touch-action: auto !important;
    -webkit-touch-callout: none;
  }

  /* Video Player Brand Icon Badge: completely covers Google Drive popout icon on mobile */
  .video-brand-badge,
  .gdrive-popout-cover {
    top: 0px !important;
    right: 0px !important;
    left: auto !important;
    bottom: auto !important;
    width: 62px !important;
    height: 62px !important;
    border-radius: 0 10px 0 10px !important;
    border: 1.5px solid rgba(230, 211, 153, 0.45) !important;
    border-top: none !important;
    border-right: none !important;
    pointer-events: auto !important;
    cursor: default !important;
    background-color: #0f172a !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.8) !important;
    padding: 7px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 25 !important;
  }

  .video-brand-badge img,
  .gdrive-popout-cover img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    border-radius: 6px !important;
  }

  /* Lesson header banner on mobile */
  .learn-lesson-header {
    margin-bottom: 10px !important;
    padding-bottom: 8px !important;
    gap: 6px !important;
  }

  .learn-lesson-title {
    font-size: 1.1rem !important;
    line-height: 1.35 !important;
  }

  /* ── Action Bar: 3-column [Previous | Center Complete | Next] ─── */
  .learn-action-bar {
    padding: 10px 10px !important;
    border-radius: 12px !important;
    margin-bottom: 14px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
  }

  .learn-prev-btn-box {
    flex: 0 0 auto !important;
    display: flex !important;
    justify-content: flex-start !important;
  }

  .learn-action-status {
    text-align: center !important;
    flex: 1 1 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .learn-next-btn-box {
    flex: 0 0 auto !important;
    display: flex !important;
    justify-content: flex-end !important;
  }

  .learn-action-status .badge {
    font-size: 0.8rem !important;
    padding: 6px 12px !important;
    white-space: nowrap !important;
  }

  .learn-nav-btn {
    font-size: 0.82rem !important;
    padding: 8px 12px !important;
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
  }

  /* Hide text labels on very small screens, keep icons */
  .btn-label {
    display: inline !important;
  }

  /* Tabs on mobile: smooth horizontal touch-scrollable strip */
  .learn-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-bottom: 1px solid #e2e8f0 !important;
    gap: 4px !important;
    margin-bottom: 14px !important;
    padding-bottom: 0 !important;
  }

  .learn-tabs::-webkit-scrollbar {
    display: none;
  }

  .learn-tabs .nav-link {
    font-size: 0.82rem !important;
    padding: 8px 12px !important;
    white-space: nowrap !important;
    border-radius: 6px 6px 0 0 !important;
  }

  .learn-tabs .nav-link i {
    font-size: 0.82rem !important;
    margin-right: 4px !important;
  }

  /* Certificate / completion banners on mobile */
  .alert.d-flex.flex-wrap {
    flex-direction: column;
    gap: 0.75rem;
    padding: 12px !important;
    border-radius: 12px !important;
  }

  .alert .mt-2.mt-sm-0 {
    width: 100%;
  }

  .alert .mt-2.mt-sm-0 .btn {
    width: 100%;
  }
}

@media (max-width: 360px) {
  .learn-page-container {
    padding: 6px 4px 20px 4px !important;
  }

  .learn-workspace-card {
    padding: 10px 8px !important;
    border-radius: 12px !important;
  }

  .learn-lesson-title {
    font-size: 0.95rem !important;
  }

  /* On truly tiny screens, hide button text and show only icons */
  .learn-nav-btn .btn-label {
    display: none !important;
  }

  .learn-nav-btn {
    font-size: 0.85rem !important;
    padding: 8px 10px !important;
  }

  .learn-action-bar {
    grid-template-columns: auto auto auto !important;
    gap: 4px !important;
  }
}


/* ── 9. QUIZ PAGE ───────────────────────────────────────────────────────── */

@media (max-width: 767.98px) {
  /* Quiz header: stack timer below title */
  .bg-white .d-flex.flex-wrap.align-items-center.justify-content-between.gap-3.border-bottom {
    flex-direction: column;
    align-items: flex-start !important;
  }

  #quiz-timer-box {
    align-self: stretch;
    justify-content: center;
    width: 100%;
  }

  /* Quiz submit button */
  .text-end.mt-4 {
    text-align: center !important;
  }

  #submit-quiz-btn {
    width: 100%;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Quiz question cards */
  .container.py-5 {
    padding-top: 2rem !important;
    padding-bottom: 2rem !important;
  }
}

@media (max-width: 575.98px) {
  /* Quiz heading */
  .bg-white.p-4.p-md-5 h1.h3 {
    font-size: 1.3rem;
  }

  /* Question card padding */
  .card.border.rounded-3.p-4 {
    padding: 1rem !important;
  }

  /* Form check items: larger touch targets */
  .form-check.p-3.bg-white.border.rounded-3 {
    padding: 0.75rem 1rem !important;
  }

  .form-check-input {
    width: 1.15em;
    height: 1.15em;
    margin-top: 0.2em;
  }
}


/* ── 10. AUTH PAGES (Login / Register) ──────────────────────────────────── */

@media (max-width: 575.98px) {
  /* Auth card padding */
  .contact-card {
    padding: 1.5rem;
    border-radius: 1rem;
  }

  /* Auth headings */
  .contact-card h1,
  .contact-card h2,
  .contact-card h3 {
    font-size: 1.5rem;
  }
}


/* ── 11. FOOTER ─────────────────────────────────────────────────────────── */

@media (max-width: 767.98px) {
  .footer-custom {
    padding: 3rem 0 1.5rem 0;
  }

  /* Stack all footer columns */
  .footer-custom .col-lg-4,
  .footer-custom .col-lg-2,
  .footer-custom .col-lg-3 {
    margin-bottom: 1.5rem;
  }
}

@media (max-width: 575.98px) {
  .footer-custom {
    padding: 2rem 0 1rem 0;
  }

  .footer-brand {
    font-size: 1.2rem;
  }

  /* Newsletter input group */
  .footer-custom .input-group {
    flex-wrap: nowrap;
  }

  .footer-custom .input-group .form-control {
    min-width: 0;
  }
}


/* ── 12. DASHBOARD — COMMON ─────────────────────────────────────────────── */

@media (max-width: 991.98px) {
  .dashboard-wrapper {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  .dashboard-main {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    min-width: 0 !important;
  }

  /* Topbar padding */
  .dashboard-topbar {
    padding: 10px 14px !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  /* Topbar title */
  .topbar-title {
    font-size: 15px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
    margin: 0 !important;
  }

  /* Topbar actions */
  .topbar-actions {
    gap: 6px !important;
    flex-shrink: 0 !important;
  }

  /* Dashboard content padding */
  .dashboard-content {
    padding: 14px 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* Student profile header card */
  .dash-student-header-card {
    padding: 18px 14px !important;
    border-radius: 14px !important;
  }

  /* Compact grid gutters so 2x2 stat cards fit cleanly */
  .dashboard-content .row.g-4 {
    --bs-gutter-x: 10px !important;
    --bs-gutter-y: 10px !important;
    margin-left: -5px !important;
    margin-right: -5px !important;
  }

  .dashboard-content .row.g-4 > * {
    padding-left: 5px !important;
    padding-right: 5px !important;
  }
}

@media (max-width: 575.98px) {
  .dashboard-topbar {
    padding: 8px 10px !important;
  }

  /* Topbar title */
  .topbar-title {
    font-size: 14px !important;
    max-width: 140px;
  }

  /* Topbar action buttons */
  .topbar-btn {
    width: 32px !important;
    height: 32px !important;
    font-size: 12px !important;
  }

  /* Dashboard content padding */
  .dashboard-content {
    padding: 10px 8px !important;
  }
}


/* ── 13. DASHBOARD — STAT CARDS ─────────────────────────────────────────── */

@media (max-width: 991.98px) {
  .stat-card {
    padding: 14px 12px !important;
    border-radius: 12px !important;
    box-sizing: border-box !important;
  }

  .stat-card-value {
    font-size: 22px !important;
    letter-spacing: -0.5px;
    margin-bottom: 2px !important;
  }

  .stat-card-icon {
    width: 36px !important;
    height: 36px !important;
    font-size: 14px !important;
    margin-bottom: 8px !important;
  }

  .stat-card-label {
    font-size: 11px !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    overflow: hidden !important;
    display: block !important;
  }
}

@media (max-width: 360px) {
  .stat-card {
    padding: 10px 8px !important;
  }

  .stat-card-value {
    font-size: 18px !important;
  }

  .stat-card-label {
    font-size: 10px !important;
  }

  .stat-card-icon {
    width: 30px !important;
    height: 30px !important;
    font-size: 12px !important;
    margin-bottom: 6px !important;
  }
}


/* ── 14. DASHBOARD — CARD HEADERS ───────────────────────────────────────── */

@media (max-width: 767.98px) {
  /* Card header: wrap title and button */
  .dash-card-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px !important;
  }

  .dash-card-body {
    padding: 12px !important;
  }
}

@media (max-width: 575.98px) {
  .dash-card-header {
    padding: 12px 14px !important;
  }

  .dash-card-title {
    font-size: 14px !important;
  }
}


/* ── 15. DASHBOARD — COURSE PROGRESS CARDS ──────────────────────────────── */

@media (max-width: 575.98px) {
  .course-progress-card {
    flex-direction: column;
    gap: 12px;
    padding: 14px;
  }

  .course-progress-thumbnail,
  .course-progress-thumbnail-placeholder {
    width: 100% !important;
    height: 120px !important;
    border-radius: 8px;
  }
}


/* ── 16. DASHBOARD — TABLES ─────────────────────────────────────────────── */

@media (max-width: 991.98px) {
  /* Wrap table containers for horizontal scroll */
  .dash-card .table-responsive,
  .dash-card [style*="overflow-x:auto"],
  .dash-card [style*="overflow-x: auto"] {
    -webkit-overflow-scrolling: touch;
  }

  /* Ensure tables have a minimum width for horizontal scrolling to activate */
  .dash-table {
    min-width: 480px;
  }
}

@media (max-width: 575.98px) {
  .dash-table thead th {
    padding: 10px 10px;
    font-size: 10px;
  }

  .dash-table tbody td {
    padding: 10px 10px;
    font-size: 12px;
  }
}


/* ── 17. DASHBOARD — FORM SECTIONS ─────────────────────────────────────── */

@media (max-width: 767.98px) {
  .form-section {
    padding: 20px 16px;
  }

  .avatar-upload-area {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

@media (max-width: 575.98px) {
  .form-section {
    padding: 16px 12px;
  }

  /* Form buttons */
  .form-section .btn-dash-primary,
  .form-section .btn-dash-danger {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}


/* ── 18. DASHBOARD — BUTTONS & BADGES ──────────────────────────────────── */

@media (max-width: 575.98px) {
  /* Prevent badge text wrapping */
  .dash-badge {
    white-space: nowrap;
    font-size: 10px;
    padding: 3px 8px;
  }

  /* Ensure dash outline buttons don't overflow */
  .btn-dash-outline {
    font-size: 12px !important;
    padding: 6px 12px !important;
    white-space: nowrap;
  }
}


/* ── 19. DASHBOARD — NOTIFICATION ITEMS ────────────────────────────────── */

@media (max-width: 575.98px) {
  .notif-item {
    padding: 12px 16px;
    gap: 10px;
  }

  .notif-icon {
    width: 30px;
    height: 30px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .notif-message {
    font-size: 12px;
  }
}


/* ── 20. DASHBOARD — CERTIFICATE CARDS ─────────────────────────────────── */

@media (max-width: 575.98px) {
  .cert-card {
    padding: 16px;
  }

  .cert-card-icon {
    font-size: 28px;
    margin-bottom: 8px;
  }
}


/* ── 21. ADMIN PANEL SPECIFICS ──────────────────────────────────────────── */

@media (max-width: 991.98px) {
  /* Admin KPI grid: force 2 cols min on tablet */
  .admin-kpi-row {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
    gap: 12px !important;
  }
}

@media (max-width: 575.98px) {
  /* Admin KPI: 2 cols on phones */
  .admin-kpi-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  /* Admin topbar: hide the Super Admin badge on smallest screens */
  .topbar-actions .dash-badge.danger {
    display: none;
  }
}


/* ── 22. ADMIN MANAGE TABLES ────────────────────────────────────────────── */

@media (max-width: 991.98px) {
  /* All admin tables need a scrollable wrapper */
  .dashboard-content .dash-table {
    min-width: 560px;
    display: table;
  }
}


/* ── 23. MODALS ─────────────────────────────────────────────────────────── */

@media (max-width: 575.98px) {
  /* Modals should be nearly full screen on mobile */
  .modal-dialog {
    margin: 0.5rem auto;
    max-width: calc(100vw - 1rem);
  }

  .modal-dialog.modal-lg {
    max-width: calc(100vw - 1rem);
  }

  /* Modal content padding */
  .modal-body.p-4,
  .modal-body.p-md-5 {
    padding: 1rem !important;
  }

  .modal-header {
    padding: 0.85rem 1rem;
  }

  .modal-footer {
    padding: 0.85rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Modal action buttons */
  .modal-footer .btn {
    flex: 1;
    min-width: 120px;
  }
}


/* ── 24. PAYMENT PAGES ──────────────────────────────────────────────────── */

@media (max-width: 767.98px) {
  /* Payment checkout / success page sections */
  .container.py-5 .bg-white.p-4.p-md-5 {
    padding: 1.25rem !important;
  }
}

@media (max-width: 575.98px) {
  /* Payment action buttons */
  .container.py-5 .btn-lg {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  /* Payment info rows */
  .container.py-5 .d-flex.justify-content-between {
    flex-wrap: wrap;
    gap: 0.25rem;
  }
}


/* ── 25. STUDENT PROFILE / FORMS ────────────────────────────────────────── */

@media (max-width: 767.98px) {
  /* Profile edit grid: stack columns */
  .row.g-4 .col-md-6,
  .row.g-3 .col-md-6 {
    /* Bootstrap already handles this; explicit override for edge cases */
    width: 100%;
  }
}


/* ── 26. WISHLIST & CERTIFICATE CARDS ───────────────────────────────────── */

@media (max-width: 575.98px) {
  .wishlist-card-img,
  .wishlist-card-img-placeholder {
    height: 130px;
  }

  .wishlist-card-body {
    padding: 12px;
  }
}


/* ── 27. ACCORDION (FAQ & Course Syllabus) ──────────────────────────────── */

@media (max-width: 575.98px) {
  .accordion-button {
    font-size: 0.9rem;
    padding: 0.85rem 1rem;
  }

  .accordion-body {
    font-size: 0.875rem;
    padding: 0.85rem 1rem;
  }
}


/* ── 28. ALERTS & FLASH MESSAGES ────────────────────────────────────────── */

@media (max-width: 575.98px) {
  .alert {
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
  }

  /* Fix alert icon + text alignment */
  .alert.d-flex {
    align-items: flex-start !important;
  }
}


/* ── 29. EMPTY STATES ───────────────────────────────────────────────────── */

@media (max-width: 575.98px) {
  .empty-state {
    padding: 40px 16px;
  }

  .empty-state-icon {
    font-size: 40px;
  }

  .empty-state-title {
    font-size: 16px;
  }
}


/* ── 30. SEARCH PAGE ────────────────────────────────────────────────────── */

@media (max-width: 767.98px) {
  .search-results-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem;
  }
}


/* ── 31. INSTRUCTOR DASHBOARD ───────────────────────────────────────────── */

@media (max-width: 767.98px) {
  /* Instructor course management: action buttons */
  .dash-card .d-flex.gap-2.flex-wrap {
    flex-direction: column;
  }

  .dash-card .d-flex.gap-2.flex-wrap .btn {
    width: 100%;
  }
}

@media (max-width: 575.98px) {
  /* Instructor analytics chart wrapper */
  .dash-card-body canvas {
    max-height: 220px;
  }
}


/* ── 32. PAGINATION ─────────────────────────────────────────────────────── */

@media (max-width: 575.98px) {
  /* Pagination: ensure it wraps rather than overflows */
  .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
  }

  .page-link {
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
  }
}


/* ── 33. TOUCH ENHANCEMENTS ─────────────────────────────────────────────── */

@media (hover: none) and (pointer: coarse) {
  /* Disable hover transforms on touch devices to prevent "sticky" hover states */
  .course-card:hover,
  .category-card:hover,
  .feature-card:hover,
  .stat-card:hover,
  .wishlist-card:hover,
  .course-progress-card:hover {
    transform: none !important;
  }

  /* Increase touch targets for sidebar nav items */
  .sidebar-nav-item {
    padding: 12px 24px !important;
  }
}


/* ── 34. UTILITY FIXES ──────────────────────────────────────────────────── */

/* Prevent long words / URLs from overflowing containers */
@media (max-width: 575.98px) {
  p, h1, h2, h3, h4, h5, h6, span, a, td, th, li {
    overflow-wrap: break-word;
    word-break: break-word;
  }

  /* Fix Bootstrap display-* headings on tiny screens */
  .display-3 { font-size: 2.2rem !important; }
  .display-4 { font-size: 1.9rem !important; }
  .display-5 { font-size: 1.6rem !important; }
}

/* Ensure sticky elements don't cover content on small screens */
@media (max-width: 991.98px) {
  .sticky-top:not(.navbar-custom):not(.dashboard-topbar) {
    position: relative !important;
    top: auto !important;
  }
}
