/* ============================================================
   COURSENOVA — GLOBAL MOBILE RESPONSIVE CSS
   Covers all pages, all components, all breakpoints
   Primary breakpoints: 1200px, 992px, 768px, 576px, 360px
   ============================================================ */

/* ── BASE: Prevent horizontal scroll everywhere ──────────── */
*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; width: 100%; }
img, video, iframe, embed, object, canvas, svg { max-width: 100%; height: auto; }

/* ── VIEWPORT META SAFETY ────────────────────────────────── */
:root {
  --mobile-padding: 1rem;
  --tablet-padding: 1.5rem;
}

/* ============================================================
   1. NAVBAR / NAVIGATION
   ============================================================ */
@media (max-width: 768px) {
  .navbar { padding: 0.7rem 1rem !important; }
  .navbar.scrolled { padding: 0.7rem 1rem !important; }
  .nav-container { gap: 0 !important; }
  .logo { min-width: auto !important; }
  .logo img { height: 44px !important; }
  .logo span { font-size: 1.05rem !important; }
  .menu-toggle { display: flex !important; align-items: center; }
  .user-name-display { display: none !important; }
  .btn-login, .btn-signup { padding: 0.4rem 0.75rem !important; font-size: 0.78rem !important; }
  .btn-login i { display: none !important; }
  body { padding-top: 60px !important; }
}

@media (max-width: 480px) {
  .logo span { font-size: 0.95rem !important; }
  .logo img { height: 36px !important; }
  .navbar { padding: 0.5rem 0.75rem !important; }
  .navbar.scrolled { padding: 0.5rem 0.75rem !important; }
  .nav-buttons { gap: 0.4rem !important; }
  .btn-signup { padding: 0.38rem 0.6rem !important; font-size: 0.75rem !important; }
  .user-avatar-small { width: 30px !important; height: 30px !important; font-size: 0.78rem !important; }
  body { padding-top: 56px !important; }
}

/* ============================================================
   2. HERO SECTION
   ============================================================ */
@media (max-width: 992px) {
  .hero {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
    padding: 2.5rem 1.5rem !important;
    text-align: center;
  }
  .hero-content h1 { font-size: 2.2rem !important; }
  .hero-visual { order: -1; }
  .hero-image { max-width: 340px !important; margin: 0 auto; }
  .hero-buttons { justify-content: center !important; }
  .value-points li { justify-content: center !important; }
}

@media (max-width: 576px) {
  .hero { padding: 2rem 1rem !important; }
  .hero-content h1 { font-size: 1.75rem !important; line-height: 1.3; }
  .hero-content p { font-size: 0.95rem !important; }
  .hero-buttons { flex-direction: column !important; align-items: center !important; }
  .hero-buttons a, .hero-buttons button { width: 100% !important; max-width: 300px; }
  .hero-image { max-width: 280px !important; }
}

/* ============================================================
   3. SECTIONS — GENERAL GRIDS
   ============================================================ */
@media (max-width: 768px) {
  /* Trust bar */
  .trust-container { grid-template-columns: 1fr 1fr !important; gap: 1rem !important; }
  .trust-item { flex-direction: column; text-align: center; }

  /* Problem-solution */
  .problem-solution {
    grid-template-columns: 1fr !important;
    padding: 2rem 1rem !important;
    gap: 2rem !important;
  }
  .problem-solution h2 { font-size: 1.6rem !important; }

  /* Features */
  .features { padding: 2.5rem 1rem !important; }
  .features-grid { grid-template-columns: 1fr !important; gap: 1.2rem !important; }
  .feature-card { padding: 1.5rem !important; }

  /* How it works */
  .how-it-works { padding: 2.5rem 1rem !important; }
  .steps-container { grid-template-columns: repeat(2, 1fr) !important; gap: 1.5rem !important; }

  /* Popular courses */
  .popular-courses { padding: 2.5rem 1rem !important; }
  .courses-grid { grid-template-columns: 1fr 1fr !important; gap: 1rem !important; }

  /* Section title */
  .section-title { font-size: 1.7rem !important; margin-bottom: 1.5rem !important; }

  /* Footer */
  .footer-container { grid-template-columns: 1fr 1fr !important; gap: 2rem !important; }
}

