/**
 * Cross-Browser Compatibility Fixes
 * 
 * Addresses browser-specific rendering differences and provides
 * fallbacks for features not universally supported.
 * 
 * Tested targets: Chrome, Firefox, Safari, Edge, iOS Safari, Android Chrome
 * Requirements: 10.8, 19.1-19.8
 */

/* ========================================
   SAFARI-SPECIFIC FIXES
   ======================================== */

/* Fix Safari flex gap support (older versions) */
@supports not (gap: 1rem) {
  .d-flex > * + *,
  .nav__menu > * + *,
  .hero__actions > * + *,
  .btn-group > * + * {
    margin-left: var(--space-2);
  }
  
  .flex-column > * + *,
  .btn-group--vertical > * + * {
    margin-left: 0;
    margin-top: var(--space-2);
  }
}

/* Fix Safari 100vh issue on iOS (address bar overlap) */
@supports (-webkit-touch-callout: none) {
  .auth-page {
    min-height: -webkit-fill-available;
  }
  
  .map-container {
    height: -webkit-fill-available;
    max-height: calc(100vh - 72px);
  }
}

/* Fix Safari input zoom on focus (font-size < 16px triggers zoom on iOS) */
@media screen and (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px;
  }
}

/* ========================================
   FIREFOX-SPECIFIC FIXES
   ======================================== */

/* Firefox focus-visible outline fix */
::-moz-focus-inner {
  border: 0;
  padding: 0;
}

/* Firefox scrollbar styling for overflow containers */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-neutral-300) transparent;
}

/* Firefox select element arrow fix */
.form-select:-moz-focusring {
  color: transparent;
  text-shadow: 0 0 0 var(--color-neutral-900);
}

/* ========================================
   EDGE / IE LEGACY FIXES
   ======================================== */

/* Clear button in Edge input fields */
input::-ms-clear,
input::-ms-reveal {
  display: none;
}

/* ========================================
   WEBKIT SCROLLBAR STYLING
   ======================================== */

/* Consistent scrollbar styling for WebKit browsers */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-neutral-300);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-neutral-400);
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */

/* Remove tap highlight on mobile WebKit browsers */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Ensure proper touch scrolling behavior */
.nav__menu--open,
.leaflet-sidebar-content,
.table-wrapper {
  -webkit-overflow-scrolling: touch;
}

/* Prevent text size adjustment on orientation change */
html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ========================================
   PRINT MEDIA COMPATIBILITY
   ======================================== */

@media print {
  /* Ensure backgrounds print in all browsers */
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  /* Hide interactive elements */
  .nav__toggle,
  .theme-toggle,
  .toast-container,
  .page-load-indicator {
    display: none !important;
  }
}
