/* BesserNews 2.0 🌍 Premium Multilingual System */

/* === Premium Badge === */
.bn-2-0-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: linear-gradient(135deg, #ff7a18 0%, #c2410c 100%);
  color: white;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 2rem;
  box-shadow: 0 4px 15px rgba(255, 122, 24, 0.4);
  position: relative;
  overflow: hidden;
  animation: bn2-pulse 3s ease-in-out infinite;
}

.bn-2-0-badge::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
  transform: rotate(45deg);
  animation: bn2-shine 4s ease-in-out infinite;
}

.bn-2-0-badge .globe-icon {
  font-size: 1rem;
  animation: bn2-rotate 10s linear infinite;
}

@keyframes bn2-pulse {
  0%, 100% { box-shadow: 0 4px 15px rgba(255, 122, 24, 0.4); }
  50% { box-shadow: 0 6px 25px rgba(255, 122, 24, 0.6); }
}

@keyframes bn2-shine {
  0% { transform: translateX(-100%) rotate(45deg); }
  100% { transform: translateX(100%) rotate(45deg); }
}

@keyframes bn2-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Toast Animations */
@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

/* === Language Selector in Header === */
.bn-lang-selector {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.bn-lang-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 122, 24, 0.1);
  border: 2px solid rgba(255, 122, 24, 0.3);
  border-radius: 2rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text-color, #1a1a1a);
  transition: all 0.3s ease;
}

.bn-lang-trigger:hover {
  background: rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.bn-lang-trigger .flag-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.bn-lang-trigger .arrow-icon {
  font-size: 0.75rem;
  transition: transform 0.3s ease;
}

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

/* Language Dropdown */
.bn-lang-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: white;
  border-radius: 1rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  min-width: 280px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 2px solid rgba(102, 126, 234, 0.2);
}

.bn-lang-dropdown[aria-hidden="false"] {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.bn-lang-dropdown-header {
  padding: 1rem 1.25rem;
  border-bottom: 2px solid rgba(102, 126, 234, 0.1);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

.bn-lang-dropdown-title {
  font-size: 0.875rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #667eea;
  margin: 0;
}

.bn-lang-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.bn-lang-item {
  margin: 0;
}

.bn-lang-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: inherit;
  border: 2px solid transparent;
}

.bn-lang-option:hover {
  background: rgba(102, 126, 234, 0.08);
  border-color: rgba(102, 126, 234, 0.2);
  transform: translateX(4px);
}

.bn-lang-option.active {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
  border-color: rgba(102, 126, 234, 0.4);
  font-weight: 700;
}

.bn-lang-option .flag {
  font-size: 1.5rem;
  line-height: 1;
}

.bn-lang-option .details {
  flex: 1;
}

.bn-lang-option .lang-name {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
  color: #1a1a1a;
}

.bn-lang-option .lang-native {
  display: block;
  font-size: 0.8125rem;
  color: #666;
  margin-top: 0.125rem;
}

.bn-lang-option .check-icon {
  color: #667eea;
  font-size: 1rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.bn-lang-option.active .check-icon {
  opacity: 1;
}

/* === Article Card Enhancement === */
.article-card.bn-2-0-article {
  position: relative;
  border: 3px solid transparent;
  background: linear-gradient(white, white) padding-box,
              linear-gradient(135deg, #667eea, #764ba2) border-box;
}

/* Homepage card variant */
.bn-news-card.bn-2-0-article {
  position: relative;
  border: none;
  background: #fff;
  border-radius: var(--bn-radius-xl);
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.15);
}
.bn-news-card.bn-2-0-article .bn-2-0-badge {
  position: absolute;
  top: .75rem;
  left: .75rem;
  z-index: 2;
}
.bn-news-card.bn-2-0-article .bn-card-image {
  border-radius: var(--bn-radius-xl) var(--bn-radius-xl) 0 0;
  width: 100%;
  margin: 0;
}
.bn-news-card.bn-2-0-article .bn-card-image img { position: relative; z-index: 1; }

.bn-lang-toast {
  position: fixed; top: 90px; right: 20px; background: linear-gradient(135deg,#667eea,#764ba2); color:#fff; padding: .9rem 1.25rem; border-radius:.75rem; font-weight:600; box-shadow:0 10px 40px rgba(0,0,0,.25); display:flex; align-items:center; gap:.6rem; z-index:10000; animation: slideIn .35s ease;
}
.bn-lang-toast.hide { animation: slideOut .3s ease forwards; }
.bn-lang-toast .globe { font-size:1.3rem; }

.article-card.bn-2-0-article::before {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

.article-card.bn-2-0-article:hover::before {
  opacity: 0.1;
}

.article-card.bn-2-0-article .article-title::after {
  content: ' 🌍';
  font-size: 0.9em;
}

/* === Top Story Badge Override for 2.0 === */
.bn-2-0-article .top-story-badge {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .bn-lang-dropdown {
    background: #1a1a1a;
    border-color: rgba(102, 126, 234, 0.3);
  }
  
  .bn-lang-option .lang-name {
    color: #e0e0e0;
  }
  
  .bn-lang-option .lang-native {
    color: #999;
  }
  
  .bn-lang-option:hover {
    background: rgba(102, 126, 234, 0.15);
  }
  
  .bn-lang-option.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.25) 0%, rgba(118, 75, 162, 0.25) 100%);
  }
  
  /* Article Language Select Dark Mode */
  .bn-lang-switcher select#bnLangSelect {
    background-color: rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.4);
    color: #e0e0e0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23a8b5ff' d='M1.41 0L6 4.58L10.59 0L12 1.41l-6 6l-6-6z'/%3E%3C/svg%3E");
  }
  
  .bn-lang-switcher select#bnLangSelect:hover {
    background-color: rgba(102, 126, 234, 0.25);
    border-color: rgba(102, 126, 234, 0.6);
  }
  
  .bn-lang-switcher select#bnLangSelect option {
    background: #1a1a1a;
    color: #e0e0e0;
  }
}

