/* Critical Mobile Fixes for Zero Bot Website */

/* Force override for mobile layouts */
@media (max-width: 768px) {
  /* CRITICAL: Override any grid that breaks mobile */
  div[style*="grid-template-columns"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5rem !important;
  }

  /* CRITICAL: Fix the specific problematic grid */
  div[style*="minmax(500px, 1fr)"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5rem !important;
  }

  div[style*="minmax(350px, 1fr)"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5rem !important;
  }

  div[style*="minmax(300px, 1fr)"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5rem !important;
  }

  /* CRITICAL: Prevent any horizontal overflow */
  * {
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
  }

  /* CRITICAL: Fix containers that break mobile */
  div[style*="max-width: 1200px"] {
    max-width: 100% !important;
    padding: 0 1rem !important;
    margin: 0 auto !important;
  }

  /* CRITICAL: Fix large text that overflows */
  h1[style*="font-size: 4rem"] {
    font-size: 2rem !important;
    line-height: 1.2 !important;
    text-align: center !important;
    word-wrap: break-word !important;
  }

  h2[style*="font-size: 3rem"] {
    font-size: 1.5rem !important;
    line-height: 1.3 !important;
    text-align: center !important;
    word-wrap: break-word !important;
  }

  h1[style*="font-size: 3rem"] {
    font-size: 1.75rem !important;
    line-height: 1.2 !important;
  }

  h2[style*="font-size: 2rem"] {
    font-size: 1.25rem !important;
    line-height: 1.3 !important;
  }

  /* CRITICAL: Fix buttons that extend beyond screen */
  a[style*="padding: 1rem 2rem"] {
    padding: 0.875rem 1rem !important;
    font-size: 0.9rem !important;
    width: 90% !important;
    max-width: 280px !important;
    margin: 0.5rem auto !important;
    display: block !important;
    text-align: center !important;
    word-wrap: break-word !important;
  }

  /* CRITICAL: Fix cards that overflow */
  div[style*="background: #1f2937"] {
    margin: 1rem 0 !important;
    padding: 1rem !important;
    max-width: 100% !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }

  /* CRITICAL: Fix hero section */
  div[style*="min-height: 90vh"] {
    min-height: auto !important;
    padding: 2rem 0 !important;
  }

  /* CRITICAL: Fix flex items that break layout */
  div[style*="display: flex; align-items: center"] {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
  }

  /* CRITICAL: Reduce gap spacing */
  div[style*="gap: 4rem"] {
    gap: 1.5rem !important;
  }

  div[style*="gap: 3rem"] {
    gap: 1rem !important;
  }

  div[style*="gap: 2rem"] {
    gap: 0.75rem !important;
  }

  /* CRITICAL: Fix padding that makes content too wide */
  div[style*="padding: 6rem 0"] {
    padding: 2rem 0 !important;
  }

  div[style*="padding: 4rem 0"] {
    padding: 1.5rem 0 !important;
  }

  div[style*="padding: 3rem 0"] {
    padding: 1.5rem 0 !important;
  }

  div[style*="padding: 0 2rem"] {
    padding: 0 1rem !important;
  }

  /* CRITICAL: Ensure text content wraps */
  p, span, div, h1, h2, h3, h4, h5, h6 {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: auto !important;
  }

  /* CRITICAL: Fix command tables specifically */
  table[style*="width: 100%"] {
    display: block !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
  }

  table[style*="width: 100%"] tbody {
    display: block !important;
  }

  table[style*="width: 100%"] tr {
    display: block !important;
    margin-bottom: 1rem !important;
    background: #1f2937 !important;
    border: 1px solid #374151 !important;
    border-radius: 0.5rem !important;
    padding: 1rem !important;
    white-space: normal !important;
  }

  table[style*="width: 100%"] td {
    display: block !important;
    width: 100% !important;
    padding: 0.5rem 0 !important;
    border: none !important;
    white-space: normal !important;
  }

  /* CRITICAL: Fix command page containers */
  div[style*="background: #1f2937"][style*="border-radius: 0.75rem"] {
    margin: 1rem 0 !important;
    overflow: visible !important;
  }

  div[style*="background: #1f2937"] div[style*="padding: 2rem"] {
    padding: 1rem !important;
  }

  /* CRITICAL: Ensure profile username shows on mobile */
  nav a[href="/profile"] span {
    display: inline !important;
    max-width: 100px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
}

/* Extra small devices */
@media (max-width: 480px) {
  body {
    font-size: 14px !important;
  }

  h1 {
    font-size: 2rem !important;
  }

  h2 {
    font-size: 1.5rem !important;
  }

  div[style*="padding: 2rem"] {
    padding: 1rem !important;
  }

  div[style*="padding: 3rem"] {
    padding: 1.5rem !important;
  }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
  div[style*="min-height: 90vh"] {
    min-height: 100vh !important;
    padding: 2rem 0 !important;
  }
}
