/* ==============================================
   METARENA - MOBILE FIXES CSS
   Apply these fixes across all templates
   ============================================== */

/* ----- iOS Safe Area Support ----- */
@supports (padding: env(safe-area-inset-top)) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
  }
  
  nav.fixed, .nav-header, header.fixed {
    padding-top: calc(env(safe-area-inset-top) + 12px);
  }
  
  footer.fixed, .footer-fixed {
    padding-bottom: calc(env(safe-area-inset-bottom) + 6px);
  }
}

/* ----- Prevent Horizontal Overflow ----- */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* ----- Minimum Touch Targets ----- */
button, a, input, select, textarea {
  min-height: 44px;
}

.btn, .nav-link, .tab-button {
  min-height: 44px;
  padding: 12px 16px;
}

.touch-target {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.btn-icon:hover {
  background: rgba(255,255,255,0.1);
}

/* ----- Text Utilities ----- */
.text-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-size: clamp(1.25rem, 5vw, 2rem);
}

/* ----- Mobile Sidebar Styles ----- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 40;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 35;
  }
  
  .sidebar-overlay.open {
    display: block;
  }
  
  .main-content {
    margin-left: 0 !important;
  }
  
  main, .main-content {
    width: 100%;
    max-width: 100vw;
    padding: 1rem !important;
  }
  
  .desktop-nav {
    display: none !important;
  }
  
  .mobile-toggle {
    display: flex !important;
  }
}

@media (min-width: 769px) {
  .mobile-toggle {
    display: none !important;
  }
  
  .sidebar-overlay {
    display: none !important;
  }
}

/* ----- Mobile Step Indicators ----- */
.step-indicator-mobile {
  display: none;
}

@media (max-width: 768px) {
  .step-indicator-mobile {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
  }
  
  .step-indicator-desktop {
    display: none !important;
  }
  
  .step-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    transition: all 0.3s;
  }
  
  .step-dot.active {
    background: linear-gradient(135deg, #8b5cf6, #06b6d4);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
  }
  
  .step-dot.complete {
    background: #22c55e;
  }
  
  .step-label-mobile {
    text-align: center;
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
  }
}

@media (min-width: 769px) {
  .step-indicator-desktop {
    display: flex !important;
  }
}

/* ----- Modal Mobile Styles ----- */
@media (max-width: 768px) {
  .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  
  .modal-content-center {
    width: calc(100% - 2rem) !important;
    max-height: calc(100vh - 4rem) !important;
    margin: 1rem !important;
    border-radius: 1rem !important;
  }
}

/* ----- Form Input Mobile Styles ----- */
input, select, textarea {
  font-size: 16px; /* Prevents iOS zoom */
}

@media (max-width: 640px) {
  input, select, textarea {
    padding: 0.875rem 1rem;
  }
}

/* ----- Card Responsiveness ----- */
@media (max-width: 640px) {
  .card, .card-glass {
    padding: 1rem;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  h2 {
    font-size: 1.25rem;
  }
}

/* ----- Dynamic Viewport Height ----- */
.min-h-screen {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ----- Tournament Cards Mobile ----- */
@media (max-width: 640px) {
  .tournament-card {
    padding: 1rem;
  }
  
  .tournament-card .game-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
  }
}

/* ----- Bottom Navigation (PWA style) ----- */
.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 0.5rem 1rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    z-index: 40;
    justify-content: space-around;
  }
  
  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.75rem;
  }
  
  .bottom-nav-item.active {
    color: #8b5cf6;
  }
  
  .bottom-nav-item i {
    font-size: 1.25rem;
  }
  
  /* Add padding to body to prevent content from being hidden behind bottom nav */
  body.has-bottom-nav {
    padding-bottom: 70px;
  }
}
