/* ========================================
   SOHOCHEQ MOBILE OPTIMIZATION
   Critical fixes for mobile responsiveness
   ======================================== */

/* 1. PREVENT HORIZONTAL SCROLL (Critical Fix) */
html,
body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  position: relative !important;
}

* {
  box-sizing: border-box;
}

/* 2. HERO INPUT - MAKE MOBILE FRIENDLY */
@media (max-width: 768px) {
  /* Stack input and button vertically */
  header .flex {
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }

  #url-input {
    width: 100% !important;
    font-size: 16px !important; /* Prevents iOS zoom */
    padding: 16px !important;
    border-radius: 12px !important;
    height: 56px !important;
  }

  #analyze-btn {
    width: 100% !important;
    margin-left: 0 !important;
    padding: 16px !important;
    font-size: 16px !important;
    height: 56px !important;
    border-radius: 12px !important;
  }

  /* Fix header padding */
  header {
    padding: 16px !important;
  }

  header h1 {
    font-size: 2rem !important;
    line-height: 1.2 !important;
  }

  header p {
    font-size: 1rem !important;
  }
}

/* 3. INFLUENCER SCOREBOARD - MOBILE RESPONSIVE */
@media (max-width: 1200px) {
  #influencer-scoreboard {
    margin: 30px 16px !important;
    padding: 24px 16px !important;
  }

  .viral-metrics-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
  }
}

@media (max-width: 768px) {
  #influencer-scoreboard {
    margin: 20px 12px !important;
    padding: 20px 12px !important;
    border-radius: 16px !important;
  }

  .viral-metrics-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .viral-metric-card {
    padding: 16px !important;
  }

  .value-number {
    font-size: 36px !important;
  }

  .competitor-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
}

/* 4. SCORE SHOWCASE - FIX MOBILE SIZING */
@media (max-width: 768px) {
  .score-showcase-enhanced {
    width: 100% !important;
    max-width: 380px !important;
    height: auto !important;
    min-height: 400px !important;
    margin: 20px auto !important;
    padding: 20px !important;
  }

  .score-arc-container-enhanced {
    width: 280px !important;
    height: 280px !important;
    margin: 0 auto !important;
  }

  .score-center-glass {
    width: 140px !important;
    height: 140px !important;
  }

  .score-number {
    font-size: 40px !important;
  }

  .score-percent {
    font-size: 20px !important;
  }

  .score-text {
    font-size: 10px !important;
    letter-spacing: 1px !important;
  }

  .score-mini-stats {
    flex-direction: column !important;
    gap: 8px !important;
  }
}

/* 5. DIALS GRID - RESPONSIVE LAYOUT */
@media (max-width: 768px) {
  /* Make dials grid responsive */
  .grid.grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  .dial-container {
    width: 100% !important;
  }

  .dial {
    width: 100% !important;
    max-width: none !important;
  }
}

@media (max-width: 480px) {
  .grid.grid-cols-4 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
}

/* 6. SHARE SECTION - MOBILE FRIENDLY */
@media (max-width: 768px) {
  .share-section {
    padding: 20px 16px !important;
    margin: 20px 12px !important;
  }

  .share-options {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .share-btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 14px !important;
  }

  .share-card {
    width: 100% !important;
    max-width: 320px !important;
    margin: 0 auto !important;
  }
}

/* 7. TIER PROGRESS - MOBILE OPTIMIZATION */
@media (max-width: 768px) {
  .tier-progress-section {
    padding: 20px 12px !important;
    margin: 20px 12px !important;
  }

  .tier-progress {
    padding: 30px 0 20px !important;
  }

  .tier-marker {
    min-width: 50px !important;
  }

  .tier-label {
    font-size: 9px !important;
    white-space: normal !important;
    line-height: 1.2 !important;
    text-align: center !important;
  }

  .tier-score {
    font-size: 8px !important;
  }

  .tier-dot {
    width: 12px !important;
    height: 12px !important;
  }
}

/* 8. TOUCH-FRIENDLY BUTTONS */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  button,
  a,
  .dial,
  .share-btn,
  .compare-btn {
    min-height: 44px !important;
    min-width: 44px !important;
  }

  /* Disable hover effects on touch */
  .card-hover:hover,
  .dial:hover {
    transform: none !important;
  }
}

/* 9. SAFE AREAS FOR NOTCHED DEVICES */
@supports (padding: max(0px)) {
  body {
    padding-left: max(12px, env(safe-area-inset-left)) !important;
    padding-right: max(12px, env(safe-area-inset-right)) !important;
    padding-top: max(12px, env(safe-area-inset-top)) !important;
    padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
  }

  #theme-toggle {
    top: max(16px, env(safe-area-inset-top)) !important;
    left: max(16px, env(safe-area-inset-left)) !important;
  }
}

/* 10. FIX TEXT VISIBILITY IN LIGHT MODE */
html[data-theme="light"] .score-number,
html[data-theme="light"] .score-percent,
html[data-theme="light"] .stat-value,
html[data-theme="light"] .score-text,
html[data-theme="light"] .stat-label {
  color: #0f172a !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* 11. PREVENT IOS ZOOM ON INPUT FOCUS */
@media (max-width: 768px) {
  input,
  select,
  textarea,
  button {
    font-size: 16px !important;
  }
}

/* 12. REDUCE ANIMATIONS ON LOW-END DEVICES */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 13. SIMPLIFY BLUR ON MOBILE FOR PERFORMANCE */
@media (max-width: 768px) {
  .glass-effect,
  .dial-face,
  #influencer-scoreboard {
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
  }

  /* Remove complex animations */
  .influencer-glass-card::before {
    animation: none !important;
  }
}

/* 14. FOOTER - MOBILE STACK */
@media (max-width: 768px) {
  #site-footer {
    padding: 40px 16px 20px !important;
  }

  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }
}

/* 15. CONTAINER MAX-WIDTH FIX */
@media (max-width: 768px) {
  .container,
  .max-w-7xl,
  .max-w-6xl,
  .max-w-4xl,
  .max-w-2xl {
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
}

/* 16. FIX STACKED ELEMENTS OVERFLOW */
@media (max-width: 768px) {
  .score-center-display,
  .score-center-glass,
  .score-arc-container-enhanced {
    max-width: 100% !important;
    overflow: visible !important;
  }
}

/* 17. RESPONSIVE TYPOGRAPHY */
@media (max-width: 768px) {
  h1 {
    font-size: 2rem !important;
  }
  h2 {
    font-size: 1.75rem !important;
  }
  h3 {
    font-size: 1.5rem !important;
  }
  h4 {
    font-size: 1.25rem !important;
  }
  p {
    font-size: 1rem !important;
    line-height: 1.6;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.75rem !important;
  }
  h2 {
    font-size: 1.5rem !important;
  }
  h3 {
    font-size: 1.25rem !important;
  }
}

/* 18. BACKGROUND IMAGE - MOBILE OPTIMIZATION */
@media (max-width: 768px) {
  html[data-theme="light"] body {
    background-attachment: scroll !important;
    background-size: cover !important;
  }

  html[data-theme="dark"] body {
    background-attachment: scroll !important;
  }
}

/* 19. CUSTOM SCROLLBAR */
@media (max-width: 768px) {
  ::-webkit-scrollbar {
    width: 6px;
  }

  ::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
  }
}

/* 20. FOCUS STATES FOR ACCESSIBILITY */
*:focus {
  outline: 2px solid #8b5cf6 !important;
  outline-offset: 2px !important;
}

button:focus,
a:focus,
input:focus {
  outline: 2px solid #ec4899 !important;
  outline-offset: 2px !important;
}