/* === Universal Flag Icons (SVG + Unicode Fallback) === */
/* Adds flag icons that work in all browsers including Firefox Private Mode */
.bn-lang-option .flag,
.bn-lang-trigger .flag-icon,
.flag {
  display: inline-block;
  width: 1.5em;
  height: 1.5em;
  font-size: inherit;
  line-height: 1;
  vertical-align: middle;
  
  /* Unicode Emoji Fallback */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  
  /* Enable better rendering on all platforms */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Ensure flags render properly in selects */
.bn-lang-switcher select#bnLangSelect option {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", 'Inter', sans-serif;
}

/* Fallback for browsers that don't support flag emojis */
@supports not (font-family: "Apple Color Emoji") {
  .bn-lang-option .flag::before,
  .bn-lang-trigger .flag-icon::before {
    content: '🏳️';
    display: inline-block;
  }
  
  .bn-lang-option[data-lang="de"] .flag::before,
  .bn-lang-trigger[data-lang="de"] .flag-icon::before {
    content: 'DE';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5em;
    height: 1.5em;
    background: linear-gradient(to bottom, #000 33%, #DD0000 33%, #DD0000 66%, #FFCE00 66%);
    border-radius: 2px;
    font-size: 0.5em;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  }
}

/* === Article Language Switcher (select-based in header nav) === */
.bn-lang-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.bn-lang-switcher select#bnLangSelect {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 2.5rem 0.5rem 1rem;
  
  background: rgba(102, 126, 234, 0.1);
  border: 2px solid rgba(102, 126, 234, 0.3);
  border-radius: 2rem;
  
  cursor: pointer;
  font-weight: 700;
  font-size: 0.875rem;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-color, #1a1a1a);
  
  transition: all 0.3s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23667eea' d='M1.41 0L6 4.58L10.59 0L12 1.41l-6 6l-6-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 0.75rem;
  
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.bn-lang-switcher select#bnLangSelect:hover {
  background-color: rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.bn-lang-switcher select#bnLangSelect:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2), 0 4px 12px rgba(102, 126, 234, 0.3);
}

.bn-lang-switcher select#bnLangSelect:active {
  transform: translateY(0);
}

.bn-lang-switcher select#bnLangSelect option {
  padding: 0.75rem 1rem;
  background: white;
  color: #1a1a1a;
  font-weight: 600;
}

/* Flag icon support in select options (browser-dependent) */
.bn-lang-switcher select#bnLangSelect option::before {
  margin-right: 0.5rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .bn-lang-dropdown {
    right: -1rem;
    left: -1rem;
    width: auto;
    min-width: auto;
  }
  
  .bn-2-0-badge {
    font-size: 0.6875rem;
    padding: 0.3rem 0.75rem;
  }
  
  .bn-lang-switcher select#bnLangSelect {
    font-size: 0.8125rem;
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    background-position: right 0.5rem center;
  }
  
  /* Homepage language selector mobile */
  .bn-lang-selector {
    width: 100%;
  }
  
  .bn-lang-trigger {
    width: 100%;
    justify-content: center;
    font-size: 0.8125rem;
  }
}
