/* 📱 Mobile-First Responsive CSS for MemeX Dashboard
 * This file provides comprehensive mobile responsiveness for all dashboard pages
 */

/* Base mobile-friendly defaults */
* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Touch-friendly button and link sizing */
button, 
.btn, 
a[role="button"] {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}

/* Responsive images and media */
img, 
video, 
iframe {
  max-width: 100%;
  height: auto;
}

/* Mobile Navigation */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1002;
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(10px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.mobile-nav-toggle:hover {
  background: rgba(42, 42, 42, 0.95);
  transform: scale(1.05);
}

.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-overlay.active {
  display: block;
  opacity: 1;
}

/* Responsive breakpoints */

/* Large tablets and small laptops */
@media (max-width: 1024px) {
  .container, .max-w-7xl, .max-w-6xl, .max-w-5xl {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
  
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Text size adjustments */
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
}

/* Tablets */
@media (max-width: 768px) {
  .mobile-nav-toggle {
    display: block;
  }
  
  /* Container adjustments */
  .container, .max-w-7xl, .max-w-6xl, .max-w-5xl, .max-w-4xl {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  /* Grid layouts become single column */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .md\\:grid-cols-2,
  .md\\:grid-cols-3,
  .md\\:grid-cols-4 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  /* Sidebar handling */
  .sidebar,
  .sidebar-fixed,
  .navigation-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    z-index: 1001;
    transition: left 0.3s ease;
    overflow-y: auto;
  }
  
  .sidebar.open,
  .sidebar-fixed.open,
  .navigation-sidebar.open {
    left: 0;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
  }
  
  /* Main content adjustments */
  .main-content,
  .content-main,
  .dashboard-main {
    margin-left: 0;
    width: 100%;
    padding-top: 4rem; /* Space for mobile toggle */
  }
  
  /* Header adjustments */
  .header,
  .page-header,
  .content-header {
    padding: 1rem;
    padding-left: 4rem; /* Space for mobile menu button */
  }
  
  /* Card and panel adjustments */
  .card, .panel, .glass-effect {
    margin: 0.5rem 0;
    border-radius: 0.75rem;
  }
  
  /* Button adjustments */
  .btn, button {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    width: auto;
  }
  
  .btn-group {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .btn-group .btn {
    width: 100%;
  }
  
  /* Table responsiveness */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
  }
  
  .table-responsive table {
    min-width: 600px;
  }
  
  /* Modal adjustments */
  .modal-content {
    margin: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }
  
  /* Navigation adjustments */
  .nav-horizontal {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .nav-tabs {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  /* Form adjustments */
  .form-row {
    flex-direction: column;
  }
  
  .form-group {
    margin-bottom: 1rem;
  }
  
  /* Stats grid */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  /* Chart containers */
  .chart-container {
    height: 250px;
    margin: 1rem 0;
  }
}

/* Mobile phones */
@media (max-width: 480px) {
  /* Container adjustments */
  .container, .max-w-7xl, .max-w-6xl, .max-w-5xl, .max-w-4xl {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  /* Typography scaling */
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  h3 { font-size: 1.125rem; }
  h4 { font-size: 1rem; }
  
  .text-3xl { font-size: 1.5rem; }
  .text-2xl { font-size: 1.25rem; }
  .text-xl { font-size: 1.125rem; }
  .text-lg { font-size: 1rem; }
  
  /* Sidebar full width on small screens */
  .sidebar,
  .sidebar-fixed,
  .navigation-sidebar {
    width: 100%;
    left: -100%;
  }
  
  .sidebar.open,
  .sidebar-fixed.open,
  .navigation-sidebar.open {
    left: 0;
  }
  
  /* Header adjustments */
  .header,
  .page-header,
  .content-header {
    padding: 0.75rem;
    padding-left: 3.5rem;
  }
  
  /* Single column stats */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  /* Button adjustments */
  .btn, button {
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  /* Action groups */
  .action-group,
  .button-group {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  /* Card padding */
  .card, .panel, .glass-effect {
    padding: 1rem;
  }
  
  /* Modal full screen on mobile */
  .modal-content {
    margin: 0;
    border-radius: 0;
    max-height: 100vh;
    height: 100vh;
  }
  
  /* Table adjustments */
  .table-responsive table {
    font-size: 0.875rem;
  }
  
  .table-responsive th,
  .table-responsive td {
    padding: 0.5rem 0.25rem;
  }
  
  /* Hide less important columns on very small screens */
  .table-responsive .hide-mobile {
    display: none;
  }
  
  /* Navigation items */
  .nav-item {
    font-size: 0.875rem;
    padding: 0.75rem;
  }
  
  /* Input adjustments */
  input, select, textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.75rem;
  }
  
  /* Chart adjustments */
  .chart-container {
    height: 200px;
  }
}

/* Landscape phones */
@media (max-width: 812px) and (orientation: landscape) {
  .sidebar,
  .sidebar-fixed,
  .navigation-sidebar {
    width: 240px;
  }
  
  .modal-content {
    max-height: 90vh;
    overflow-y: auto;
  }
}

/* Touch-specific improvements */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .hover\\:bg-gray-700:hover,
  .hover\\:bg-gray-600:hover,
  .hover\\:text-white:hover {
    background-color: inherit;
    color: inherit;
  }
  
  /* Add active states for better touch feedback */
  .btn:active,
  button:active,
  .nav-link:active {
    transform: scale(0.98);
    opacity: 0.8;
  }
  
  /* Larger touch targets */
  .touch-target {
    min-height: 44px;
    min-width: 44px;
  }
}

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

/* Print styles for mobile */
@media print {
  .mobile-nav-toggle,
  .mobile-overlay,
  .sidebar,
  .nav-tabs,
  .btn {
    display: none !important;
  }
  
  .main-content {
    margin: 0;
    padding: 0;
  }
}

/* Utility classes for mobile */
.mobile-only {
  display: none;
}

.desktop-only {
  display: block;
}

@media (max-width: 768px) {
  .mobile-only {
    display: block;
  }
  
  .desktop-only {
    display: none;
  }
  
  .mobile-hidden {
    display: none;
  }
  
  .mobile-full-width {
    width: 100%;
  }
  
  .mobile-center {
    text-align: center;
  }
  
  .mobile-stack {
    flex-direction: column;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .mobile-overlay,
  .modal-content {
    transition: none;
  }
  
  .floating-animation,
  .pulse-glow {
    animation: none;
  }
}

/* Focus styles for keyboard navigation */
button:focus,
.btn:focus,
.nav-link:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #8b5cf6;
  outline-offset: 2px;
}

/* Dark mode specific mobile adjustments */
@media (prefers-color-scheme: dark) {
  .mobile-nav-toggle {
    background: rgba(15, 15, 15, 0.95);
    border-color: rgba(255, 255, 255, 0.15);
  }
}