@media (max-width: 480px) {
  .trust-container { grid-template-columns: 1fr !important; }
  .steps-container { grid-template-columns: 1fr !important; }
  .courses-grid { grid-template-columns: 1fr !important; }
  .footer-container { grid-template-columns: 1fr !important; text-align: center; }
  .footer-logo { margin: 0 auto; }
  .section-title { font-size: 1.4rem !important; }
}

/* ============================================================
   4. STORE / MARKETPLACE PAGE
   ============================================================ */
@media (max-width: 768px) {
  .store-header, .store-hero { padding: 1.5rem 1rem !important; text-align: center; }
  .store-filters { flex-direction: column !important; gap: 0.7rem !important; }
  .store-filters select, .store-filters input { width: 100% !important; }
  .books-grid { grid-template-columns: 1fr 1fr !important; gap: 1rem !important; }
  .book-card { font-size: 0.88rem; }
  .sell-btn-wrap { position: fixed !important; bottom: 1.2rem; right: 1.2rem; z-index: 999; }
  .filter-sidebar { position: relative !important; top: 0 !important; margin-bottom: 1.5rem !important; }
  .stats-bar {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    width: 100% !important;
  }
  .stat-item {
    max-width: none !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border) !important;
  }
  .stat-item:nth-child(even) {
    border-left: 1px solid var(--border) !important;
  }
  .stat-item:nth-child(3), .stat-item:nth-child(4) {
    border-bottom: none !important;
  }
}

@media (max-width: 480px) {
  .books-grid { grid-template-columns: 1fr !important; max-width: 340px; margin: 0 auto; }
  .store-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .store-tab { white-space: nowrap; min-width: 90px; }
}

/* ============================================================
   5. BOOK DETAIL PAGE
   ============================================================ */
@media (max-width: 768px) {
  .detail-grid, .book-detail-layout {
    grid-template-columns: 1fr !important;
    flex-direction: column !important;
    padding: 1rem !important;
    gap: 1.2rem !important;
  }
  .book-detail-main { order: 1; }
  .book-detail-sidebar { order: 2; }
  .seller-card { padding: 1rem !important; }
  .book-detail-img, .book-cover { max-width: 200px !important; margin: 0 auto !important; }
}

/* ============================================================
   6. COURSE CONTENT PAGE
   ============================================================ */
@media (max-width: 992px) {
  .content-container {
    grid-template-columns: 1fr !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .sidebar {
    width: 100% !important;
    max-height: 260px !important;
    overflow-y: auto !important;
    border-right: none !important;
    border-bottom: 1px solid #e2e8f0;
  }
  .main-content { padding: 1.5rem 1rem !important; }
  .task-checklist { display: none; /* save space on mobile */ }
}

@media (max-width: 576px) {
  .sidebar { max-height: 200px !important; }
  .main-content { padding: 1rem 0.75rem !important; }
  .lesson-header h1 { font-size: 1.3rem !important; }
  .progress-banner { flex-direction: column; gap: 0.8rem; }
  .action-footer { flex-wrap: wrap; gap: 0.6rem; }
  .mark-btn { font-size: 0.82rem !important; padding: 8px 14px !important; }
}

/* ============================================================
   7. DASHBOARD
   ============================================================ */
@media (max-width: 992px) {
  .dashboard-container, .dashboard-grid {
    grid-template-columns: 1fr !important;
  }
  .dashboard-sidebar {
    width: 100% !important;
    height: auto !important;
    position: relative !important;
    top: 0 !important;
    border-right: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 0.5rem 1rem !important;
    background: #ffffff !important;
    overflow-x: auto !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    z-index: 100 !important;
  }
  .sidebar-user {
    display: none !important;
  }
  .sidebar-footer {
    display: none !important;
  }
  .sidebar-nav {
    display: flex !important;
    flex-direction: row !important;
    gap: 0.5rem !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }
  .sidebar-nav::-webkit-scrollbar {
    display: none !important;
  }
  .sidebar-nav a {
    white-space: nowrap !important;
    padding: 0.6rem 1rem !important;
    font-size: 0.85rem !important;
    border-radius: 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    transform: none !important;
  }
  .dashboard-main { padding: 1.2rem 1rem !important; }
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 0.8rem !important; }
}

@media (max-width: 576px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .dashboard-main { padding: 1rem 0.75rem !important; }
  .stat-card { padding: 1rem !important; }
  .progress-courses-list { gap: 0.8rem !important; }
}

/* ============================================================
   8. COMMUNITY PAGE
   ============================================================ */
