/* ============================================================
   URGO Medical LMS — Responsive Stylesheet
   Covers: login.php, menu.php, course_overview.php, learn.php
   Breakpoints: Tablet (768-1024), Mobile (<=480)
   ============================================================ */

/* ============================================================
   SHARED: Navbar Responsive (menu.php, course_overview.php)
   ============================================================ */

/* --- Tablet (768px – 1024px) --- */
@media screen and (max-width: 1024px) {

  /* Navbar */
  .main-header .nav-container {
    padding: 10px 15px;
  }
  .main-header .nav-logo img {
    height: 38px;
  }
  .main-header .dropdown-toggle {
    padding: 10px 18px;
    font-size: 13px;
  }
}

/* --- Mobile (<=768px) --- */
@media screen and (max-width: 768px) {

  /* Navbar - keep row layout, no stack */
  .main-header .nav-container {
    flex-direction: row !important;
    padding: 8px 12px;
  }
  .main-header .nav-logo {
    margin-bottom: 0 !important;
  }
  .main-header .nav-logo img {
    height: 30px;
  }
  .main-header .dropdown-toggle {
    padding: 8px 14px;
    font-size: 12px;
  }
  .main-header .dropdown-menu {
    min-width: 180px;
  }
  .main-header .dropdown-menu li a {
    padding: 10px 16px;
    font-size: 13px;
  }
}


/* ============================================================
   1. LOGIN PAGE (login.php legacy + index.php modern)
   ============================================================ */

/* --- index.php: Extra mobile refinements --- */
@media screen and (max-width: 576px) {
  .login-container .login-left {
    padding: 20px 16px;
  }
  .login-container .logo-wrapper {
    padding: 15px 0 0 0;
  }
  .login-container .form-content {
    padding: 15px 16px 30px;
  }
  .login-container .welcome-text h1 {
    font-size: 24px;
  }
  .login-container .welcome-text p {
    font-size: 13px;
    margin-bottom: 20px;
  }
  .login-container .form-group input {
    padding: 12px 14px;
    font-size: 14px;
  }
  .login-container .btn-login,
  .login-container .btn-register {
    padding: 12px;
    font-size: 14px;
  }
  .login-container .login-footer {
    margin-top: 20px;
  }
  .login-container .login-footer p {
    font-size: 11px;
  }
  .login-container .partner-logos img {
    height: 30px;
  }
}

/* --- login.php legacy form --- */

/* --- Tablet --- */
@media screen and (max-width: 1024px) {
  .body.body-s {
    max-width: 380px;
    padding: 30px 20px;
  }
}

/* --- Mobile --- */
@media screen and (max-width: 600px) {
  .body.body-s {
    max-width: 100%;
    padding: 20px 15px;
    box-sizing: border-box;
  }

  /* Stack form rows: label above input */
  .sky-form .row {
    display: flex;
    flex-direction: column;
  }
  .sky-form .row .label.col.col-4 {
    width: 100%;
    text-align: left;
    margin-bottom: 5px;
  }
  .sky-form .row .col.col-8 {
    width: 100%;
  }

  /* Flip container - remove hardcoded width */
  .flipContain {
    width: 100% !important;
    max-width: 100%;
  }

  /* Form header */
  .sky-form > header {
    font-size: 1.2em !important;
    padding: 15px 10px;
  }

  /* Buttons full width */
  .sky-form footer .button,
  .sky-form footer .button-secondary {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    text-align: center;
    box-sizing: border-box;
  }

  /* Password recovery modal */
  .sky-form.sky-form-modal {
    width: 90% !important;
    left: 5% !important;
    margin-left: 0 !important;
    margin-top: -120px !important;
  }

  /* Login header nav */
  header.main nav {
    width: 100%;
  }
  header.main nav ul {
    text-align: center;
  }
}

@media screen and (max-width: 400px) {
  .sky-form > header {
    font-size: 1em !important;
    line-height: 1.3;
  }
}


/* ============================================================
   2. MENU PAGE (menu.php)
   ============================================================ */

