/* Mobile Responsiveness - Comprehensive Mobile-First Styles */

/* ============================================
   Mobile Breakpoints
   ============================================ */
/* 
   - Mobile: 320px - 575px
   - Tablet: 576px - 991px  
   - Desktop: 992px+
*/

/* ============================================
   Base Mobile Styles (Mobile First)
   ============================================ */

/* Ensure proper viewport handling */
html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  font-size: 16px; /* Base font size for mobile readability */
  line-height: 1.6;
  overflow-x: hidden; /* Prevent horizontal scroll */
}

/* ============================================
   Typography - Responsive Scaling
   ============================================ */

/* Mobile Typography */
h1 { font-size: 1.75rem; line-height: 1.3; }
h2 { font-size: 1.5rem; line-height: 1.3; }
h3 { font-size: 1.25rem; line-height: 1.4; }
h4 { font-size: 1.1rem; line-height: 1.4; }
h5 { font-size: 1rem; line-height: 1.5; }
h6 { font-size: 0.9rem; line-height: 1.5; }

p, li {
  font-size: 1rem;
  line-height: 1.6;
}

/* Tablet Typography */
@media (min-width: 576px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.5rem; }
  h4 { font-size: 1.25rem; }
}

/* Desktop Typography */
@media (min-width: 992px) {
  h1 { font-size: 2.5rem; }
  h2 { font-size: 2rem; }
  h3 { font-size: 1.75rem; }
  h4 { font-size: 1.5rem; }
}

/* ============================================
   Touch Targets - Minimum 44x44px
   ============================================ */

/* Buttons */
.btn,
button,
input[type="submit"],
input[type="button"],
a.btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  touch-action: manipulation; /* Prevent double-tap zoom */
  -webkit-tap-highlight-color: rgba(0, 123, 255, 0.3); /* iOS tap highlight */
  user-select: none; /* Prevent text selection on tap */
}

/* Touch-optimized elements */
.touch-target-optimized {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 123, 255, 0.3);
}

/* Touch-friendly body class */
body.touch-optimized * {
  -webkit-tap-highlight-color: rgba(0, 123, 255, 0.2);
}

/* Swipe gesture indicators */
.swipeable {
  touch-action: pan-y;
  overflow-x: hidden;
}