@media (max-width: 768px) {
  .community-container {
    grid-template-columns: 1fr !important;
    padding: 0 10px !important;
    gap: 1rem !important;
    margin-top: 80px !important;
  }
  .sidebar-right {
    display: none !important;
  }
  .sidebar-left {
    display: none !important;
  }
  .top-action-bar {
    padding: 15px !important;
    flex-direction: column !important;
    gap: 12px !important;
    align-items: stretch !important;
    border-radius: 12px !important;
  }
  .top-action-bar > div {
    width: 100% !important;
    justify-content: space-between !important;
  }
  .post-card { padding: 1rem !important; }
  .leaderboard-list li { font-size: 0.85rem !important; }
}

@media (max-width: 480px) {
  .community-header, .community-hero { padding: 1rem 0.75rem !important; }
  .post-meta { flex-wrap: wrap; gap: 0.3rem; font-size: 0.78rem !important; }
  .post-actions { gap: 0.6rem !important; }
}

/* ============================================================
   9. MOCK TESTS PAGE
   ============================================================ */
@media (max-width: 768px) {
  .mock-tests-header { padding: 1.5rem 1rem !important; text-align: center; }
  .tests-grid { grid-template-columns: 1fr !important; gap: 1rem !important; }
  .test-pack-card { padding: 1.2rem !important; }
  .mock-filters { flex-wrap: wrap; gap: 0.6rem !important; }
  .mock-filter-btn { font-size: 0.82rem !important; padding: 0.4rem 0.8rem !important; }
}

/* ============================================================
   10. QUIZ ENGINE / DAILY CHALLENGE
   ============================================================ */
@media (max-width: 768px) {
  .quiz-container { padding: 1rem !important; margin: 0 !important; border-radius: 0 !important; }
  .quiz-header { flex-direction: column; gap: 0.6rem; text-align: center; }
  .question-text { font-size: 1rem !important; }
  .option-btn { padding: 0.8rem 1rem !important; font-size: 0.9rem !important; }
  .quiz-progress-bar { height: 6px !important; }
  .quiz-timer { font-size: 1.1rem !important; }
  .result-card { padding: 1.5rem 1rem !important; }
  .result-score { font-size: 2.5rem !important; }
  .challenge-grid { grid-template-columns: 1fr !important; }
  .streak-stats { flex-wrap: wrap; gap: 0.8rem; }
  .dc-container { margin-top: 20px !important; padding: 0 12px !important; }
  .dc-today-card div[style*="border-right"] { border-right: none !important; border-bottom: 1px solid #f1f5f9 !important; }
  .dc-today-card div[style*="padding: 40px"] { padding: 20px !important; }
}

@media (max-width: 480px) {
  .quiz-container { padding: 0.75rem !important; }
  .question-text { font-size: 0.92rem !important; }
  .options-list { gap: 0.6rem !important; }
  .option-btn { font-size: 0.85rem !important; padding: 0.7rem 0.9rem !important; }
}

/* ============================================================
   11. CERTIFICATES PAGE
   ============================================================ */
@media (max-width: 768px) {
  .certificates-grid { grid-template-columns: 1fr 1fr !important; gap: 1rem !important; }
  .cert-card { padding: 1rem !important; }
  .cert-preview { max-width: 100% !important; }
}

@media (max-width: 480px) {
  .certificates-grid { grid-template-columns: 1fr !important; }
  .cert-search-bar { flex-direction: column !important; gap: 0.6rem; }
  .cert-search-bar input { width: 100% !important; }
}

/* ============================================================
   12. MY COURSES PAGE
   ============================================================ */
@media (max-width: 768px) {
  .my-courses-grid { grid-template-columns: 1fr !important; gap: 1rem !important; }
  .enrolled-course-card { padding: 1rem !important; flex-direction: column !important; }
  .course-thumb { width: 100% !important; height: 140px !important; border-radius: 8px !important; }
}

/* ============================================================
   13. SIGNUP / LOGIN PAGES
   ============================================================ */
@media (max-width: 576px) {
  .auth-container, .signup-container {
    flex-direction: column !important;
    min-height: auto !important;
  }
  .auth-left, .auth-right {
    width: 100% !important;
    padding: 2rem 1.2rem !important;
  }
  .auth-left { display: none !important; } /* hide decorative side on tiny screens */
  .auth-form { max-width: 100% !important; padding: 0 !important; }
  .auth-card { padding: 1.5rem 1.2rem !important; margin: 1rem !important; width: calc(100% - 2rem) !important; }
  .google-btn { width: 100% !important; }
  .form-row { flex-direction: column !important; gap: 0.8rem !important; }
}

/* ============================================================
   14. ADMIN DASHBOARD
   ============================================================ */
@media (max-width: 992px) {
  .admin-wrapper {
    flex-direction: column !important;
  }
  .admin-sidebar {
    width: 100% !important;
    height: auto !important;
    position: relative !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 0.5rem !important;
    border-right: none !important;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
    display: flex !important;
    gap: 0.3rem !important;
  }
  .admin-sidebar .sidebar-header, .admin-sidebar .sidebar-footer {
    display: none !important;
  }
  .admin-sidebar .sidebar-nav, .admin-sidebar ul { flex-direction: row !important; display: flex !important; }
  .sidebar-item, .admin-sidebar li { flex-shrink: 0; }
  .sidebar-item a, .admin-sidebar li a {
    padding: 0.5rem 0.9rem !important;
    font-size: 0.8rem !important;
    white-space: nowrap;
  }
  .admin-content, .content-area { padding: 1rem !important; }
}

@media (max-width: 768px) {
  .admin-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; font-size: 0.82rem; }
  .admin-table thead { display: none; } /* hide headers, show as cards */
  .admin-table tbody tr {
    display: block;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 0.8rem;
    padding: 0.8rem;
  }
  .admin-table tbody td { display: block; padding: 0.3rem 0 !important; border: none !important; }
  .admin-table tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #6366f1;
    font-size: 0.7rem;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .admin-card { padding: 1rem !important; }
  .card-header { flex-wrap: wrap !important; gap: 0.6rem !important; }
  .stats-cards { grid-template-columns: 1fr 1fr !important; gap: 0.8rem !important; }
}

