/* =====================================================
   MULTI-LANGUAGE & RTL SUPPORT STYLES
   Extreme Bearing Website - i18n CSS
   ===================================================== */

/* =====================================================
   i18n Styles & Language Switcher Component
   ===================================================== */

/* Prevent flash of untranslated content (FOUC) */
/* Hide all translatable content until i18n is ready */
.i18n-loading [data-i18n] {
  visibility: hidden !important;
}

.i18n-ready [data-i18n] {
  visibility: visible;
  animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.language-switcher {
  position: relative;
  display: inline-block;
}

.lang-switcher-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  color: var(--gray-700);
  text-decoration: none;
  transition: all var(--transition-base);
  border-radius: var(--radius-sm);
}

.lang-switcher-btn:hover {
  color: var(--primary-blue);
}

.lang-switcher-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  transition: stroke var(--transition-base);
}

/* Dropdown */
.lang-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  min-width: 220px;
  max-width: calc(100vw - 2rem);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 1000;
  animation: slideDown 0.2s ease;
  box-sizing: border-box;
}

.lang-dropdown.show {
  display: block;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--gray-700);
  text-decoration: none;
  transition: all var(--transition-base);
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
}

.lang-option:last-child {
  border-bottom: none;
}

.lang-option:hover {
  background: var(--gray-50);
  color: var(--primary-blue);
}

.lang-option.active {
  background: var(--primary-blue);
  color: var(--white);
  font-weight: 600;
}

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

.lang-option .lang-name {
  font-family: 'Geologica', sans-serif;
  font-weight: 500;
  font-size: 0.9375rem;
}

/* Animation */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile styles */
@media (max-width: 768px) {
  .language-switcher {
    margin-left: 0;
  }
  
  .current-lang {
    padding: 0.4rem 0.75rem;
  }
  
  .lang-dropdown {
    right: auto;
    left: 0;
    min-width: 200px;
  }
}

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

/* HTML/Body RTL adjustments */
html[lang="ar"] {
  direction: rtl;
}

html[lang="ar"] body {
  text-align: right;
}

/* Navigation RTL */
html[lang="ar"] .nav-links {
  flex-direction: row-reverse;
}

html[lang="ar"] .language-switcher {
  margin-left: 0;
  margin-right: 1rem;
}

html[lang="ar"] .lang-dropdown {
  right: auto;
  left: 0;
}

/* Grid layouts RTL */
html[lang="ar"] .grid {
  direction: rtl;
}

/* Flex layouts RTL */
html[lang="ar"] .flex-row {
  flex-direction: row-reverse;
}

/* Buttons and icons RTL */
html[lang="ar"] .btn svg,
html[lang="ar"] .icon-left {
  margin-left: 0.5rem;
  margin-right: 0;
}

html[lang="ar"] .icon-right {
  margin-right: 0.5rem;
  margin-left: 0;
}

/* Forms RTL */
html[lang="ar"] input,
html[lang="ar"] textarea,
html[lang="ar"] select {
  text-align: right;
}

html[lang="ar"] .form-group label {
  text-align: right;
}

/* Product cards RTL */
html[lang="ar"] .product-card {
  text-align: right;
}

html[lang="ar"] .product-card-actions {
  flex-direction: row-reverse;
}

/* Hero section RTL */
html[lang="ar"] .hero-content {
  grid-template-columns: 1fr 1fr;
  direction: rtl;
}

/* Footer RTL */
html[lang="ar"] .footer-grid {
  direction: rtl;
}

/* Breadcrumbs RTL */
html[lang="ar"] .breadcrumb {
  flex-direction: row-reverse;
}

html[lang="ar"] .breadcrumb-separator {
  transform: rotate(180deg);
}

/* Pagination RTL */
html[lang="ar"] .pagination {
  flex-direction: row-reverse;
}

/* =====================================================
   Language-specific Typography Adjustments
   ===================================================== */

/* Arabic font adjustments */
html[lang="ar"] {
  font-family: 'Geologica', 'Tajawal', 'Cairo', 'Amiri', sans-serif;
}

html[lang="ar"] h1,
html[lang="ar"] h2,
html[lang="ar"] h3 {
  font-weight: 700;
  letter-spacing: 0;
}

html[lang="ar"] p {
  line-height: 1.8;
}

/* Numbers in RTL should remain LTR */
html[lang="ar"] .number,
html[lang="ar"] .price,
html[lang="ar"] .quantity {
  direction: ltr;
  display: inline-block;
}

/* =====================================================
   CMS Multi-Language Editor Styles
   ===================================================== */

.cms-tabs {
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 1.5rem;
}

.tab-list {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-family: 'Geologica', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-600);
  transition: all var(--transition-base);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--primary-blue);
  background: var(--gray-50);
}

.tab-btn.active {
  color: var(--primary-blue);
  border-bottom-color: var(--primary-blue);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.translation-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.badge-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

.btn-auto-translate {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary-blue);
  background: var(--white);
  border: 1px solid var(--primary-blue);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
}

.btn-auto-translate:hover {
  background: var(--primary-blue);
  color: var(--white);
}

/* Translation progress */
.translation-progress {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--gray-50);
  border-radius: var(--radius-md);
}

.translation-progress h4 {
  margin-bottom: 1rem;
  color: var(--gray-900);
}

.progress-grid {
  display: grid;
  gap: 0.75rem;
}

.progress-item {
  display: grid;
  grid-template-columns: 3rem 1fr 3rem;
  align-items: center;
  gap: 1rem;
}

.progress-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-blue), var(--primary-dark));
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  text-align: right;
}

/* =====================================================
   Utility Classes
   ===================================================== */

.text-rtl {
  direction: rtl;
  text-align: right;
}

.text-ltr {
  direction: ltr;
  text-align: left;
}

/* Hide elements based on language */
[lang]:not([lang="en"]) .en-only {
  display: none !important;
}

[lang="en"] .not-en {
  display: none !important;
}

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

@media (max-width: 1024px) {
  html[lang="ar"] .hero-content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .tab-list {
    gap: 0.25rem;
  }
  
  .tab-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }
  
  html[lang="ar"] .language-switcher {
    margin-right: 0.5rem;
  }
}

