/* 高级语言选择器样式 - 国际化专业版 */

/* 全局变量定义 */
:root {
  --language-selector-bg: rgba(25, 25, 35, 0.95);
  --language-selector-border: rgba(255, 255, 255, 0.15);
  --language-selector-hover-bg: rgba(74, 144, 226, 0.2);
  --language-selector-active-bg: rgba(74, 144, 226, 0.3);
  --language-selector-text: #ffffff;
  --language-selector-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
  --language-selector-radius: 18px;
  --language-selector-transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 语言选择器主容器 */
.language-selector.dropdown-style {
  position: relative;
  z-index: 10000;
  display: inline-block !important;
  flex-shrink: 0;
}

/* 触发按钮样式 - 国际化专业设计 */
.selector-trigger {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--language-selector-border);
  padding: 10px 20px;
  min-width: 150px;
  width: auto;
  border-radius: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--language-selector-text);
  transition: var(--language-selector-transition);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
}

/* 添加国际化地球图标 */
.selector-trigger::before {
  content: "🌍";
  font-size: 18px;
  margin-right: 8px;
  transition: transform 0.3s ease;
}

/* 悬停效果 */
.selector-trigger:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08));
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.selector-trigger:hover::before {
  transform: rotate(20deg);
}

/* 激活效果 */
.selector-trigger:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

/* 下拉箭头 */
.selector-trigger .chevron-icon {
  font-size: 14px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-left: auto;
  color: rgba(255, 255, 255, 0.7);
}

.dropdown-style.active .selector-trigger .chevron-icon {
  transform: rotate(180deg);
}

/* 语言图标 */
.language-sphere {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.selector-trigger:hover .language-sphere {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 255, 255, 0.3);
}

/* 当前语言文本 */
.selector-trigger .current-lang {
  display: inline-block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-grow: 1;
  text-align: left;
  font-weight: 500;
}

/* 加载状态 */
.language-loading {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  right: 0;
  background: var(--language-selector-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--language-selector-radius);
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--language-selector-shadow);
  z-index: 10001;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  transition: var(--language-selector-transition);
  pointer-events: none;
  border: 1px solid var(--language-selector-border);
}

/* 加载动画 */
.spinner {
  width: 32px;
  height: 32px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  border-top-color: #4a90e2;
  animation: spin 1s ease-in-out infinite;
}

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

/* 语言选项容器 */
.language-options-masonry {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  min-width: 300px;
  max-width: 380px;
  max-height: 80vh;
  padding: 20px;
  background: var(--language-selector-bg);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-radius: var(--language-selector-radius);
  box-shadow: var(--language-selector-shadow);
  z-index: 10002;
  opacity: 0;
  transform: translateY(15px) scale(0.95);
  transition: var(--language-selector-transition);
  overflow-y: auto;
  border: 1px solid var(--language-selector-border);
}

/* 瀑布流网格 */
.masonry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 16px;
  width: 100%;
}

/* 语言选项项 */
.masonry-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 16px;
  color: var(--language-selector-text);
  text-decoration: none;
  transition: var(--language-selector-transition);
  opacity: 0;
  transform: translateY(10px);
  animation: fadeInUp 0.4s ease forwards;
  font-size: 15px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

/* 添加悬停光效 */
.masonry-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: 0.5s;
}

.masonry-item:hover::before {
  left: 100%;
}

/* 语言图标 */
.masonry-item img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
  transition: transform 0.3s ease;
}

.masonry-item:hover img {
  transform: scale(1.15) rotate(5deg);
}

/* 悬停效果 */
.masonry-item:hover {
  background: var(--language-selector-hover-bg);
  transform: translateY(-3px);
  outline: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  border-color: rgba(74, 144, 226, 0.4);
}

/* 激活效果 */
.masonry-item:active {
  background: var(--language-selector-active-bg);
  transform: translateY(0);
}

/* 当前选中语言 */
.masonry-item.current {
  background: linear-gradient(135deg, rgba(74, 144, 226, 0.3), rgba(74, 144, 226, 0.2));
  border-color: rgba(74, 144, 226, 0.6);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.masonry-item.current::after {
  content: "✓";
  position: absolute;
  right: 12px;
  color: #4a90e2;
  font-weight: bold;
  font-size: 18px;
  text-shadow: 0 0 8px rgba(74, 144, 226, 0.5);
}

/* 动画延迟 */
.masonry-item:nth-child(1) { animation-delay: 0.05s; }
.masonry-item:nth-child(2) { animation-delay: 0.1s; }
.masonry-item:nth-child(3) { animation-delay: 0.15s; }
.masonry-item:nth-child(4) { animation-delay: 0.2s; }
.masonry-item:nth-child(5) { animation-delay: 0.25s; }
.masonry-item:nth-child(6) { animation-delay: 0.3s; }
.masonry-item:nth-child(7) { animation-delay: 0.35s; }
.masonry-item:nth-child(8) { animation-delay: 0.4s; }
.masonry-item:nth-child(9) { animation-delay: 0.45s; }
.masonry-item:nth-child(10) { animation-delay: 0.5s; }

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 滚动条美化 */
.language-options-masonry::-webkit-scrollbar {
  width: 8px;
}

.language-options-masonry::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.language-options-masonry::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4a90e2, #5e6fc7);
  border-radius: 4px;
}

.language-options-masonry::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #5e6fc7, #4a90e2);
}

/* 激活状态 */
.dropdown-style.active .language-options-masonry {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.dropdown-style.active .language-loading {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* 隐藏状态 */
.hidden {
  display: none !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .language-options-masonry {
    min-width: 180px;
    max-width: calc(90vw);
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    padding: 12px;
    border-radius: 16px;
  }
  
  .masonry-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .masonry-item {
    padding: 12px;
    border-radius: 12px;
    font-size: 14px;
  }
  
  .masonry-item img {
    width: 24px;
    height: 24px;
    border-radius: 6px;
  }
  
  .selector-trigger {
    min-width: auto;
    padding: 8px 16px;
    border-radius: 24px;
  }
  
  .selector-trigger .current-lang {
    display: none;
  }
  
  .selector-trigger::before {
    margin-right: 0;
  }
}

@media (max-width: 480px) {
  .language-options-masonry {
    min-width: 150px;
    max-width: calc(95vw);
    border-radius: 14px;
  }
  
  .masonry-item {
    padding: 10px;
    border-radius: 10px;
    font-size: 13px;
  }
  
  .masonry-item img {
    width: 20px;
    height: 20px;
    border-radius: 5px;
  }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  .selector-trigger {
    background: linear-gradient(135deg, rgba(50, 50, 60, 0.3), rgba(30, 30, 40, 0.2));
    border-color: rgba(100, 100, 120, 0.3);
  }
  
  .selector-trigger:hover {
    background: linear-gradient(135deg, rgba(60, 60, 70, 0.4), rgba(40, 40, 50, 0.3));
    border-color: rgba(120, 120, 140, 0.4);
  }
}