@media (max-width: 480px) {
  .stats-cards { grid-template-columns: 1fr !important; }
  .admin-actions { flex-wrap: wrap !important; gap: 0.5rem !important; }
  .admin-actions button { font-size: 0.8rem !important; padding: 0.5rem 0.8rem !important; }
}

/* ============================================================
   15. MODAL / OVERLAY — all pages
   ============================================================ */
@media (max-width: 768px) {
  .modal-overlay, .modal-container.active {
    align-items: flex-end !important; /* slide up from bottom */
    padding: 0 !important;
  }
  .modal-content, .modal-box, .modal-content.admin-card {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 92vh !important;
    overflow-y: auto !important;
    margin: 0 !important;
  }
}

@media (max-width: 480px) {
  .modal-content { padding: 1.2rem !important; }
  .modal-tabs { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
  .modal-tab-btn { white-space: nowrap !important; font-size: 0.82rem !important; padding: 0.5rem 0.8rem !important; }
  .form-group label { font-size: 0.85rem !important; }
  .admin-input { font-size: 0.9rem !important; padding: 0.6rem !important; }
}

/* ============================================================
   16. COURSE.HTML (Course Browse Listing)
   ============================================================ */
@media (max-width: 768px) {
  .courses-page-header { padding: 1.5rem 1rem !important; text-align: center; }
  .courses-filter-bar { flex-wrap: wrap !important; gap: 0.6rem !important; padding: 0.8rem 1rem !important; }
  .course-filter-pill { font-size: 0.8rem !important; padding: 0.4rem 0.9rem !important; }
  .all-courses-grid { grid-template-columns: 1fr 1fr !important; gap: 1rem !important; padding: 1rem !important; }
  .course-card-big { padding: 1rem !important; }
}

@media (max-width: 480px) {
  .all-courses-grid { grid-template-columns: 1fr !important; max-width: 340px; margin: 0 auto; }
  .course-card-big .course-icon { font-size: 1.8rem !important; }
}

/* ============================================================
   17. PRACTICE / CODING PAGE
   ============================================================ */
@media (max-width: 768px) {
  .practice-layout {
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    height: auto !important;
  }
  .code-editor-panel { height: 320px !important; }
  .output-panel { height: 180px !important; }
  .practice-sidebar { width: 100% !important; max-height: 200px !important; overflow-y: auto !important; }
  .problem-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ============================================================
   18. PROFILE PAGE
   ============================================================ */
@media (max-width: 768px) {
  .profile-layout { flex-direction: column !important; padding: 1rem !important; gap: 1rem !important; }
  .profile-sidebar { width: 100% !important; }
  .profile-avatar-big { width: 80px !important; height: 80px !important; font-size: 2rem !important; }
  .profile-stats { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 480px) {
  .profile-stats { grid-template-columns: 1fr !important; }
  .profile-card { padding: 1rem !important; }
}

/* ============================================================
   19. GLOBAL UTILITY RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  /* Spacing utility */
  .section { padding: 2.5rem 1rem !important; }
  .container, .page-container { padding: 0 1rem !important; max-width: 100% !important; }

  /* Typography scale-down */
  h1 { font-size: clamp(1.5rem, 5vw, 2.5rem) !important; }
  h2 { font-size: clamp(1.25rem, 4vw, 2rem) !important; }
  h3 { font-size: clamp(1rem, 3.5vw, 1.5rem) !important; }

  /* Buttons full-width on forms */
  .form-submit-btn { width: 100% !important; }

  /* Tables scroll */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }

  /* Cards */
  .card-grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }

  /* Horizontal scroll containers */
  .scroll-x { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; display: flex !important; flex-wrap: nowrap !important; padding-bottom: 0.5rem; }

  /* Notifications */
  .notification-panel { width: 100vw !important; right: 0 !important; border-radius: 0 0 16px 16px !important; max-height: 80vh !important; }
}

