/* ============================================
   World-Class Modern Language Switcher
   Inspired by Apple, Stripe, Linear
   ============================================ */

.main-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.main-nav ul {
  display: inline-flex;
  align-items: center;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  margin-left: 20px;
  direction: ltr !important;
  position: relative;
}

/* Keep switcher fixed in place for RTL */
body.lang-ar .language-switcher {
  direction: ltr !important;
  order: 2;
  margin-left: 20px;
  margin-right: 0;
}

body.lang-ar .main-nav {
  direction: ltr !important;
}

body.lang-ar .main-nav ul {
  direction: rtl;
}

/* Dropdown Container */
.lang-dropdown {
  position: relative;
}

/* Current Language Button */
.lang-current {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #333;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.lang-current:hover {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.lang-dropdown.open .lang-current {
  background: #fff;
  border-color: #FF5126;
  box-shadow: 0 0 0 3px rgba(255, 81, 38, 0.1);
}

/* Globe Icon */
.globe-icon {
  width: 18px;
  height: 18px;
  color: #666;
  transition: all 0.25s ease;
}

.lang-current:hover .globe-icon,
.lang-dropdown.open .globe-icon {
  color: #FF5126;
}

/* Current Language Text */
.current-lang {
  font-weight: 600;
  letter-spacing: 0.5px;
  font-size: 12px;
}

/* Chevron Icon */
.chevron-icon {
  width: 14px;
  height: 14px;
  color: #999;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lang-dropdown.open .chevron-icon {
  transform: rotate(180deg);
  color: #FF5126;
}

/* Dropdown Menu */
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 
    0 0 0 1px rgba(0, 0, 0, 0.04),
    0 4px 6px -1px rgba(0, 0, 0, 0.08),
    0 20px 40px -10px rgba(0, 0, 0, 0.18);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.96);
  transform-origin: top right;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  overflow: hidden;
}

/* Menu entrance animation */
.lang-dropdown.open .lang-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Language Option */
.lang-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  transition: all 0.2s ease;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.lang-option:hover {
  background: rgba(0, 0, 0, 0.04);
}

.lang-option.active {
  background: linear-gradient(135deg, rgba(255, 81, 38, 0.08) 0%, rgba(255, 81, 38, 0.04) 100%);
}

.lang-option.active:hover {
  background: linear-gradient(135deg, rgba(255, 81, 38, 0.12) 0%, rgba(255, 81, 38, 0.08) 100%);
}

/* Flag in dropdown */
.lang-option .fi {
  font-size: 20px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s ease;
}

.lang-option:hover .fi {
  transform: scale(1.1);
}

/* Language Name */
.lang-name {
  flex: 1;
  font-weight: 500;
  transition: color 0.2s ease;
}

.lang-option.active .lang-name {
  color: #FF5126;
  font-weight: 600;
}

/* Check Icon */
.check-icon {
  width: 18px;
  height: 18px;
  color: #FF5126;
  opacity: 0;
  transform: scale(0.5) rotate(-10deg);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lang-option.active .check-icon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Hover line effect */
.lang-option::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: #FF5126;
  border-radius: 0 3px 3px 0;
  transition: height 0.2s ease;
}

.lang-option.active::before {
  height: 24px;
}

/* Ripple effect on options */
.lang-option::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 81, 38, 0.12);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.5s ease, height 0.5s ease;
}

.lang-option:active::after {
  width: 300px;
  height: 300px;
  transition: width 0s, height 0s;
}

/* Stagger animation for menu items */
.lang-dropdown.open .lang-option {
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.lang-dropdown.open .lang-option:nth-child(1) {
  animation-delay: 0.05s;
}

.lang-dropdown.open .lang-option:nth-child(2) {
  animation-delay: 0.1s;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Mobile Responsive */

/* Desktop only - hide on mobile */
.language-switcher.desktop-only {
  display: inline-flex;
}

/* Mobile only - hidden by default, show on mobile */
.language-switcher.mobile-only {
  display: none;
  position: fixed;
  top: 15px;
  right: 15px;
  left: auto !important;
  z-index: 9999;
  direction: ltr !important;
}

/* Keep mobile switcher fixed - don't change for RTL */
body.lang-ar .language-switcher.mobile-only {
  right: 15px;
  left: auto !important;
  direction: ltr !important;
}

@media screen and (max-width: 768px) {
  /* Hide desktop switcher */
  .language-switcher.desktop-only {
    display: none !important;
  }
  
  /* Show mobile switcher */
  .language-switcher.mobile-only {
    display: inline-flex !important;
  }
  
  .language-switcher.mobile-only .lang-current {
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.08);
  }
  
  .language-switcher.mobile-only .globe-icon {
    width: 18px;
    height: 18px;
  }
  
  .language-switcher.mobile-only .current-lang {
    font-size: 13px;
    font-weight: 600;
  }
  
  .language-switcher.mobile-only .chevron-icon {
    width: 14px;
    height: 14px;
  }
  
  .language-switcher.mobile-only .lang-menu {
    min-width: 180px;
    right: 0;
    left: auto !important;
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  }
  
  body.lang-ar .language-switcher.mobile-only .lang-menu {
    right: 0;
    left: auto !important;
  }
  
  .language-switcher.mobile-only .lang-option {
    padding: 12px 14px;
    border-radius: 12px;
  }
  
  .language-switcher.mobile-only .lang-option .fi {
    font-size: 20px;
  }
  
  .language-switcher.mobile-only .lang-name {
    font-size: 14px;
  }
}

/* Fix MSA logo position when language changes */
#ubea-logo {
  position: relative;
  z-index: 10;
}

#ubea-logo a {
  display: flex;
  align-items: center;
  text-decoration: none;
  position: relative;
}

#ubea-logo .logo-img {
  margin-right: 8px;
  position: relative;
  z-index: 1;
}

#ubea-logo em {
  font-style: normal;
  font-weight: 600;
  color: #333;
  position: relative;
  z-index: 1;
}

/* Ensure logo stays in place for both languages */
body.lang-ar #ubea-logo {
  direction: ltr;
  text-align: left;
}

body.lang-ar #ubea-logo a {
  flex-direction: row;
}

body.lang-ar #ubea-logo .logo-img {
  margin-right: 8px;
  margin-left: 0;
}

body.lang-ar .customer-logo h4,
body.lang-ar .partner-logo h4 {
  text-align: center;
}

body.lang-ar .customer-logo p,
body.lang-ar .partner-logo p {
  text-align: center;
}
