/* ==============================================
   CHIPUKA ACADEMY - MOBILE RESPONSIVE STYLES
   Optimized for Android, iOS, and all mobile devices
   ============================================== */

/* Prevent horizontal scroll on mobile */
html, body {
  overflow-x: hidden;
  max-width: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Mobile-first responsive breakpoints */
@media (max-width: 640px) {
  /* Touch targets - ensure minimum 44px for accessibility */
  button, .btn, a[role="button"], input[type="submit"], input[type="button"] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Form inputs mobile optimization */
  input, select, textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px 16px;
    min-height: 44px;
    border-radius: 6px;
  }

  /* Mobile navigation improvements */
  .mobile-menu {
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    will-change: transform;
  }

  .mobile-menu.open {
    transform: translateX(0);
  }

  /* Hero section mobile optimization */
  .hero-content h1 {
    font-size: 2rem !important;
    line-height: 1.2;
  }

  .hero-content p {
    font-size: 1rem !important;
  }

  .hero-content .btn {
    padding: 12px 24px;
    font-size: 1rem;
  }

  /* Card layouts mobile optimization */
  .card-grid {
    gap: 1rem;
  }

  .card {
    margin-bottom: 1rem;
  }

  /* Table mobile optimization */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    font-size: 0.875rem;
  }

  th, td {
    padding: 8px 12px;
    white-space: nowrap;
  }

  /* Image optimization */
  img {
    max-width: 100%;
    height: auto;
  }

  /* Video responsive */
  video, iframe {
    max-width: 100%;
    height: auto;
  }
}

/* Small mobile devices (320px - 480px) */
@media (max-width: 480px) {
  /* Very small screens */
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Typography adjustments */
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }

  /* Compact card layouts */
  .card-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Smaller buttons */
  .btn {
    padding: 10px 16px;
    font-size: 0.875rem;
  }

  /* Compact forms */
  .form-group {
    margin-bottom: 1rem;
  }

  input, select, textarea {
    padding: 10px 12px;
  }
}

/* Large mobile devices (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
  /* Tablet-like mobile devices */
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Better navigation for larger phones */
  .mobile-nav .nav-item {
    padding: 12px 16px;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .hover\:scale-105:hover {
    transform: none;
  }

  .hover\:shadow-lg:hover {
    box-shadow: var(--shadow-md);
  }

  /* Improve tap targets */
  .nav-link, .btn, .card {
    padding: 12px;
    margin: 4px 0;
  }

  /* Better button feedback */
  .btn:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }

  /* Enhanced touch feedback */
  .btn, .card, .nav-link {
    -webkit-tap-highlight-color: rgba(97, 198, 18, 0.2);
    /* Removed invalid tap-highlight-color property */
  }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  /* iOS doesn't support -webkit-overflow-scrolling on body */
  body {
    -webkit-overflow-scrolling: auto;
  }

  /* Fix iOS input zoom */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px !important;
    transform: translateZ(0); /* Force hardware acceleration */
    -webkit-appearance: none;
    appearance: none; /* Standard property for compatibility */
    border-radius: 6px;
  }

  /* iOS Safari bottom bar fix */
  .mobile-bottom-safe {
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Prevent iOS bounce scroll */
  body {
    position: relative;
    height: 100vh;
    height: -webkit-fill-available;
  }
}

/* Android specific optimizations */
@media screen and (-webkit-min-device-pixel-ratio: 1) {
  /* Android Chrome optimizations */
  .card, .btn {
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
  }

  /* Better scrolling */
  .scroll-smooth {
    -webkit-overflow-scrolling: touch;
  }

  /* Android text rendering */
  body {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
  }
}

/* Landscape orientation optimizations */
@media (orientation: landscape) and (max-height: 500px) {
  /* Compact header for landscape */
  .mobile-header {
    height: 56px;
  }

  /* Reduce hero height */
  .hero-section {
    height: 70vh;
    min-height: 400px;
  }

  /* Compact cards */
  .card {
    padding: 12px;
  }

  .card h3 {
    font-size: 1rem;
  }

  /* Adjust navigation for landscape */
  .mobile-menu {
    max-height: 80vh;
    overflow-y: auto;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Sharper images and borders */
  img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }

  .card {
    border-width: 0.5px;
  }

  /* Better border rendering on high DPI */
  .btn, .card, .form-input {
    border-width: 1px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden; /* Standard property for compatibility */
  }
}

