/* Responsive Fixes for Mobile and Tablet Devices */

/* ============================================
   MOBILE NAVIGATION FIXES
   ============================================ */

/* Fix navigation overflow on small screens */
@media (max-width: 768px) {
  .nav-container {
    padding: 0 var(--space-4);
  }
  
  .nav-links {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Ensure mobile nav bottom doesn't cover content */
  .mobile-nav-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
  }
  
  /* Add padding to main content to prevent overlap */
  main {
    padding-bottom: 80px !important;
  }
  
  /* Ensure footer has space above mobile nav */
  footer {
    margin-bottom: 80px;
  }
  
  /* Fix nav links overflow */
  .nav-links a {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
}

/* ============================================
   STATS GRID FIXES
   ============================================ */

/* Fix stats grid - 4 columns too cramped on mobile */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-4) !important;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr !important;
  }
  
  .stat-card {
    padding: var(--space-4) !important;
  }
}

/* ============================================
   TOOL CARDS FIXES
   ============================================ */

/* Fix tool cards - 280px too wide for small phones */
@media (max-width: 480px) {
  .tools-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-4) !important;
  }
  
  .tool-card {
    padding: var(--space-6) !important;
  }
}

@media (max-width: 768px) and (min-width: 481px) {
  .tools-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ============================================
   HERO SECTION FIXES
   ============================================ */

/* Fix hero two-column layout stacking */
@media (max-width: 968px) {
  .hero .container {
    grid-template-columns: 1fr !important;
    gap: var(--space-8) !important;
  }
  
  .hero-content {
    text-align: center;
  }
  
  .hero-subtitle {
    max-width: 100% !important;
    margin-left: auto;
    margin-right: auto;
  }
  
  .hero-cta {
    justify-content: center;
  }
  
  .hero-trust {
    justify-content: center;
  }
  
  .hero-visual {
    order: -1; /* Show features above content on mobile */
  }
}

/* ============================================
   PROCESS CARDS FIXES
   ============================================ */

/* Fix process cards stacking on tablets */
@media (max-width: 968px) {
  .process-cards {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-6) !important;
  }
}

