/* Menu Theme Switching CSS */
/* This file handles the light/dark logo switching when scrolling */

/* Force the entire header to use flexbox layout */
.site-header .container {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  flex-direction: row !important;
  position: relative !important;
}

/* Force the navbar to be a flex container */
.navbar.site-navbar {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  flex-direction: row !important;
  width: 100% !important;
  flex-wrap: nowrap !important;
  position: relative !important;
}

/* Ensure the main-menu div itself is a flex container */
#main-menu {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  flex-direction: row !important;
  width: 100% !important;
}

/* CRITICAL: Logo is now OUTSIDE main-menu, use ABSOLUTE positioning to force it left */
.brand-logo {
  position: absolute !important;
  left: 0 !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  display: block !important;
  vertical-align: middle;
  flex-shrink: 0 !important;
  z-index: 1000 !important;
}

.brand-logo img {
  position: relative;
  transition: opacity 0.3s ease;
}

/* Default state - show light logo (dark version), hide dark logo (white version) */
.brand-logo .light-version-logo {
  display: block !important;
}

.brand-logo .dark-version-logo {
  display: none !important;
}

/* Dark theme pages (black header) - show WHITE logo for contrast */
.dark-bg .brand-logo .light-version-logo {
  display: none !important;
}

.dark-bg .brand-logo .dark-version-logo {
  display: block !important;
}

/* When sticky-menu class is added (on scroll), switch to white logo and white text */
header.sofax-header-section.sticky-menu .brand-logo .light-version-logo {
  display: none;
}

header.sofax-header-section.sticky-menu .brand-logo .dark-version-logo {
  display: block;
}

/* Override for light background pages - keep dark logo and dark text when sticky */
header.sofax-header-section:not(.dark-bg).sticky-menu .brand-logo .light-version-logo {
  display: block !important;
}

header.sofax-header-section:not(.dark-bg).sticky-menu .brand-logo .dark-version-logo {
  display: none !important;
}

/* Text color when sticky - default to white */
header.sofax-header-section.sticky-menu .nav-link-item {
  color: #fff !important;
}

header.sofax-header-section.sticky-menu .btn {
  color: #fff !important;
}

/* Login button should ALWAYS stay white */
header.sofax-header-section .v2-login-btn {
  color: #fff !important;
}

header.sofax-header-section.sticky-menu .v2-login-btn {
  color: #fff !important;
}

/* Override for light background pages - keep dark text when sticky */
header.sofax-header-section:not(.dark-bg).sticky-menu .nav-link-item {
  color: #000 !important;
}

header.sofax-header-section:not(.dark-bg).sticky-menu .btn {
  color: #000 !important;
}

/* Login button should ALWAYS stay white on both light and dark backgrounds */
header.sofax-header-section:not(.dark-bg).sticky-menu .v2-login-btn {
  color: #fff !important;
}

/* NEW: Main menu container positioning */
.main-menu-container {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  flex: 1 !important;
  margin-left: auto !important;
  width: 100% !important;
}

/* CRITICAL: Force menu wrapper to be on the right */
.menu-block-wrapper {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  flex: 1 !important;
  margin-left: auto !important;
  /* Force menu to be on the right */
  float: right !important;
  clear: both !important;
}

/* Override any Bootstrap or other framework CSS */
@media (min-width: 992px) {
  .site-navbar {
    flex-flow: row nowrap !important;
    justify-content: flex-end !important;
  }
  
  .site-navbar .menu-block-wrapper {
    display: flex !important;
    flex-basis: auto !important;
  }
  
  /* CRITICAL: Ensure logo is absolutely positioned on the left on desktop */
  .brand-logo {
    position: absolute !important;
    left: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 1000 !important;
  }
  
  /* CRITICAL: Ensure menu is on the right on desktop */
  .main-menu-container {
    float: right !important;
    clear: both !important;
    margin-left: auto !important;
    width: calc(100% - 200px) !important; /* Leave space for logo */
  }
  
  .menu-block-wrapper {
    float: right !important;
    clear: both !important;
    margin-left: auto !important;
  }
}

