/* ═══════════════════════════════════════════════
   Language Switcher — Modern, Mobile-First Design
   Desktop: Smart dropdown
   Mobile: Bottom-sheet modal with backdrop
   ═══════════════════════════════════════════════ */

/* ── Wrapper ── */
.lang-switcher {
  position: relative;
  display: inline-block;
  margin: 0 4px;
  vertical-align: middle;
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
}

.lang-switcher-host {
  display: inline-block;
  vertical-align: middle;
  padding: 0 4px;
}

/* ── Trigger button ── */
.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  border: 1.5px solid rgba(0, 0, 0, 0.18);
  background: rgba(255, 255, 255, 0.95);
  color: #1a1a1a;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  position: relative;
  z-index: 1;
  touch-action: manipulation;
}

.lang-btn:hover,
.lang-btn:focus-visible,
.lang-btn[aria-expanded="true"] {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.4);
}

.lang-btn:focus-visible {
  outline: 2px solid #1a5fcc;
  outline-offset: 2px;
}

.lang-btn:active {
  transform: scale(0.97);
}

.lang-btn-flag {
  font-size: 17px;
  line-height: 1;
  display: inline-block;
}

.lang-btn-code {
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  color: inherit;
}

.lang-btn-arrow {
  font-size: 10px;
  opacity: 0.6;
  margin-left: 1px;
  transition: transform 0.2s ease;
  display: inline-block;
  line-height: 1;
}

.lang-btn[aria-expanded="true"] .lang-btn-arrow {
  transform: rotate(180deg);
}

/* ── Dark theme variant (auto-applied based on background) ── */
.lang-switcher-dark .lang-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}
.lang-switcher-dark .lang-btn:hover,
.lang-switcher-dark .lang-btn:focus-visible,
.lang-switcher-dark .lang-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.6);
}

/* ── Dropdown panel (DESKTOP) ── */
.lang-dropdown {
  position: fixed;          /* escape parent overflow:hidden */
  /* top / bottom / right computed by JS */
  min-width: 200px;
  max-width: 280px;
  background: #fff;
  color: #1a1a1a !important;
  border-radius: 12px;
  box-shadow:
    0 10px 32px rgba(0, 0, 0, 0.16),
    0 2px 6px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.04);
  padding: 6px 0;
  list-style: none;
  margin: 0;
  z-index: 2147483647;      /* max z-index */
  opacity: 0;
  transform: translateY(-4px) scale(0.97);
  transform-origin: top right;
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    visibility 0s linear 0.18s;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  will-change: opacity, transform;
}

.lang-switcher.open .lang-dropdown {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    visibility 0s linear 0s;
}

/* Ensure dropdown is always accessible when open */
.lang-switcher.open .lang-dropdown * {
  pointer-events: auto;
}

/* Mobile sheet header — hidden on desktop */
.lang-sheet-header {
  display: none;
}

/* ── Language option ── */
.lang-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  color: #1a1a1a !important;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  background: #fff !important;
  transition: background 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  outline: none;
}

.lang-item:hover,
.lang-item:focus-visible {
  background: rgba(26, 95, 204, 0.08) !important;
  color: #1a1a1a !important;
}

.lang-item:focus-visible {
  background: rgba(26, 95, 204, 0.12) !important;
  color: #1a1a1a !important;
}

.lang-item.active {
  background: rgba(26, 95, 204, 0.08) !important;
  font-weight: 600;
  color: #1a5fcc !important;
}

.lang-item-flag {
  font-size: 19px;
  line-height: 1;
  flex-shrink: 0;
  color: inherit !important;
}

.lang-item-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1a1a1a !important;
}

.lang-item-check {
  color: #1a5fcc;
  font-weight: 700;
  font-size: 14px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Footer variant ── */
.lang-switcher-footer .lang-btn {
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}
.lang-switcher-footer .lang-btn:hover,
.lang-switcher-footer .lang-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.7);
}

/* Backdrop removed - not needed for mobile design */
body.lang-switcher-mobile-open {
  overflow: hidden;
}

/* ════════════════════════════════════════
   MOBILE — Bottom sheet style
   ════════════════════════════════════════ */