/* --- Tablet (768-1024px) --- */
@media screen and (max-width: 1024px) {

  /* Course grid: 3 columns */
  .course-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 20px;
  }

  /* Hero */
  .home-content {
    padding: 40px 15px 60px;
  }
  .home-content h1,
  .header-section h1 {
    font-size: 2em !important;
  }
  .home-content p {
    font-size: 1em;
    max-width: 90%;
  }

  /* Card title */
  .browse-movie-title {
    font-size: 0.75em !important;
  }

  /* Legend */
  .module-legend {
    gap: 10px;
    margin-bottom: 30px;
  }
  .legend-badge {
    padding: 6px 12px;
    font-size: 0.78em;
  }

  /* Circular progress on cards */
  .progress-circle {
    width: 36px;
    height: 36px;
  }
  .progress-circle svg {
    width: 36px;
    height: 36px;
  }
  .progress-circle .progress-text {
    font-size: 9px;
  }

  /* Card status badge */
  .card-status-badge {
    font-size: 0.5em;
    padding: 2px 6px;
  }
  .status-detail-text {
    font-size: 0.58em !important;
  }

  /* Closed modal */
  .closed-modal-content {
    max-width: 350px;
    padding: 25px 30px;
  }

  /* Main content top margin */
  .main-content {
    margin-top: 70px !important;
  }
}

/* --- Small tablet (601-768px) --- */
@media screen and (max-width: 768px) {

  /* Hide mobile footer (Home, Quiz, Analytics buttons) */
  .mobile-footer {
    display: none !important;
  }

  /* Course grid: 2 columns */
  .course-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 15px;
  }

  /* Hero */
  .header-section h1,
  .home-content h1 {
    font-size: 1.6em !important;
  }
  .home-content p {
    font-size: 0.9em;
    margin-bottom: 25px;
  }
  .user-greeting h2 {
    font-size: 1.2em !important;
  }

  /* Card image aspect ratio */
  .browse-movie-link figure {
    padding-top: 120% !important;
  }

  /* Main content top margin */
  .main-content {
    margin-top: 65px !important;
  }

  /* Footer */
  footer .container {
    padding: 0 10px;
  }
  footer ul li {
    font-size: 0.75em;
  }
}

/* --- Mobile (<=480px) --- */
@media screen and (max-width: 480px) {

  /* Course grid: 1 column */
  .course-grid {
    grid-template-columns: 1fr !important;
    gap: 15px;
    padding-bottom: 30px;
  }

  /* Hero */
  .home-content {
    padding: 25px 12px 40px;
  }
  .header-section h1,
  .home-content h1 {
    font-size: 1.3em !important;
    margin-bottom: 10px;
  }
  .home-content p {
    font-size: 0.85em;
    line-height: 1.5;
    margin-bottom: 20px;
  }
  .user-greeting h2 {
    font-size: 1em !important;
  }

  /* Legend badges compact */
  .module-legend {
    gap: 8px;
    margin: 10px 0 25px;
  }
  .legend-badge {
    padding: 5px 10px;
    font-size: 0.7em;
    border-radius: 4px;
  }

  /* Card adjustments */
  .browse-movie-link {
    border-radius: 12px;
  }
  .browse-movie-link figure {
    padding-top: 100% !important;
    border-radius: 12px 12px 0 0;
  }
  .browse-movie-bottom {
    padding: 15px;
  }
  .browse-movie-title {
    font-size: 0.85em !important;
    margin-bottom: 10px;
    margin-top: 10px;
  }
  .browse-movie-year {
    font-size: 0.55em;
  }
  .card-status-badge {
    font-size: 0.5em;
  }
  .status-detail-text {
    font-size: 0.55em !important;
    margin-bottom: 10px;
  }

  /* Section heading */
  #popular-downloads h2 {
    font-size: 1.1em !important;
    padding-bottom: 8px;
    margin-bottom: 15px;
  }

  /* Grid full-span items */
  .course-grid > div[style*="grid-column"] {
    margin-bottom: 10px !important;
  }

  /* Closed modal mobile */
  .closed-modal-content {
    max-width: 92%;
    padding: 20px 25px;
    margin: 0 15px;
  }
  .closed-modal-icon {
    font-size: 2.5em;
  }
  .closed-modal-title {
    font-size: 1.2em;
  }

  /* Main content */
  .main-content {
    margin-top: 55px !important;
  }

  /* Container */
  .container-fluid.home-content {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}


/* ============================================================
   3. COURSE OVERVIEW (course_overview.php)
   ============================================================ */

/* --- Tablet (768-1024px) --- */
@media screen and (max-width: 1024px) {

  .course-container {
    padding: 30px 20px;
    gap: 30px;
  }

  .course-content-panel {
    max-width: 350px;
  }

  .course-title {
    font-size: 20px;
  }
}

