/* Header Positioning CSS - Fixed Column Layout for All Languages */

/* ========================================
   FIXED COLUMN LAYOUT - ALL LANGUAGES
   ======================================== */

/* Force fixed column order for all languages */
.header-navigation .primary-menu {
  display: grid !important;
  grid-template-columns: 1fr 2fr 1fr !important;
  gap: 0 !important;
  align-items: center !important;
  width: 100% !important;
}

/* Column 1: Logo - Always Left */
.header-left-section {
  order: 1 !important;
  justify-self: start !important;
  display: flex !important;
  justify-content: flex-start !important;
  width: 100% !important;
  margin-right: 40px !important;
}

/* Column 2: Menu - Always Center */
.header-center-section {
  order: 2 !important;
  justify-self: center !important;
  display: flex !important;
  justify-content: center !important;
  width: 100% !important;
  margin: 0 40px !important;
}

/* Column 3: Icons Container - Always Right */
.header-right-section {
  order: 3 !important;
  justify-self: end !important;
  display: flex !important;
  justify-content: flex-end !important;
  width: 100% !important;
  margin-left: 40px !important;
  margin-right: 20px !important;
}

/* ========================================
   LANGUAGE-INDEPENDENT POSITIONING
   ======================================== */

/* Override any language-based positioning */
html[dir="rtl"] .header-navigation .primary-menu,
body[dir="rtl"] .header-navigation .primary-menu,
html[lang="ar"] .header-navigation .primary-menu,
body[lang="ar"] .header-navigation .primary-menu,
html[dir="ltr"] .header-navigation .primary-menu,
body[dir="ltr"] .header-navigation .primary-menu,
html[lang="en"] .header-navigation .primary-menu,
body[lang="en"] .header-navigation .primary-menu {
  flex-direction: unset !important;
  display: grid !important;
  grid-template-columns: 1fr 2fr 1fr !important;
}

/* Force logo to always be in first column */
html[dir="rtl"] .header-left-section,
body[dir="rtl"] .header-left-section,
html[lang="ar"] .header-left-section,
body[lang="ar"] .header-left-section,
html[dir="ltr"] .header-left-section,
body[dir="ltr"] .header-left-section,
html[lang="en"] .header-left-section,
body[lang="en"] .header-left-section {
  order: 1 !important;
  justify-self: start !important;
}

/* Force menu to always be in second column */
html[dir="rtl"] .header-center-section,
body[dir="rtl"] .header-center-section,
html[lang="ar"] .header-center-section,
body[lang="ar"] .header-center-section,
html[dir="ltr"] .header-center-section,
body[dir="ltr"] .header-center-section,
html[lang="en"] .header-center-section,
body[lang="en"] .header-center-section {
  order: 2 !important;
  justify-self: center !important;
}

/* Force icons container to always be in third column */
html[dir="rtl"] .header-right-section,
body[dir="rtl"] .header-right-section,
html[lang="ar"] .header-right-section,
body[lang="ar"] .header-right-section,
html[dir="ltr"] .header-right-section,
body[dir="ltr"] .header-right-section,
html[lang="en"] .header-right-section,
body[lang="en"] .header-right-section {
  order: 3 !important;
  justify-self: end !important;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
  .header-navigation .primary-menu {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto auto !important;
    gap: 10px !important;
  }
  
  .header-left-section {
    order: 1 !important;
    justify-self: center !important;
    margin: 10px 0 !important;
  }
  
  .header-center-section {
    order: 2 !important;
    justify-self: center !important;
    margin: 10px 0 !important;
  }
  
  .header-right-section {
    order: 3 !important;
    justify-self: center !important;
    margin: 10px 0 !important;
  }
}

@media (max-width: 576px) {
  .header-left-section,
  .header-center-section,
  .header-right-section {
    margin: 5px 0 !important;
  }
}

/* ========================================
   LANGUAGE SELECTOR STYLING
   ======================================== */

.language-selector {
  position: relative;
  display: inline-block;
}

.lang-dropdown {
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.3s ease;
  background: transparent;
  border: none;
}

.lang-dropdown:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lang-dropdown.active {
  background: rgba(255, 255, 255, 0.3);
}

.language-options {
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 150px;
  margin-top: 5px;
  padding: 8px 0;
  display: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  z-index: 10001;
}

.language-options.show {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
}

.language-option {
  display: block;
  padding: 8px 16px;
  color: #333;
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
}

.language-option:hover {
  background: #f5f5f5;
  color: #000;
}

.language-option.active {
  background: #e3f2fd;
  color: #1976d2;
}

.language-option.active .check-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #1976d2;
}

/* RTL adjustments for language options */
html[dir="rtl"] .language-options,
body[dir="rtl"] .language-options,
html[lang="ar"] .language-options,
body[lang="ar"] .language-options {
  right: auto;
  left: 0;
}

html[dir="rtl"] .language-option.active .check-icon,
body[dir="rtl"] .language-option.active .check-icon,
html[lang="ar"] .language-option.active .check-icon,
body[lang="ar"] .language-option.active .check-icon {
  right: auto;
  left: 16px;
}

/* ========================================
   FORCE HEADER ORDER
   ======================================== */

/* Ensure header elements maintain their order */
.header-navigation .primary-menu > * {
  order: inherit !important;
}

/* Override any conflicting order properties */
.header-left-section,
.header-center-section,
.header-right-section {
  order: inherit !important;
}

/* ========================================
   ULTIMATE POSITIONING OVERRIDE
   ======================================== */

/* Force all positioning to be language-independent */
.header-navigation .primary-menu {
  direction: unset !important;
  text-align: unset !important;
}

/* Ensure grid layout is always maintained */
.header-navigation .primary-menu {
  display: grid !important;
  grid-template-columns: 1fr 2fr 1fr !important;
  grid-template-rows: auto !important;
  gap: 0 !important;
  align-items: center !important;
  justify-items: stretch !important;
  width: 100% !important;
  max-width: none !important;
}

/* Force column widths */
.header-left-section {
  grid-column: 1 !important;
  grid-row: 1 !important;
}

.header-center-section {
  grid-column: 2 !important;
  grid-row: 1 !important;
}

.header-right-section {
  grid-column: 3 !important;
  grid-row: 1 !important;
}
