/**
 * Enhanced Multilingual Language Selector Styles
 * Features: Loading states, better animations, improved accessibility
 */

.language-selector {
  position: relative;
  display: inline-block;
  margin-left: auto;
  z-index: 1000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.language-dropdown {
  position: relative;
}

.language-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--background-color, #ffffff);
  border: 2px solid var(--border-color, #e1e5e9);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color, #333);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  min-width: 140px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.language-toggle:hover {
  background: var(--hover-background, #f8f9fa);
  border-color: var(--primary-color, #3498db);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
}

.language-toggle:focus {
  border-color: var(--primary-color, #3498db);
  box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.1);
}

.language-toggle[aria-expanded="true"] {
  border-color: var(--primary-color, #3498db);
  background: var(--primary-color, #3498db);
  color: #ffffff;
}

.language-toggle[aria-expanded="true"] .dropdown-arrow {
  color: #ffffff;
}

.current-lang-flag {
  font-size: 18px;
  line-height: 1;
}

.current-lang-name {
  flex: 1;
  text-align: left;
  white-space: nowrap;
}

.dropdown-arrow {
  font-size: 10px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-secondary, #666);
  margin-left: 4px;
}

.language-toggle[aria-expanded="true"] .dropdown-arrow {
  transform: rotate(180deg);
}

.language-options {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--background-color, #ffffff);
  border: 2px solid var(--border-color, #e1e5e9);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1001;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.language-options.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.language-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-color, #333);
  transition: all 0.2s ease;
  border-bottom: 1px solid var(--border-light, #f1f3f4);
  position: relative;
  min-height: 44px; /* Better touch targets */
}

.language-option:last-child {
  border-bottom: none;
}

.language-option:hover {
  background: linear-gradient(135deg, var(--primary-color, #3498db), var(--secondary-color, #2980b9));
  color: #ffffff;
  transform: translateX(4px);
}

.language-option.current {
  background: var(--success-color, #27ae60);
  color: #ffffff;
  font-weight: 600;
}

.language-option.current:hover {
  background: var(--success-color, #27ae60);
  transform: none;
}

.language-option .lang-flag {
  font-size: 18px;
  line-height: 1;
}

.language-option .lang-name {
  flex: 1;
  text-align: left;
}

.language-option .fas.fa-check {
  font-size: 12px;
  color: #ffffff;
  opacity: 0.9;
}

/* Loading and transition states */
.language-switching {
  pointer-events: none;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.language-switching .language-selector {
  opacity: 0.5;
}

.language-selector.loading .language-toggle {
  opacity: 0.6;
  cursor: not-allowed;
  position: relative;
}

.language-selector.loading .language-toggle::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border: 2px solid transparent;
  border-top: 2px solid var(--primary-color, #3498db);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translateY(-50%) rotate(0deg); }
  100% { transform: translateY(-50%) rotate(360deg); }
}

/* Dark mode styles */
.dark-mode .language-toggle {
  background: var(--dark-background-secondary, #2c3e50);
  border-color: var(--dark-border, #34495e);
  color: var(--dark-text, #ecf0f1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.dark-mode .language-toggle:hover {
  background: var(--dark-hover-background, #34495e);
  border-color: var(--primary-color, #3498db);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.25);
}

.dark-mode .language-toggle[aria-expanded="true"] {
  background: var(--primary-color, #3498db);
  border-color: var(--primary-color, #3498db);
}

.dark-mode .language-options {
  background: var(--dark-background-secondary, #2c3e50);
  border-color: var(--dark-border, #34495e);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.dark-mode .language-option {
  color: var(--dark-text, #ecf0f1);
  border-bottom-color: var(--dark-border, #34495e);
}

.dark-mode .language-option:hover {
  background: linear-gradient(135deg, var(--primary-color, #3498db), var(--secondary-color, #2980b9));
  color: #ffffff;
}

.dark-mode .language-option.current {
  background: var(--success-color, #27ae60);
  color: #ffffff;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .language-selector {
    margin-left: 0;
    margin-right: 16px;
  }
  
  .language-toggle {
    padding: 8px 12px;
    font-size: 13px;
    min-width: 120px;
  }
  
  .language-option {
    padding: 10px 12px;
    font-size: 13px;
    min-height: 48px; /* Larger touch targets on mobile */
  }
  
  .current-lang-flag,
  .language-option .lang-flag {
    font-size: 16px;
  }
  
  /* Full width dropdown on small screens */
  .language-options {
    left: -50px;
    right: -50px;
    min-width: 200px;
  }
}

@media (max-width: 480px) {
  .language-options {
    left: -100px;
    right: -100px;
    min-width: 250px;
  }
}

/* Header integration */
header nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

header nav .language-selector {
  margin-left: auto;
}

/* Mobile menu integration */
@media (max-width: 768px) {
  .mobile-nav .language-selector {
    padding: 16px;
    border-top: 1px solid var(--border-color, #e1e5e9);
    margin-top: 16px;
    margin-left: 0;
    margin-right: 0;
  }
  
  .mobile-nav .language-selector .language-toggle {
    width: 100%;
    justify-content: center;
  }
  
  .dark-mode .mobile-nav .language-selector {
    border-top-color: var(--dark-border, #34495e);
  }
}

/* RTL support */
[dir="rtl"] .language-selector {
  margin-left: 0;
  margin-right: auto;
}

[dir="rtl"] .language-options {
  left: auto;
  right: 0;
}

[dir="rtl"] .current-lang-name,
[dir="rtl"] .language-option .lang-name {
  text-align: right;
}

[dir="rtl"] .language-option:hover {
  transform: translateX(-4px);
}

/* Accessibility improvements */
.language-toggle:focus-visible {
  outline: 2px solid var(--primary-color, #3498db);
  outline-offset: 2px;
}

.language-option:focus {
  background: var(--primary-color, #3498db);
  color: #ffffff;
  outline: none;
}

/* Keyboard navigation */
.language-option[tabindex="0"]:focus {
  background: var(--primary-color, #3498db);
  color: #ffffff;
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .language-toggle {
    border-width: 3px;
    font-weight: 700;
  }
  
  .language-option:hover {
    background: #000000;
    color: #ffffff;
  }
  
  .language-option.current {
    background: #000000;
    color: #ffffff;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .language-toggle,
  .language-options,
  .language-option,
  .dropdown-arrow {
    transition: none;
  }
  
  .language-toggle:hover {
    transform: none;
  }
  
  .language-option:hover {
    transform: none;
  }
}

/* Print styles */
@media print {
  .language-selector {
    display: none;
  }
}

/* Success message for language changes */
.language-change-success {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--success-color, #27ae60);
  color: white;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  z-index: 10000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.language-change-success.show {
  transform: translateX(0);
}

/* Animation for appearing selector */
.language-selector.fade-in {
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Enhanced Multilingual System Styles */

/* Language Selector */
.language-selector select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: white;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: all 0.3s ease;
}

.language-selector select:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

.language-selector select option {
  background: #2c3e50;
  color: white;
}

/* Enhanced Auto-redirect Notification */
.auto-redirect-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(248,249,250,0.95) 100%);
  color: #2c3e50;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  max-width: 420px;
  min-width: 320px;
  backdrop-filter: blur(20px);
  border: 2px solid rgba(255, 255, 255, 0.8);
  animation: slideInDown 0.6s cubic-bezier(0.23, 1, 0.320, 1);
  overflow: hidden;
}

.notification-content {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.notification-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 25px 15px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.notification-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.notification-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #95a5a6;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.notification-close:hover {
  background: rgba(231, 76, 60, 0.1);
  color: #e74c3c;
  transform: scale(1.1);
}

.notification-body {
  padding: 0 25px 20px;
}

.notification-footer {
  padding: 15px 25px;
  background: rgba(0, 0, 0, 0.03);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.notification-icon {
  font-size: 28px;
  animation: pulse 2s infinite;
}

.countdown-display {
  margin: 15px 0;
  font-size: 14px;
  color: #7f8c8d;
  text-align: center;
}

.countdown-number {
  display: inline-block;
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
  font-weight: bold;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 8px;
  min-width: 28px;
  text-align: center;
  animation: countdownPulse 1s infinite;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin: 10px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3498db, #2980b9);
  border-radius: 2px;
  transition: width 1s linear;
  width: 0;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-ip {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: white;
}

.badge-timezone {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: white;
}

.badge-browser {
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  color: white;
}

.badge-auto {
  background: linear-gradient(135deg, #34495e, #2c3e50);
  color: white;
}

.notification-text h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
}

.notification-text p {
  margin: 4px 0;
  font-size: 14px;
  line-height: 1.4;
}

.notification-text small {
  opacity: 0.8;
  font-size: 12px;
}

.notification-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.notification-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.notification-btn.primary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.notification-btn.primary:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.notification-btn.secondary {
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.notification-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.countdown-highlight {
  color: #ffd700;
  font-weight: bold;
  animation: glow 1s ease-in-out infinite alternate;
}

/* Debug Notifications */
.debug-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #2ed573;
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  z-index: 10000;
  font-size: 12px;
  max-width: 300px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideInRight 0.3s ease;
}

.debug-notification.debug-error {
  background: #ff4757;
}

.debug-notification.debug-warning {
  background: #ffa502;
}

.debug-notification.debug-success {
  background: #2ed573;
}

/* Language Detection Status */
.language-detection-status {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 12px;
  z-index: 9999;
  max-width: 250px;
  backdrop-filter: blur(10px);
  display: none;
}

.language-detection-status.show {
  display: block;
  animation: fadeInUp 0.3s ease;
}

/* Animations */
@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100px);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes glow {
  from {
    text-shadow: 0 0 5px #ffd700, 0 0 10px #ffd700;
  }
  to {
    text-shadow: 0 0 10px #ffd700, 0 0 20px #ffd700, 0 0 30px #ffd700;
  }
}

@keyframes countdownPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.7);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(52, 152, 219, 0);
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .auto-redirect-notification {
    left: 10px;
    right: 10px;
    transform: none;
    max-width: none;
    min-width: auto;
  }
  
  .notification-content {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }
  
  .notification-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .debug-notification {
    right: 10px;
    left: 10px;
    max-width: none;
  }
  
  .language-detection-status {
    left: 10px;
    right: 10px;
    max-width: none;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .language-selector select {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
  }
  
  .language-selector select:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .auto-redirect-notification {
    border: 2px solid white;
  }
  
  .notification-btn {
    border-width: 2px;
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .auto-redirect-notification,
  .debug-notification,
  .language-detection-status {
    animation: none;
  }
  
  .notification-icon {
    animation: none;
  }
  
  .countdown-highlight {
    animation: none;
  }
} 