/* Mobile App-Only Styles - Only loads on screens <= 768px and when in PWA mode */
@media (max-width: 768px) and (display-mode: standalone) {

  /* Safe area insets for modern mobile devices */
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    background: #f8fafc;
  }

  /* Hide browser UI elements when in app mode */
  .mobile-hide-in-app {
    display: none !important;
  }

  /* Simplified app-like navigation bar */
  .mobile-app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: linear-gradient(135deg, #059669 0%, #0d9488 100%);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding: 8px 16px;
    padding-top: calc(8px + env(safe-area-inset-top));
    box-shadow: 0 2px 20px rgba(5, 150, 105, 0.3);
    min-height: 48px;
  }

  .mobile-app-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100%;
  }

  .mobile-app-title {
    font-size: 16px;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
  }

  /* Hide complex header elements for cleaner mobile app experience */
  .mobile-app-hide-complex {
    display: none !important;
  }

  /* Bottom navigation for app-like UX */
  .mobile-app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0,0,0,0.1);
    padding: 8px 16px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 20px rgba(0,0,0,0.1);
  }

  .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 12px;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #64748b;
    min-height: 48px;
    min-width: 48px;
  }

  .nav-item:hover {
    background: rgba(5, 150, 105, 0.1);
    color: #059669;
  }

  .nav-item.active {
    background: #059669;
    color: white;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
  }

  .nav-item span {
    font-size: 10px;
    font-weight: 500;
    margin-top: 2px;
  }

  /* App content area with proper spacing */
  .mobile-app-content {
    padding-top: calc(48px + env(safe-area-inset-top));
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
    min-height: 100vh;
    min-height: 100dvh;
  }

  /* Simplified dashboard for mobile app */
  .mobile-app-dashboard {
    padding: 16px;
  }

  .mobile-app-dashboard .stats-grid {
    display: none; /* Hide complex stats on mobile */
  }

  .mobile-app-dashboard .lesson-info-banner {
    display: none; /* Hide info banners for cleaner look */
  }

  /* App-like card design */
  .mobile-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.05);
    margin: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
  }

  .mobile-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  }

  .mobile-card:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  }

  /* Full-screen mobile layouts */
  .mobile-fullscreen {
    min-height: 100vh;
    min-height: 100dvh;
  }

  /* Swipe gestures for navigation */
  .mobile-swipe-container {
    touch-action: pan-y pinch-zoom;
    overscroll-behavior: contain;
  }

  /* App-like button styles */
  .mobile-app-button {
    background: linear-gradient(135deg, #059669 0%, #0d9488 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-weight: 600;
    font-size: 16px;
    min-height: 48px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
  }

  .mobile-app-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
  }

  .mobile-app-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
  }

  /* Loading states for app-like feel */
  .mobile-app-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
  }

  .mobile-app-loader-content {
    text-align: center;
    padding: 20px;
  }

  .mobile-app-loader-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #059669;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
  }

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

  /* Hide scrollbars for app-like feel */
  ::-webkit-scrollbar {
    display: none;
  }

  /* Smooth scrolling */
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  /* Disable text selection in app mode */
  * {
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
  }

  /* Allow text selection in input fields */
  input, textarea, [contenteditable] {
    -webkit-user-select: text;
  }

  /* Custom modal styles for mobile app */
  .mobile-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  .mobile-modal-content {
    background: white;
    border-radius: 20px;
    padding: 24px;
    margin: 16px;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  }

  /* Pull-to-refresh indicator */
  .mobile-pull-refresh {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: #059669;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
  }

  .mobile-pull-refresh.visible {
    opacity: 1;
  }
}

/* Mobile-specific enhancements for all mobile devices */
@media (max-width: 768px) {
  /* Enhanced touch targets for all mobile */
  button, a, [role="button"] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Better mobile typography */
  body {
    font-size: 16px;
    line-height: 1.5;
  }

  /* Mobile-optimized spacing */
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
}