@media (max-width: 576px) {
  /* Order Card stacking */
  .order-header {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .order-actions {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .order-actions button {
    width: 100% !important;
  }
}

@media (max-width: 480px) {
  /* Very small phone adjustments */
  .section { padding: 2rem 0.75rem !important; }
  .container, .page-container { padding: 0 0.75rem !important; }
  .btn-primary, .btn-secondary {
    padding: 0.65rem 1.2rem !important;
    font-size: 0.88rem !important;
    min-height: 42px;
  }
  .verify-container {
    padding: 20px !important;
    border-radius: 16px !important;
  }
}

/* ============================================================
   20. TOUCH UX IMPROVEMENTS (all devices)
   ============================================================ */
/* Larger touch targets */
button, a, [role="button"] {
  -webkit-tap-highlight-color: transparent;
}
input, select, textarea {
  font-size: 16px !important; /* Prevents iOS zoom */
  touch-action: manipulation;
}

/* Smooth scroll for iOS momentum */
.sidebar, .modal-content, .admin-sidebar, .store-tabs,
.chat-messages, .quiz-list, .lesson-list, .lesson-list-scroll {
  -webkit-overflow-scrolling: touch;
}

/* Prevent text overflow everywhere */
.nav-menu a, .btn, button, .card-title, h1, h2, h3 {
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ============================================================
   21. LANDSCAPE PHONE MODE
   ============================================================ */
@media (max-height: 500px) and (orientation: landscape) {
  .sidebar { max-height: 150px !important; }
  .hero { padding: 1.5rem 1rem !important; }
  .hero-content h1 { font-size: 1.6rem !important; }
  .modal-content { max-height: 95vh !important; }
  body { padding-top: 52px !important; }
}

/* ============================================================
   22. TABLET-SPECIFIC (iPad/medium screens)
   ============================================================ */
@media (min-width: 577px) and (max-width: 992px) {
  .hero { padding: 3rem 2rem !important; }
  .features-grid { grid-template-columns: 1fr 1fr !important; }
  .courses-grid { grid-template-columns: 1fr 1fr !important; }
  .books-grid { grid-template-columns: 1fr 1fr 1fr !important; }
  .stats-grid, .stats-cards { grid-template-columns: 1fr 1fr !important; }
  .community-layout { grid-template-columns: 1fr !important; }
}

/* ============================================================
   23. SCROLLBAR POLISH (mobile hide)
   ============================================================ */
@media (max-width: 768px) {
  ::-webkit-scrollbar { width: 0px; height: 0px; }
  * { scrollbar-width: none; }
}

/* ============================================================
   24. ABOUT US PAGE
   ============================================================ */
@media (max-width: 968px) {
  .founder-img {
    height: 380px !important;
    object-fit: cover !important;
  }
  .founder-image-container::before {
    top: -8px !important;
    left: -8px !important;
  }
}
@media (max-width: 576px) {
  .founder-img {
    height: 280px !important;
  }
}
