/**
 * InfluQa Internationalization (i18n) Styles
 * Styles for the language switcher and RTL support
 */

/* ==========================================
   Language Switcher Styles
   ========================================== */

.i18n-switcher {
  position: relative;
  display: inline-block;
  z-index: 1000;
}

.i18n-switcher-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: white;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  color: #374151;
}

.i18n-switcher-button:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.i18n-switcher-button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.i18n-switcher-flag {
  font-size: 18px;
  line-height: 1;
}

.i18n-switcher-name {
  font-weight: 500;
}

.i18n-switcher-arrow {
  width: 16px;
  height: 16px;
  color: #9ca3af;
  transition: transform 0.2s ease;
}

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

.i18n-switcher-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.i18n-switcher-dropdown[hidden] {
  display: none;
}

.i18n-switcher-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
  text-align: left;
  color: #374151;
}

.i18n-switcher-option:hover {
  background: #f3f4f6;
}

.i18n-switcher-option.active {
  background: #eff6ff;
  color: #2563eb;
}

.i18n-switcher-option:focus {
  outline: none;
  background: #f3f4f6;
}

.i18n-switcher-option .i18n-switcher-flag {
  font-size: 20px;
}

.i18n-switcher-option .i18n-switcher-name {
  flex: 1;
  font-weight: 500;
}

.i18n-switcher-check {
  width: 20px;
  height: 20px;
  color: #2563eb;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .i18n-switcher-button {
    background: #1f2937;
    border-color: #374151;
    color: #f3f4f6;
  }

  .i18n-switcher-button:hover {
    background: #374151;
    border-color: #4b5563;
  }

  .i18n-switcher-dropdown {
    background: #1f2937;
    border-color: #374151;
  }

  .i18n-switcher-option {
    color: #f3f4f6;
  }

  .i18n-switcher-option:hover {
    background: #374151;
  }

  .i18n-switcher-option.active {
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
  }

  .i18n-switcher-option:focus {
    background: #374151;
  }

  .i18n-switcher-check {
    color: #60a5fa;
  }
}

/* ==========================================
   RTL (Right-to-Left) Support
   ========================================== */

[dir="rtl"] {
  text-align: right;
}

[dir="rtl"] .i18n-switcher-dropdown {
  right: auto;
  left: 0;
}

[dir="rtl"] .i18n-switcher-option {
  text-align: right;
}

[dir="rtl"] .i18n-switcher-arrow {
  margin-left: 0;
  margin-right: 4px;
}

/* ==========================================
   Language Badge Styles
   ========================================== */

.i18n-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: #f3f4f6;
  font-size: 12px;
  font-weight: 500;
  color: #4b5563;
}

.i18n-badge-flag {
  font-size: 14px;
}

/* ==========================================
   Translation Loading States
   ========================================== */

.i18n-loading {
  position: relative;
  color: transparent !important;
}

.i18n-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: i18n-spin 0.8s linear infinite;
}

@keyframes i18n-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================
   Responsive Adjustments
   ========================================== */

@media (max-width: 640px) {
  .i18n-switcher-button {
    padding: 6px 10px;
    font-size: 13px;
  }

  .i18n-switcher-dropdown {
    min-width: 180px;
  }

  .i18n-switcher-option {
    padding: 10px 14px;
  }

  /* Hide language name on mobile, show only flag */
  .i18n-switcher-button .i18n-switcher-name {
    display: none;
  }
}

/* ==========================================
   Animation for Language Change
   ========================================== */

.i18n-fade-in {
  animation: i18n-fadeIn 0.3s ease-in-out;
}

@keyframes i18n-fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================
   Accessibility Improvements
   ========================================== */

.i18n-switcher-button:focus-visible,
.i18n-switcher-option:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .i18n-switcher-arrow,
  .i18n-switcher-option,
  .i18n-fade-in {
    transition: none;
    animation: none;
  }
}

/* ==========================================
   Print Styles
   ========================================== */

@media print {
  .i18n-switcher {
    display: none;
  }
}

/* ==========================================
   Unified Locale Dropdown (Header)
   ========================================== */

.nav-icon-wrapper {
  position: relative;
}

.nav-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

.nav-icon {
  font-size: 18px;
  line-height: 1;
}

.nav-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  background: #1a1a2e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 1000;
}

.nav-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.locale-dropdown-content {
  padding: 12px;
}

.locale-section {
  margin-bottom: 12px;
}

.locale-section:last-child {
  margin-bottom: 0;
}

.locale-label {
  display: block;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.locale-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.locale-select:hover {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.locale-select:focus {
  outline: none;
  border-color: #a855f7;
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

.locale-select option {
  background: #1a1a2e;
  color: #fff;
  padding: 8px;
}

/* RTL support for dropdown */
[dir="rtl"] .nav-dropdown {
  right: auto;
  left: 0;
}

[dir="rtl"] .locale-select {
  background-position: left 12px center;
  padding-right: 12px;
  padding-left: 32px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .nav-dropdown {
    right: -60px;
    min-width: 240px;
  }
  
  [dir="rtl"] .nav-dropdown {
    right: auto;
    left: -60px;
  }
}