/* ========================================
   LANGUAGE SELECTOR - Glassmorphism Premium
   ======================================== */

.language-selector {
  position: relative;
}

/* Main Button - Original Design (Black background) */
.lang-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: transparent;
  border: none;
  padding: 0.5rem;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-btn:hover {
  color: #fff;
}

.lang-flag {
  width: 28px;
  height: 20px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.lang-code {
  letter-spacing: 0.5px;
}

.lang-arrow {
  width: 16px;
  height: 16px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.8;
}

.language-selector.open .lang-arrow {
  transform: rotate(180deg);
}

/* Dropdown - Premium Glassmorphism */
.lang-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  background: rgba(20, 20, 40, 0.75);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  padding: 0.5rem;
  min-width: 180px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-15px) scale(0.95);
  transform-origin: top right;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 30px rgba(31, 81, 255, 0.15);
  z-index: 1000;
}

/* Arrow pointing up */
.lang-dropdown::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: rgba(20, 20, 40, 0.75);
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  transform: rotate(45deg);
  backdrop-filter: blur(24px);
}

.language-selector.open .lang-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Language Options */
.lang-option {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.85rem 1rem;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  position: relative;
  border-radius: 10px;
  margin: 2px 0;
}

.lang-option::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 60%;
  background: linear-gradient(180deg, #1f51ff, #3b82f6);
  border-radius: 0 3px 3px 0;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.lang-option:hover,
.lang-option:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  outline: none;
}

.lang-option:hover::before,
.lang-option:focus-visible::before {
  transform: translateY(-50%) scaleY(1);
}

.lang-option .lang-flag {
  width: 22px;
  height: 16px;
}

/* Focus states */
.lang-btn:focus-visible {
  outline: 2px solid rgba(31, 81, 255, 0.8);
  outline-offset: 2px;
}

/* ========================================
   LANGUAGE DETECT POPUP - Glassmorphism
   ======================================== */
.lang-detect-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(20, 20, 40, 0.9);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 24px;
  padding: 2.5rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow:
    0 30px 60px -15px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 40px rgba(31, 81, 255, 0.2);
}

.lang-detect-popup.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.lang-detect-popup .popup-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, rgba(31, 81, 255, 0.3), rgba(59, 130, 246, 0.2));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(31, 81, 255, 0.3);
}

.lang-detect-popup .popup-icon svg {
  width: 32px;
  height: 32px;
  color: #fff;
}

.lang-detect-popup h3 {
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.lang-detect-popup p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.lang-detect-popup .popup-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.lang-detect-popup .btn-popup {
  padding: 0.85rem 1.75rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
}

.lang-detect-popup .btn-popup-primary {
  background: linear-gradient(135deg, #1f51ff, #3b82f6);
  color: #fff;
  box-shadow: 0 4px 15px rgba(31, 81, 255, 0.4);
}

.lang-detect-popup .btn-popup-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(31, 81, 255, 0.5);
}

.lang-detect-popup .btn-popup-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.lang-detect-popup .btn-popup-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.lang-detect-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.lang-detect-backdrop.show {
  opacity: 1;
  visibility: visible;
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 900px) {
  .language-selector {
    width: 100%;
  }

  .lang-btn {
    width: 100%;
    justify-content: center;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
  }

  .lang-btn:active {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(0.98);
  }

  .lang-dropdown {
    position: static;
    width: 100%;
    opacity: 1;
    visibility: visible;
    transform: none;
    margin-top: 0.5rem;
    max-height: 0;
    overflow: hidden;
    padding: 0;
    background: rgba(20, 20, 40, 0.6);
    border-radius: 12px;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.35s ease;
    backdrop-filter: blur(20px);
  }

  .lang-dropdown::before {
    display: none;
  }

  .language-selector.open .lang-dropdown {
    max-height: 250px;
    padding: 0.5rem;
    margin-top: 0.75rem;
  }

  .lang-option {
    padding: 1rem;
    border-radius: 10px;
  }

  .lang-option:active {
    background: rgba(31, 81, 255, 0.15);
  }

  .lang-detect-popup {
    padding: 2rem 1.5rem;
    width: 92%;
  }

  .lang-detect-popup h3 {
    font-size: 1.2rem;
  }

  .lang-detect-popup .popup-actions {
    flex-direction: column;
  }

  .lang-detect-popup .btn-popup {
    width: 100%;
  }
}