@media (max-width: 640px) {
  .lang-switcher-backdrop {
    display: block !important;
  }

  .lang-switcher-backdrop.active {
    display: block;
  }

  .lang-dropdown {
    /* Bottom sheet from bottom of screen */
    position: fixed !important;
    z-index: 2147483647 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    max-height: 75vh !important;
    border-radius: 16px 16px 0 0;
    padding: 8px 0 max(16px, env(safe-area-inset-bottom)) 0;
    background: #fff !important;
    box-shadow:
      0 -8px 32px rgba(0, 0, 0, 0.18),
      0 -1px 3px rgba(0, 0, 0, 0.05);
    transform: translateY(100%) !important;
    transform-origin: bottom center;
    transition:
      transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
      visibility 0s linear 0.28s;
    opacity: 1;
    visibility: hidden;
    pointer-events: none;
  }

  .lang-switcher.open .lang-dropdown {
    transform: translateY(0) !important;
    transition:
      transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
      visibility 0s linear 0s;
    visibility: visible;
    pointer-events: auto;
  }

  /* Show sheet header on mobile */
  .lang-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    margin-bottom: 4px;
    position: relative;
  }

  .lang-sheet-header::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.18);
  }

  .lang-sheet-title {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin-top: 6px;
  }

  .lang-sheet-close {
    background: rgba(0, 0, 0, 0.06);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-top: 6px;
    -webkit-tap-highlight-color: transparent;
  }

  .lang-sheet-close:hover,
  .lang-sheet-close:active {
    background: rgba(0, 0, 0, 0.12);
  }

  .lang-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    font-size: 15px;
    min-height: 48px;
    color: #1a1a1a;
    background: #fff;
  }

  .lang-item:hover,
  .lang-item:focus-visible {
    background: rgba(26, 95, 204, 0.12);
    color: #1a1a1a;
  }

  .lang-item.active {
    background: rgba(26, 95, 204, 0.12);
    color: #1a5fcc;
  }

  .lang-item-flag {
    font-size: 22px;
    flex-shrink: 0;
  }

  .lang-item-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #1a1a1a;
  }

  .lang-item-check {
    color: #1a5fcc;
    font-weight: 700;
    margin-left: auto;
    flex-shrink: 0;
  }

  .lang-btn {
    min-height: 38px;
    padding: 7px 12px 7px 10px;
  }

  .lang-sheet-title {
    color: #1a1a1a;
  }

  .lang-sheet-close {
    color: #666;
  }
}

/* ════════════════════════════════════════
   REDIRECT MODAL (English → Styku USA)
   ════════════════════════════════════════ */
.language-redirect-modal {
  display: none;
  position: fixed;
  z-index: 2147483645;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease;
  align-items: center;
  justify-content: center;
}

.language-redirect-modal.active {
  display: flex;
  opacity: 1;
}

.language-redirect-modal-content {
  background: #fff;
  padding: 30px 28px;
  border-radius: 14px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
  animation: lsSlideUp 0.25s ease;
  font-family: 'Poppins', system-ui, sans-serif;
}

@keyframes lsSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.language-redirect-modal-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 10px;
  color: #1a1a1a;
}

.language-redirect-modal-text {
  font-size: 13.5px;
  color: #555;
  margin-bottom: 22px;
  line-height: 1.55;
}

.language-redirect-modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.language-redirect-modal-btn {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.18s ease;
  font-family: inherit;
  min-height: 40px;
}

.language-redirect-modal-btn-cancel {
  background: #f0f0f0;
  color: #333;
}
.language-redirect-modal-btn-cancel:hover { background: #e3e3e3; }

.language-redirect-modal-btn-confirm {
  background: #1a5fcc;
  color: #fff;
}
.language-redirect-modal-btn-confirm:hover { background: #1450b0; }

@media (max-width: 480px) {
  .language-redirect-modal-content { padding: 24px 20px; }
  .language-redirect-modal-buttons { flex-direction: column-reverse; }
  .language-redirect-modal-btn { width: 100%; text-align: center; }
}

/* ════════════════════════════════════════
   Reduced motion preferences
   ════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .lang-dropdown,
  .lang-btn,
  .lang-btn-arrow,
  .lang-item,
  .language-redirect-modal,
  .language-redirect-modal-content,
  .lang-switcher-backdrop {
    transition: none !important;
    animation: none !important;
  }
}