/* Performance optimizations for mobile */
@media (max-width: 768px) {
  /* Reduce animations on mobile for better performance */
  .animate-pulse {
    animation-duration: 2s;
  }

  .transition-all {
    transition-duration: 200ms;
  }

  /* Disable heavy animations */
  .hover\:scale-105 {
    transition: none;
  }

  /* Optimize background images */
  .bg-cover {
    background-attachment: scroll; /* Better performance */
  }

  /* Reduce paint and composite operations */
  .card, .btn {
    will-change: auto;
  }

  /* Optimize transforms */
  .mobile-menu {
    will-change: transform;
  }
}

/* Accessibility improvements for mobile */
@media (max-width: 768px) {
  /* Better focus indicators */
  .btn:focus,
  .nav-link:focus,
  input:focus,
  select:focus,
  textarea:focus {
    outline: 2px solid #61C612;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px rgba(97, 198, 18, 0.2);
  }

  /* Larger text for better readability */
  body {
    font-size: 16px;
    line-height: 1.5;
  }

  /* Better contrast for small text */
  small, .text-xs {
    font-size: 0.875rem;
  }

  /* Ensure minimum touch target sizes */
  [role="button"], button, .btn {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* Print styles (for mobile print) */
@media print {
  /* Hide mobile navigation when printing */
  .mobile-menu,
  .mobile-menu-button {
    display: none !important;
  }

  /* Optimize layout for print */
  .container {
    max-width: none;
    padding: 0;
  }

  /* Ensure text is readable when printed */
  body {
    font-size: 12pt;
    line-height: 1.4;
  }
}

/* Utility classes for mobile */
.mobile-hidden { display: none; }
@media (max-width: 768px) {
  .mobile-hidden { display: none; }
  .desktop-hidden { display: block; }
}

@media (min-width: 769px) {
  .mobile-hidden { display: block; }
  .desktop-hidden { display: none; }
}

/* Mobile-specific components */
.mobile-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  padding: 16px;
  margin-bottom: 16px;
  transition: box-shadow 0.2s ease, transform 0.1s ease;
}

.mobile-card:active {
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transform: translateY(-1px);
}

.mobile-nav-item {
  display: block;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 500;
  color: #374151;
  background: none;
  border: none;
  text-align: left;
  width: 100%;
  min-height: 48px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.mobile-nav-item:hover {
  background-color: #f3f4f6;
}

.mobile-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 16px;
  min-height: 44px;
  background: white;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mobile-input:focus {
  outline: none;
  border-color: #61C612;
  box-shadow: 0 0 0 3px rgba(97, 198, 18, 0.1);
}

.mobile-button {
  width: 100%;
  background: #61C612;
  color: white;
  padding: 12px 16px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  min-height: 44px;
  transition: background-color 0.2s ease, transform 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mobile-button:active {
  background: #4CAF50;
  transform: scale(0.98);
}

.mobile-button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
}

/* Loading states for mobile */
.mobile-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.mobile-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e7eb;
  border-top: 3px solid #61C612;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Enhanced mobile grid system */
.mobile-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .mobile-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .mobile-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Mobile-optimized spacing */
.mobile-section {
  padding: 2rem 1rem;
}

@media (min-width: 640px) {
  .mobile-section {
    padding: 3rem 1.5rem;
  }
}

@media (min-width: 1024px) {
  .mobile-section {
    padding: 4rem 2rem;
  }
}

/* Improved mobile typography scale */
.mobile-heading-1 {
  font-size: 1.75rem;
  line-height: 1.2;
  font-weight: 700;
}

.mobile-heading-2 {
  font-size: 1.5rem;
  line-height: 1.3;
  font-weight: 600;
}

.mobile-heading-3 {
  font-size: 1.25rem;
  line-height: 1.4;
  font-weight: 600;
}

@media (min-width: 640px) {
  .mobile-heading-1 {
    font-size: 2rem;
  }

  .mobile-heading-2 {
    font-size: 1.75rem;
  }

  .mobile-heading-3 {
    font-size: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .mobile-heading-1 {
    font-size: 2.5rem;
  }

  .mobile-heading-2 {
    font-size: 2rem;
  }

  .mobile-heading-3 {
    font-size: 1.75rem;
  }
}

/* Mobile-safe area handling */
@supports (padding: max(0px)) {
  .mobile-safe-top {
    padding-top: max(1rem, env(safe-area-inset-top));
  }

  .mobile-safe-bottom {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .mobile-safe-left {
    padding-left: max(1rem, env(safe-area-inset-left));
  }

  .mobile-safe-right {
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) {
  .mobile-card {
    background: #1f2937;
    color: white;
  }

  .mobile-input {
    background: #374151;
    border-color: #4b5563;
    color: white;
  }

  .mobile-nav-item {
    color: #f9fafb;
  }

  .mobile-nav-item:hover {
    background-color: #374151;
  }
}