@media (max-width: 640px) {
  .process-cards {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================
   TOUCH TARGET FIXES (44px minimum)
   ============================================ */

/* Ensure all buttons meet 44px minimum touch target */
@media (max-width: 768px) {
  .btn {
    min-height: 44px;
    min-width: 44px;
    padding: var(--space-3) var(--space-5) !important;
  }
  
  .btn-sm {
    min-height: 44px;
    padding: var(--space-2) var(--space-4) !important;
  }
  
  .btn-lg {
    min-height: 48px;
    padding: var(--space-4) var(--space-6) !important;
  }
  
  /* Navigation buttons */
  .nav-links a {
    min-height: 44px;
    padding: var(--space-3) var(--space-4) !important;
  }
  
  .nav-toggle {
    min-width: 44px;
    min-height: 44px;
    padding: var(--space-3) !important;
  }
  
  /* Mobile nav items */
  .mobile-nav-item {
    min-height: 60px;
    min-width: 60px;
    padding: var(--space-3) !important;
  }
  
  /* Upload boxes - make easier to tap */
  .upload-box {
    min-height: 120px;
  }
  
  .upload-label {
    min-height: 120px;
    padding: var(--space-4) !important;
  }
  
  /* File input labels */
  label[for^="photo"] {
    min-height: 44px;
    cursor: pointer;
  }
  
  /* Remove buttons */
  .remove-btn {
    min-width: 44px;
    min-height: 44px;
    padding: var(--space-2) !important;
    font-size: 1.25rem;
  }
  
  /* Filter chips */
  .filter-chip {
    min-height: 44px;
    padding: var(--space-3) var(--space-4) !important;
  }
  
  /* Search input */
  .search-input {
    min-height: 44px;
    padding: var(--space-3) var(--space-4) !important;
  }
  
  /* Form inputs */
  input[type="email"],
  input[type="text"],
  input[type="file"],
  select,
  textarea {
    min-height: 44px;
    padding: var(--space-3) var(--space-4) !important;
  }
}

/* ============================================
   BREED GRID FIXES
   ============================================ */

@media (max-width: 640px) {
  .breed-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 968px) and (min-width: 641px) {
  .breed-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ============================================
   GUIDES GRID FIXES
   ============================================ */

@media (max-width: 640px) {
  .guides-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================
   ONBOARDING SECTION FIXES
   ============================================ */

@media (max-width: 640px) {
  .onboarding-steps {
    grid-template-columns: 1fr !important;
  }
  
  .onboarding-step {
    flex-direction: column;
    text-align: center;
  }
  
  .step-number {
    margin: 0 auto var(--space-4);
  }
}

/* ============================================
   SEARCH SECTION FIXES
   ============================================ */

@media (max-width: 768px) {
  .breed-search-container {
    padding: 0 var(--space-4);
  }
  
  .search-input-wrapper {
    width: 100%;
    min-width: 100% !important;
  }
  
  .filter-chips {
    gap: var(--space-2) !important;
  }
  
  .filter-chip {
    font-size: 0.8125rem;
    padding: var(--space-2) var(--space-3) !important;
  }
}

/* ============================================
   SCANNER UPLOAD FIXES
   ============================================ */

@media (max-width: 640px) {
  .upload-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-4) !important;
  }
  
  .upload-box {
    min-height: 140px;
  }
  
  .upload-label {
    min-height: 140px;
  }
  
  .photo-review-section {
    padding: var(--space-4) !important;
  }
  
  .review-photos-grid {
    grid-template-columns: 1fr !important;
  }
  
  .review-photo-item {
    min-height: 200px;
  }
}

/* ============================================
   GENERAL MOBILE IMPROVEMENTS
   ============================================ */

@media (max-width: 768px) {
  /* Improve spacing on mobile */
  section {
    padding: var(--space-12) 0 !important;
  }
  
  .section-header {
    margin-bottom: var(--space-8) !important;
  }
  
  /* Better container padding */
  .container {
    padding: 0 var(--space-4) !important;
  }
  
  /* Improve text readability */
  .hero-subtitle {
    font-size: 1.125rem !important;
  }
  
  /* Better button spacing */
  .hero-cta {
    flex-direction: column;
    width: 100%;
  }
  
  .hero-cta .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================
   TABLET SPECIFIC FIXES
   ============================================ */

@media (min-width: 769px) and (max-width: 1024px) {
  .tools-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  .breed-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  .process-cards {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ============================================
   VERY SMALL PHONES (320px - 375px)
   ============================================ */

@media (max-width: 375px) {
  .hero-title {
    font-size: clamp(1.75rem, 8vw, 2.5rem) !important;
  }
  
  .hero-subtitle {
    font-size: 1rem !important;
  }
  
  .btn-lg {
    font-size: 0.9375rem !important;
    padding: var(--space-3) var(--space-5) !important;
  }
  
  .section-header h2 {
    font-size: clamp(1.5rem, 6vw, 2rem) !important;
  }
}

/* ============================================
   LANDSCAPE ORIENTATION FIXES
   ============================================ */

@media (max-width: 768px) and (orientation: landscape) {
  .hero {
    padding: var(--space-12) 0 !important;
  }
  
  .mobile-nav-bottom {
    padding: var(--space-1) 0;
  }
  
  .mobile-nav-item {
    min-height: 50px;
  }
  
  .mobile-nav-item .icon {
    font-size: 1.25rem;
  }
  
  .mobile-nav-item .label {
    font-size: 0.65rem;
  }
}

/* ============================================
   ACCESSIBILITY - TOUCH TARGETS
   ============================================ */

/* Ensure all interactive elements are easily tappable */
@media (pointer: coarse) {
  /* Touch devices */
  a, button, input, select, textarea, label {
    min-height: 44px;
  }
  
  /* Links in cards */
  .tool-card,
  .breed-card,
  .guide-card {
    min-height: 44px;
  }
}
