/* iOS Safe Area and Mobile Fixes */

/* iOS Safe Area Support for devices with notches and rounded corners */
.ios-safe-area {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Safe area insets for specific sides */
.ios-safe-top {
  padding-top: env(safe-area-inset-top);
}

.ios-safe-bottom {
  padding-bottom: env(safe-area-inset-bottom);
}

.ios-safe-left {
  padding-left: env(safe-area-inset-left);
}

.ios-safe-right {
  padding-right: env(safe-area-inset-right);
}

/* Modal container that respects safe areas */
.mobile-modal-container {
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile browsers */
  padding-top: max(env(safe-area-inset-top), 1rem);
  padding-bottom: max(env(safe-area-inset-bottom), 1rem);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Full screen modal that accounts for safe areas */
.fullscreen-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Prominent close button optimized for mobile */
.mobile-close-button {
  position: fixed;
  top: max(env(safe-area-inset-top), 0.5rem);
  right: max(env(safe-area-inset-right), 1rem);
  z-index: 9999;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px); /* Safari support */
  border-radius: 50%;
  width: 44px; /* iOS Human Interface Guidelines minimum touch target */
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-close-button:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.05);
}

.mobile-close-button:active {
  transform: scale(0.95);
}

/* Alternative close button styles */
.mobile-close-button-light {
  background: rgba(255, 255, 255, 0.9);
  color: #374151;
}

.mobile-close-button-brand {
  background: rgba(1, 97, 135, 0.9); /* Using the brand color from the app */
  color: white;
}

/* Responsive visibility classes */
@media (max-width: 768px) {
  .mobile-only {
    display: block !important;
  }
  
  .desktop-only {
    display: none !important;
  }
  
  .mobile-close-button {
    display: flex;
  }
  
  .desktop-close-button {
    display: none;
  }
}

@media (min-width: 769px) {
  .mobile-only {
    display: none !important;
  }
  
  .desktop-only {
    display: block !important;
  }
  
  .mobile-close-button {
    display: none;
  }
  
  .desktop-close-button {
    display: block;
  }
}

/* Fix for modals that might be cut off on mobile */
.mobile-modal-fix {
  max-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 2rem);
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 2rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Prevent content from being hidden behind status bar */
.avoid-status-bar {
  margin-top: env(safe-area-inset-top);
}

/* For fixed headers that need to account for the notch */
.fixed-header-safe {
  position: fixed;
  top: env(safe-area-inset-top);
  left: env(safe-area-inset-left);
  right: env(safe-area-inset-right);
}

/* For sticky elements that should stick below the safe area */
.sticky-safe {
  position: sticky;
  top: env(safe-area-inset-top);
}

/* Utility for content that should fill safe area */
.fill-safe-area {
  height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}