/* COMPLETELY SEPARATE MOBILE MENU CSS - NO INTERFERENCE WITH DESKTOP */
@media (max-width: 991px) {
  /* Hide the old desktop menu structure on mobile */
  .menu-block-wrapper {
    display: none !important;
  }
  
  /* Show mobile menu trigger on mobile */
  .mobile-menu-trigger {
    display: flex !important;
    height: 30px;
    width: 30px;
    margin-left: auto !important;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    order: 3;
  }
  
  /* Mobile menu trigger styling */
  .mobile-menu-trigger {
    cursor: pointer !important;
    transition: all 0.3s ease;
  }
  
  .mobile-menu-trigger:hover {
    transform: scale(1.1);
  }
  
  .mobile-menu-trigger span {
    display: block;
    height: 2px;
    background-color: #13111A;
    width: 24px;
    position: relative;
    transition: all 0.3s ease;
  }
  
  .mobile-menu-trigger span:before,
  .mobile-menu-trigger span:after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #13111A;
    transition: all 0.3s ease;
  }
  
  .mobile-menu-trigger span:before {
    top: -8px;
  }
  
  .mobile-menu-trigger span:after {
    top: 8px;
  }
  
  /* Dark theme mobile menu trigger */
  .dark-bg .mobile-menu-trigger span,
  .dark-bg .mobile-menu-trigger span:before,
  .dark-bg .mobile-menu-trigger span:after {
    background-color: #fff !important;
  }
  
  /* Sticky menu mobile trigger */
  header.sofax-header-section.sticky-menu .mobile-menu-trigger span,
  header.sofax-header-section.sticky-menu .mobile-menu-trigger span:before,
  header.sofax-header-section.sticky-menu .mobile-menu-trigger span:after {
    background-color: #fff !important;
  }
  
  /* Light background pages - keep dark mobile trigger when sticky */
  header.sofax-header-section:not(.dark-bg).sticky-menu .mobile-menu-trigger span,
  header.sofax-header-section:not(.dark-bg).sticky-menu .mobile-menu-trigger span:before,
  header.sofax-header-section:not(.dark-bg).sticky-menu .mobile-menu-trigger span:after {
    background-color: #000 !important;
  }
}

/* OLD MOBILE MENU SYSTEM COMPLETELY REMOVED */

/* OLD SAFARI FIXES REMOVED - Using new mobile menu system */

/* ADDITIONAL SAFARI FIXES - Target WebKit browsers */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  @media (max-width: 991px) {
    /* Force hide on WebKit browsers (Safari, Chrome on iOS) */
    .mobile-menu-container:not(.active) {
      display: none !important;
      visibility: hidden !important;
      opacity: 0 !important;
      pointer-events: none !important;
      position: absolute !important;
      left: -9999px !important;
      top: -9999px !important;
      width: 0 !important;
      height: 0 !important;
      overflow: hidden !important;
      clip: rect(0, 0, 0, 0) !important;
      /* WebKit-specific hiding */
      -webkit-transform: translate3d(-9999px, -9999px, 0) !important;
      transform: translate3d(-9999px, -9999px, 0) !important;
      -webkit-backface-visibility: hidden !important;
      backface-visibility: hidden !important;
      -webkit-perspective: 1000px !important;
      perspective: 1000px !important;
      /* Additional WebKit hiding */
      -webkit-appearance: none !important;
      -webkit-user-select: none !important;
      user-select: none !important;
    }
    
    .mobile-menu-overlay:not(.active) {
      display: none !important;
      visibility: hidden !important;
      opacity: 0 !important;
      pointer-events: none !important;
      position: absolute !important;
      left: -9999px !important;
      top: -9999px !important;
      width: 0 !important;
      height: 0 !important;
      overflow: hidden !important;
      clip: rect(0, 0, 0, 0) !important;
      /* WebKit-specific hiding */
      -webkit-transform: translate3d(-9999px, -9999px, 0) !important;
      transform: translate3d(-9999px, -9999px, 0) !important;
      -webkit-backface-visibility: hidden !important;
      backface-visibility: hidden !important;
      -webkit-perspective: 1000px !important;
      perspective: 1000px !important;
      /* Additional WebKit hiding */
      -webkit-appearance: none !important;
      -webkit-user-select: none !important;
      user-select: none !important;
    }
    
    .mobile-menu:not(.active) {
      display: none !important;
      visibility: hidden !important;
      opacity: 0 !important;
      pointer-events: none !important;
      position: absolute !important;
      left: -9999px !important;
      top: -9999px !important;
      width: 0 !important;
      height: 0 !important;
      overflow: hidden !important;
      clip: rect(0, 0, 0, 0) !important;
      /* WebKit-specific hiding */
      -webkit-transform: translate3d(-9999px, -9999px, 0) !important;
      transform: translate3d(-9999px, -9999px, 0) !important;
      -webkit-backface-visibility: hidden !important;
      backface-visibility: hidden !important;
      -webkit-perspective: 1000px !important;
      perspective: 1000px !important;
      /* Additional WebKit hiding */
      -webkit-appearance: none !important;
      -webkit-user-select: none !important;
      user-select: none !important;
    }
  }
}