/* --- Small tablet & below (<=900px) — already stacks, but improve it --- */
@media screen and (max-width: 900px) {

  .course-container {
    flex-direction: column;
    padding: 20px 15px;
    gap: 20px;
  }

  .course-thumbnail-section {
    width: 100%;
    max-width: 100%;
  }

  .course-thumbnail {
    max-height: 350px;
    aspect-ratio: auto;
  }

  .course-thumbnail img {
    max-height: 350px;
    object-fit: contain;
  }

  .course-content-panel {
    max-width: 100%;
    width: 100%;
  }
}

/* --- Mobile (<=480px) --- */
@media screen and (max-width: 480px) {

  .course-title-bar {
    padding: 15px;
  }
  .course-title {
    font-size: 16px;
  }

  .course-container {
    padding: 15px 12px;
    gap: 15px;
  }

  .course-thumbnail {
    max-height: 250px;
  }
  .course-thumbnail img {
    max-height: 250px;
  }

  .course-content-panel {
    padding: 18px;
  }

  .panel-title {
    font-size: 14px;
  }

  /* Increase touch targets for unit items */
  .unit-item {
    padding: 14px 0;
    gap: 10px;
  }
  .unit-name {
    font-size: 13px;
  }

  .continue-btn {
    padding: 14px 20px;
    font-size: 15px;
    border-radius: 8px;
  }

  /* Progress circle smaller */
  .course-content-panel .progress-circle {
    width: 36px;
    height: 36px;
  }
  .course-content-panel .progress-circle svg {
    width: 36px;
    height: 36px;
  }

  /* Empty notice */
  .empty-notice {
    padding: 20px 15px;
  }
  .empty-notice i {
    font-size: 30px;
  }

  /* Main content area */
  .main-content {
    padding-top: 55px;
  }
}


/* ============================================================
   4. LEARN PAGE (learn.php)
   ============================================================ */

