/**
 * Mobile Optimizations
 * Responsive improvements and touch optimizations
 */

/* Touch-friendly targets */
@media (max-width: 768px) {
  /* Minimum touch target size (44x44px) */
  button, a, input, select, textarea {
    min-height: 44px;
    min-width: 44px;
  }

  /* Larger tap targets for mobile */
  .btn, button {
    padding: 12px 20px;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Prevent text size adjustment on iOS */
  input, select, textarea {
    font-size: 16px;
  }

  /* Swipe gestures */
  .swipeable {
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  /* Mobile navigation */
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px;
    z-index: 1000;
    display: flex;
    justify-content: space-around;
    align-items: center;
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    color: #9ca3af;
    text-decoration: none;
    font-size: 12px;
    transition: color 0.2s;
  }

  .mobile-nav-item.active {
    color: #3b82f6;
  }

  .mobile-nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
  }

  /* Responsive grid */
  .grid {
    grid-template-columns: 1fr;
  }

  .grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Stack on mobile */
  .flex-row {
    flex-direction: column;
  }

  /* Full width on mobile */
  .container {
    padding: 12px;
  }

  /* Mobile-optimized cards */
  .card {
    margin-bottom: 16px;
    padding: 16px;
  }

  /* Hide desktop-only elements */
  .desktop-only {
    display: none !important;
  }

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

  /* Mobile modals */
  .modal {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  /* Touch feedback */
  .touchable {
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.3);
    transition: transform 0.1s, opacity 0.1s;
  }

  .touchable:active {
    transform: scale(0.98);
    opacity: 0.8;
  }

  /* Swipeable cards */
  .swipe-card {
    position: relative;
    overflow: hidden;
  }

  .swipe-card-content {
    transition: transform 0.3s ease;
  }

  /* Pull to refresh */
  .pull-to-refresh {
    position: relative;
    overflow: hidden;
  }

  .pull-to-refresh-indicator {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    transition: top 0.3s;
  }

  .pull-to-refresh.active .pull-to-refresh-indicator {
    top: 20px;
  }

  /* Bottom sheet */
  .bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1f2937;
    border-radius: 20px 20px 0 0;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }

  .bottom-sheet.open {
    transform: translateY(0);
  }

  /* Optimized tables for mobile */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 600px;
  }

  /* Compact spacing */
  .space-y-3 > * + * {
    margin-top: 8px;
  }

  .space-y-4 > * + * {
    margin-top: 12px;
  }

  /* Mobile-optimized charts */
  .chart-container {
    height: 250px;
    overflow-x: auto;
  }

  /* Safe area insets for notched devices */
  .safe-area-top {
    padding-top: env(safe-area-inset-top);
  }

  .safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .safe-area-left {
    padding-left: env(safe-area-inset-left);
  }

  .safe-area-right {
    padding-right: env(safe-area-inset-right);
  }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .mobile-nav {
    display: none;
  }

  .chart-container {
    height: 200px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .icon, .logo {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
  .mobile-nav {
    background: rgba(17, 24, 39, 0.95);
  }
}