/* ADDITIONAL MOBILE FORCE HIDING - Target specific mobile user agents */
@media screen and (max-width: 991px) {
  /* Force hide any mobile menu that might be showing */
  .mobile-menu-container:not(.active) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
  }
  
  .mobile-menu-overlay:not(.active) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
  }
  
  .mobile-menu:not(.active) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
  }
}

@media (min-width: 992px) {
  /* Hide mobile menu on desktop */
  .mobile-menu-container {
    display: none !important;
  }
  
  /* Show desktop menu on desktop */
  .menu-block-wrapper {
    display: flex !important;
  }
}

/* Additional responsive breakpoints */
@media (max-width: 767px) {
  .mobile-menu-trigger {
    margin-left: 15px !important;
  }
  
  .mobile-menu {
    width: 100% !important;
  }
}

@media (max-width: 575px) {
  .mobile-menu-trigger {
    margin-left: 10px !important;
  }
  
  .brand-logo {
    margin-right: 15px !important;
  }
}

/* FIXED MOBILE MENU CSS - Safari iOS Compatible */

/* Mobile Menu Container - Hidden by default */
.mobile-menu-container-fixed {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  /* Safari iOS specific fixes */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.mobile-menu-container-fixed.active {
  display: block;
  opacity: 1;
  visibility: visible;
}

/* Mobile Menu Overlay */
.mobile-menu-overlay-fixed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  z-index: 1;
}