/* Pull to refresh indicator */
.pull-to-refresh-indicator {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1rem;
  background: #007bff;
  color: white;
  border-radius: 0 0 1rem 1rem;
  transition: top 0.3s ease;
  z-index: 10000;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-sm {
  min-height: 38px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.btn-lg {
  min-height: 50px;
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
}

/* Navigation Links */
.nav-link,
.navbar-nav .nav-link {
  min-height: 44px;
  padding: 0.75rem 1rem !important;
  display: flex;
  align-items: center;
  touch-action: manipulation;
}

/* Form Controls */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
input[type="number"],
input[type="search"],
select,
textarea {
  min-height: 44px;
  font-size: 16px; /* Prevents zoom on iOS */
  padding: 0.75rem;
  width: 100%;
  touch-action: manipulation;
}

textarea {
  min-height: 100px;
}

/* Checkboxes and Radio Buttons */
input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  margin-right: 0.5rem;
  touch-action: manipulation;
}

label {
  display: flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

/* ============================================
   Layout & Spacing
   ============================================ */

/* Container Padding */
.container,
.container-fluid {
  padding-left: 1rem;
  padding-right: 1rem;
}

/* Main Content */
main {
  padding: 1rem;
}

/* Cards */
.card {
  margin-bottom: 1rem;
  border-radius: 8px;
}

.card-body {
  padding: 1rem;
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.card-text {
  font-size: 0.95rem;
}

/* Grid System Enhancements */
.row {
  margin-left: -0.5rem;
  margin-right: -0.5rem;
}

.row > [class*="col-"] {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  margin-bottom: 1rem;
}

/* ============================================
   Navigation - Mobile Optimized
   ============================================ */

/* Navbar */
.navbar {
  padding: 0.5rem 1rem;
}

.navbar-brand {
  font-size: 1.25rem;
  padding: 0.5rem 0;
}

.navbar-brand img {
  max-height: 40px;
}

.navbar-toggler {
  padding: 0.5rem;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
}

.navbar-toggler-icon {
  width: 1.5em;
  height: 1.5em;
}

/* Mobile Menu */
@media (max-width: 991.98px) {
  .navbar-collapse {
    background: white;
    padding: 1rem;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-top: 1rem;
  }
  
  .navbar-nav {
    flex-direction: column;
  }
  
  .navbar-nav .nav-item {
    border-bottom: 1px solid #e9ecef;
  }
  
  .navbar-nav .nav-item:last-child {
    border-bottom: none;
  }
  
  .navbar-nav .nav-link {
    padding: 1rem !important;
    color: #333 !important;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  /* Dropdown menus in mobile */
  .dropdown-menu {
    position: static !important;
    float: none;
    width: 100%;
    margin-top: 0.5rem;
    border: none;
    box-shadow: none;
    background-color: #f8f9fa;
  }
  
  .dropdown-item {
    padding: 0.75rem 1rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  /* Profile dropdown on mobile */
  .profile-dropdown {
    width: 100%;
    margin-top: 1rem;
  }
  
  .profile-button {
    width: 100%;
    min-height: 44px;
    text-align: left;
    padding: 0.75rem 1rem;
  }
  
  .dropdown-content {
    position: static;
    width: 100%;
    margin-top: 0.5rem;
  }
}

/* ============================================
   Forms - Mobile Optimized
   ============================================ */

/* Form Groups */
.form-group {
  margin-bottom: 1.25rem;
}

.form-control,
.form-select {
  width: 100%;
  padding: 0.75rem;
  font-size: 16px; /* Prevents iOS zoom */
  border: 1px solid #ced4da;
  border-radius: 4px;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
  border-color: #007bff;
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Form Labels */
.form-label {
  font-weight: 500;
  margin-bottom: 0.5rem;
  display: block;
}

/* Input Groups */
.input-group {
  flex-wrap: wrap;
}

.input-group .form-control,
.input-group .form-select {
  margin-bottom: 0.5rem;
}

.input-group .btn {
  width: 100%;
  margin-left: 0;
}

/* Search Bar */
.search-bar {
  flex-direction: column;
  width: 100%;
}

.search-bar input {
  width: 100%;
  margin-bottom: 0.75rem;
  border-radius: 4px;
}

.search-bar button {
  width: 100%;
  margin-left: 0;
  border-radius: 4px;
}

/* ============================================
   Tables - Mobile Responsive
   ============================================ */

/* Make tables scrollable on mobile */
.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

/* Stack table cells on very small screens */
@media (max-width: 575px) {
  .table-responsive {
    overflow-x: visible;
  }
  
  .table-responsive table,
  .table-responsive thead,
  .table-responsive tbody,
  .table-responsive th,
  .table-responsive td,
  .table-responsive tr {
    display: block;
  }
  
  .table-responsive thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  
  .table-responsive tr {
    border: 1px solid #ccc;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background-color: #fff;
    border-radius: 4px;
  }
  
  .table-responsive td {
    border: none;
    position: relative;
    padding-left: 50%;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    text-align: left;
  }
  
  .table-responsive td:before {
    content: attr(data-label);
    position: absolute;
    left: 6px;
    width: 45%;
    padding-right: 10px;
    white-space: nowrap;
    font-weight: bold;
    color: #495057;
  }
  
  /* Action buttons in tables */
  .table-responsive .btn {
    width: 100%;
    margin-bottom: 0.25rem;
  }
  
  .table-responsive .btn-group {
    flex-direction: column;
    width: 100%;
  }
}

/* ============================================
   Hero Sections
   ============================================ */

.hero-section {
  padding: 2rem 1rem;
  min-height: auto;
}

.hero-section .display-4 {
  font-size: 1.75rem;
  margin-bottom: 1rem;
}

.hero-section .lead {
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 576px) {
  .hero-section {
    padding: 3rem 1rem;
  }
  
  .hero-section .display-4 {
    font-size: 2.25rem;
  }
  
  .hero-section .lead {
    font-size: 1.25rem;
  }
}

@media (min-width: 992px) {
  .hero-section {
    padding: 4rem 1rem;
  }
  
  .hero-section .display-4 {
    font-size: 3rem;
  }
  
  .hero-section .lead {
    font-size: 1.5rem;
  }
}

/* ============================================
   Footer - Mobile Optimized
   ============================================ */

.footer {
  padding: 2rem 1rem 1rem;
  text-align: center;
}

.footer .row > div {
  margin-bottom: 2rem;
}

.footer h5 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.footer ul {
  list-style: none;
  padding: 0;
}

.footer ul li {
  margin-bottom: 0.5rem;
}

.footer .logo-container,
.footer .Additional-links,
.footer .footer-bottom {
  text-align: center;
}

.footer .list-inline {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
}

@media (min-width: 576px) {
  .footer {
    padding: 3rem 1rem 1rem;
    text-align: left;
  }
  
  .footer .row > div {
    margin-bottom: 1rem;
  }
  
  .footer .logo-container,
  .footer .Additional-links {
    text-align: right;
  }
}

/* ============================================
   Dashboard Cards
   ============================================ */

.dashboard-card,
.card {
  margin-bottom: 1rem;
}

.dashboard-stat {
  padding: 1rem;
  margin-bottom: 1rem;
}

/* Stack dashboard stats on mobile */
@media (max-width: 767px) {
  .dashboard-card .col-md-3,
  .dashboard-card .col-md-4,
  .dashboard-card .col-md-6,
  .dashboard-card .col-lg-3,
  .dashboard-card .col-lg-4,
  .dashboard-card .col-lg-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  /* Dashboard action buttons */
  .d-flex.justify-content-end,
  .d-flex.justify-content-between {
    flex-direction: column;
    align-items: stretch !important;
  }
  
  .d-flex.justify-content-end .btn,
  .d-flex.justify-content-between .btn {
    width: 100%;
    margin-bottom: 0.5rem;
    margin-right: 0 !important;
  }
  
  .d-flex.justify-content-end .btn:last-child,
  .d-flex.justify-content-between .btn:last-child {
    margin-bottom: 0;
  }
  
  /* Chart containers */
  .card canvas {
    max-width: 100%;
    height: auto !important;
  }
}

/* ============================================
   Profile Cards
   ============================================ */

.profile-card {
  max-width: 100%;
  margin: 1rem auto;
  padding: 1rem;
}

.profile-image {
  width: 80px;
  height: 80px;
}

@media (min-width: 576px) {
  .profile-card {
    max-width: 200px;
  }
  
  .profile-image {
    width: 100px;
    height: 100px;
  }
}

/* ============================================
   Course Cards & Grids
   ============================================ */

.course-box {
  width: 100%;
  margin-bottom: 1.5rem;
}

.discover-grid {
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 576px) {
  .discover-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .course-box {
    width: 48%;
  }
}

@media (min-width: 992px) {
  .discover-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .course-box {
    width: 22%;
  }
}

/* ============================================
   Category Buttons
   ============================================ */

.category-btn {
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  min-height: 44px;
  text-align: center;
  white-space: normal;
}

@media (min-width: 576px) {
  .category-btn {
    width: auto;
    min-width: 180px;
  }
}

/* ============================================
   Modals & Overlays
   ============================================ */

.modal-dialog {
  margin: 1rem;
  max-width: calc(100% - 2rem);
}

.modal-content {
  border-radius: 8px;
}

.modal-header,
.modal-body,
.modal-footer {
  padding: 1rem;
}

@media (min-width: 576px) {
  .modal-dialog {
    margin: 1.75rem auto;
    max-width: 500px;
  }
}

/* ============================================
   Images - Responsive
   ============================================ */

img {
  max-width: 100%;
  height: auto;
}

.banner-image,
.header-image {
  width: 100%;
  height: auto;
}

/* ============================================
   Utilities - Mobile Specific
   ============================================ */

/* Hide on mobile */
.mobile-hide {
  display: none !important;
}

@media (min-width: 992px) {
  .mobile-hide {
    display: block !important;
  }
}

/* Show only on mobile */
.mobile-only {
  display: block !important;
}

@media (min-width: 992px) {
  .mobile-only {
    display: none !important;
  }
}

/* Spacing adjustments */
@media (max-width: 575px) {
  .mb-mobile-2 {
    margin-bottom: 1rem !important;
  }
  
  .mt-mobile-2 {
    margin-top: 1rem !important;
  }
  
  .px-mobile-1 {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }
}

/* Button groups - stack on mobile */
@media (max-width: 767px) {
  .btn-group,
  .btn-toolbar {
    flex-direction: column;
    width: 100%;
  }
  
  .btn-group .btn,
  .btn-toolbar .btn {
    width: 100%;
    margin-bottom: 0.5rem;
    border-radius: 4px;
  }
  
  .btn-group .btn:last-child,
  .btn-toolbar .btn:last-child {
    margin-bottom: 0;
  }
  
  /* Inline button groups */
  .d-flex .btn:not(:last-child) {
    margin-right: 0;
    margin-bottom: 0.5rem;
  }
}

/* Action bars and toolbars */
@media (max-width: 767px) {
  .action-bar,
  .toolbar {
    flex-direction: column;
  }
  
  .action-bar > *,
  .toolbar > * {
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  .action-bar > *:last-child,
  .toolbar > *:last-child {
    margin-bottom: 0;
  }
}

/* ============================================
   Accessibility - Mobile
   ============================================ */

/* Focus indicators */
*:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* Skip link */
.skip-link:focus {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  padding: 1rem;
  background: #000;
  color: #fff;
  text-decoration: none;
}

/* ============================================
   Performance Optimizations
   ============================================ */

/* Smooth scrolling */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* Reduce animations on mobile for performance */
@media (max-width: 767px) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  .navbar,
  .footer,
  .btn,
  .no-print {
    display: none !important;
  }
  
  body {
    font-size: 12pt;
    line-height: 1.5;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
  }
}