/* --- Tablet (768-1024px) --- */
@media screen and (max-width: 1024px) {

  /* Sidebar narrower */
  .sidebar {
    width: 240px;
  }

  /* Top header: wrap nav buttons */
  .top-header {
    padding: 8px 15px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .header-left {
    order: 1;
  }
  .progress-area {
    order: 3;
    width: 100%;
    justify-content: center;
    margin-top: 5px;
  }
  .nav-buttons {
    order: 2;
    gap: 6px;
  }

  /* Nav buttons smaller */
  .nav-btn {
    padding: 6px 14px;
    font-size: 12px;
  }

  /* Help buttons smaller */
  .help-btn {
    font-size: 12px !important;
    padding: 0 12px !important;
    height: 28px !important;
  }

  /* Progress bar adjusts */
  .progress-bar {
    width: 160px;
  }

  /* Content area less padding */
  .content-area {
    padding: 20px 25px;
  }
  .content-body {
    padding: 20px;
  }
  .content-title {
    font-size: 18px;
  }

  /* Tour button */
  .tour-btn {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  /* Claim certificate button */
  .claim-certificate-btn {
    font-size: 11px;
    padding: 5px 12px;
  }
}

/* --- Mobile (<=768px) --- */
@media screen and (max-width: 768px) {

  /* ---- SIDEBAR: Slide-out Drawer ---- */
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }

  .sidebar.drawer-open {
    left: 0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }

  /* Overlay when drawer is open */
  .drawer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  .drawer-overlay.active {
    display: block;
    opacity: 1;
  }

  /* Always show toggle button on mobile */
  .sidebar-toggle {
    display: flex !important;
    z-index: 998;
  }

  /* Override the existing collapse logic */
  .app-container .sidebar {
    display: flex !important;
  }
  .app-container.sidebar-collapsed .sidebar {
    display: flex !important;
    left: -280px;
  }
  .app-container.sidebar-collapsed .sidebar.drawer-open {
    left: 0;
  }

  /* ---- TOP HEADER: Compact ---- */
  .top-header {
    padding: 8px 10px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .header-left {
    order: 1;
    display: flex;
    gap: 6px !important;
  }

  /* Forum/Questions - icons only on mobile */
  .help-btn {
    font-size: 0 !important;
    padding: 0 10px !important;
    height: 30px !important;
    min-width: 30px;
    justify-content: center;
  }
  .help-btn i {
    font-size: 14px !important;
  }

  /* Progress area */
  .progress-area {
    order: 2;
    flex: 1;
    min-width: 0;
  }
  .progress-bar {
    width: 80px;
  }
  .progress-text {
    font-size: 11px;
    white-space: nowrap;
  }

  /* Nav buttons */
  .nav-buttons {
    order: 3;
    gap: 5px;
  }
  .nav-btn {
    padding: 6px 10px;
    font-size: 11px;
  }
  /* Hide text on mobile nav buttons, show icons only */
  #mainNavGroup .nav-btn {
    font-size: 0;
    padding: 6px 10px;
  }
  #mainNavGroup .nav-btn i {
    font-size: 13px;
  }

  .tour-btn {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  /* Claim cert compact */
  .claim-certificate-btn {
    font-size: 10px;
    padding: 4px 10px;
    gap: 4px;
  }

  /* ---- CONTENT AREA ---- */
  .content-area {
    padding: 15px;
  }
  .content-body {
    padding: 15px;
  }
  .content-title {
    font-size: 16px;
  }
  .content-text {
    font-size: 12px;
  }
  .content-meta {
    font-size: 10px;
  }

  /* H5P quiz iframe */
  .h5p-quiz-iframe-container iframe {
    height: 400px;
  }
  .h5p-quiz-header {
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .h5p-quiz-title {
    font-size: 13px;
  }
  .h5p-quiz-badge {
    font-size: 10px;
  }

  /* MCQ form improvements */
  .mcq-question {
    margin-bottom: 20px !important;
    padding-bottom: 15px !important;
  }
  .mcq-question p {
    font-size: 14px !important;
  }
  .mcq-options {
    margin-left: 10px !important;
  }
  .mcq-options label {
    font-size: 13px;
    padding: 6px 0;
  }
  .mcq-options input[type="radio"],
  .mcq-options input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px !important;
  }
  #submitMCQBtn {
    width: 100%;
    padding: 12px 20px !important;
    font-size: 15px !important;
  }

  /* Color legend in MCQ - stack on mobile */
  .content-body > div[style*="display: flex"][style*="align-items: center"][style*="gap: 20px"] {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* H5P completed view */
  .h5p-completed-view {
    padding: 30px 20px !important;
  }
  .h5p-completed-view h2 {
    font-size: 20px !important;
  }
  .h5p-completed-view div[style*="inline-grid"] {
    grid-template-columns: 1fr !important;
    gap: 15px !important;
    padding: 20px !important;
  }
  .h5p-completed-view div[style*="border-right"] {
    border-right: none !important;
    border-bottom: 1px solid #e2e8f0;
    padding-right: 0 !important;
    padding-bottom: 15px;
  }

  /* Video player */
  .content-media {
    aspect-ratio: auto;
    max-height: 50vh;
  }
  .content-media video,
  .content-media iframe {
    max-height: 50vh;
  }

  /* Forum modal adjustments */
  .forum-modal-content {
    width: 95% !important;
    max-width: 95% !important;
    margin: 10px;
  }
}

/* --- Very small mobile (<=400px) --- */
@media screen and (max-width: 400px) {

  /* Even more compact header */
  .top-header {
    padding: 6px 8px;
  }

  /* Hide "Home" text, keep icon */
  #homeBtn {
    font-size: 0;
    padding: 6px 10px;
  }
  #homeBtn i {
    font-size: 13px;
  }

  /* Progress bar even smaller */
  .progress-bar {
    width: 60px;
  }
  .progress-text {
    font-size: 10px;
  }

  /* Content area minimal padding */
  .content-area {
    padding: 10px 8px;
  }

  /* Sidebar drawer narrower on very small screens */
  .sidebar {
    width: 250px;
    left: -250px;
  }
  .app-container.sidebar-collapsed .sidebar {
    left: -250px;
  }
  .app-container.sidebar-collapsed .sidebar.drawer-open {
    left: 0;
  }
}


/* ============================================================
   SHARED: Touch-friendly Dropdown (all pages with nav)
   Helps hover menus work on touch devices
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
  /* On touch devices, make dropdown accessible via tap */
  .nav-dropdown .dropdown-menu {
    display: none;
  }
  .nav-dropdown.touch-open .dropdown-menu {
    display: block;
  }
}


/* ============================================================
   SHARED: Print-friendly hide
   ============================================================ */
@media print {
  .sidebar,
  .sidebar-toggle,
  .top-header,
  .main-header,
  .nav-buttons,
  .drawer-overlay,
  footer {
    display: none !important;
  }
  .content-area {
    padding: 0 !important;
  }
  .app-container {
    display: block !important;
  }
  .main-area {
    overflow: visible !important;
  }
}