/* Mobile Menu */
.mobile-menu-fixed {
  position: fixed;
  top: 0;
  left: -100%;
  width: 280px;
  height: 100%;
  background: #ffffff;
  transition: left 0.3s ease;
  overflow-y: auto;
  z-index: 2;
  /* Safari iOS specific fixes */
  -webkit-overflow-scrolling: touch;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.mobile-menu-container-fixed.active .mobile-menu-fixed {
  left: 0;
}

/* Mobile Menu Header */
.mobile-menu-header-fixed {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  position: sticky;
  top: 0;
  z-index: 10;
}

.mobile-menu-title-fixed {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.mobile-menu-close-fixed {
  background: none;
  border: none;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
  /* Ensure clickable in Safari */
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.mobile-menu-close-fixed:hover,
.mobile-menu-close-fixed:active {
  background: #e9ecef;
}

/* Mobile Menu Navigation */
.mobile-menu-nav-fixed {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-menu-item-fixed {
  border-bottom: 1px solid #f1f3f4;
}

.mobile-menu-link-fixed {
  display: block;
  padding: 15px 20px;
  color: #333;
  text-decoration: none;
  font-size: 16px;
  transition: background-color 0.2s ease;
  /* Ensure clickable in Safari */
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.mobile-menu-link-fixed:hover,
.mobile-menu-link-fixed:active {
  background: #f8f9fa;
}

/* Dropdown Triggers */
.mobile-dropdown-trigger-fixed {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mobile-dropdown-trigger-fixed i {
  transition: transform 0.3s ease;
}

.mobile-dropdown-trigger-fixed.active i {
  transform: rotate(180deg);
}

/* Mobile Submenu */
.mobile-submenu-fixed {
  display: none;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
}

.mobile-submenu-fixed.active {
  display: block;
}

.mobile-submenu-fixed li {
  border-bottom: 1px solid #e9ecef;
}

.mobile-submenu-fixed a {
  padding: 12px 20px 12px 40px;
  color: #666;
  text-decoration: none;
  display: block;
  font-size: 14px;
  /* Ensure clickable in Safari */
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.mobile-submenu-fixed a:hover,
.mobile-submenu-fixed a:active {
  background: #e9ecef;
}

/* Mobile Login Button */
.mobile-login-btn-fixed {
  background: linear-gradient(135deg, #236292 0%, #581c87 100%);
  color: white !important;
  text-align: center;
  font-weight: 600;
}

/* Mobile Styles Only */
@media (max-width: 991px) {
  .mobile-menu-container-fixed {
    display: block;
  }
  
  /* Hide desktop menu on mobile */
  .menu-block-wrapper {
    display: none !important;
  }
}

/* Desktop Styles */
@media (min-width: 992px) {
  .mobile-menu-container-fixed {
    display: none !important;
  }
}

/* Safari iOS Specific Fixes */
@supports (-webkit-touch-callout: none) {
  .mobile-menu-container-fixed {
    /* Force hardware acceleration for Safari */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000px;
    perspective: 1000px;
    
    /* Additional Safari iOS compatibility fixes */
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    -webkit-overflow-scrolling: touch;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    
    /* Fix for Safari iOS viewport height issues */
    height: 100vh;
    height: -webkit-fill-available;
    height: fill-available;
    
    /* Ensure proper stacking context */
    z-index: 9999 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
  }

  .mobile-menu-fixed {
    /* Safari-specific positioning */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000px;
    perspective: 1000px;
    
    /* Additional hardware acceleration */
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
  }

  .mobile-menu-close-fixed,
  .mobile-menu-link-fixed,
  .mobile-submenu-fixed a {
    /* Prevent text selection and improve touch response */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }
  
  /* Ensure touch events work properly on all elements */
  .mobile-menu-container-fixed * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  
  /* Fix for Safari iOS position: fixed issues */
  .mobile-menu-container-fixed {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
  }
}

/* Prevent body scroll when menu is open */
body.menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* Additional Safari iOS version compatibility */
@supports (-webkit-touch-callout: none) {
  /* iOS 15+ specific fixes */
  @supports (height: 100dvh) {
    .mobile-menu-container-fixed {
      height: 100dvh;
    }
  }
  
  /* iOS 14+ specific fixes */
  @supports (height: 100vh) and (height: -webkit-fill-available) {
    .mobile-menu-container-fixed {
      height: 100vh;
      height: -webkit-fill-available;
    }
  }
  
  /* Force Safari to respect our positioning */
  .mobile-menu-container-fixed {
    -webkit-transform: translate3d(0, 0, 0) !important;
    transform: translate3d(0, 0, 0) !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    -webkit-perspective: 1000px !important;
    perspective: 1000px !important;
  }
  
  /* Ensure menu is always on top */
  .mobile-menu-container-fixed.active {
    z-index: 99999 !important;
  }
}

/* iPhone 15 Pro and newer model specific fixes */
@supports (-webkit-touch-callout: none) {
  /* Detect newer iPhone models with higher resolution displays */
  @media screen and (min-resolution: 3dppx) {
    .mobile-menu-container-fixed {
      /* Force newer rendering approach for iPhone 15 Pro */
      -webkit-transform: translate3d(0, 0, 0) !important;
      transform: translate3d(0, 0, 0) !important;
      -webkit-backface-visibility: hidden !important;
      backface-visibility: hidden !important;
      -webkit-perspective: 1000px !important;
      perspective: 1000px !important;
      
      /* iPhone 15 Pro specific positioning */
      position: fixed !important;
      top: 0 !important;
      left: 0 !important;
      right: 0 !important;
      bottom: 0 !important;
      width: 100% !important;
      height: 100% !important;
      height: 100vh !important;
      height: 100dvh !important;
      
      /* Force hardware acceleration for newer GPU */
      -webkit-transform-style: preserve-3d !important;
      transform-style: preserve-3d !important;
      -webkit-transform-origin: 0 0 !important;
      transform-origin: 0 0 !important;
      
      /* Enhanced z-index for newer Safari */
      z-index: 999999 !important;
    }
    
    .mobile-menu-container-fixed.active {
      z-index: 9999999 !important;
    }
    
    /* iPhone 15 Pro touch event fixes */
    .mobile-menu-container-fixed * {
      -webkit-touch-callout: none !important;
      -webkit-user-select: none !important;
      user-select: none !important;
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
    }
  }
  
  /* Alternative detection for iPhone 15 Pro */
  @media screen and (min-width: 393px) and (max-width: 430px) {
    .mobile-menu-container-fixed {
      /* iPhone 15 Pro screen size specific fixes */
      -webkit-transform: translate3d(0, 0, 0) !important;
      transform: translate3d(0, 0, 0) !important;
      position: fixed !important;
      z-index: 999999 !important;
    }
  }
}
