/**
 * Language and RTL/LTR Support Styles
 * Version: 1.0.0
 * Last Updated: December 6, 2025
 */

/* RTL/LTR Base Styles */
[dir="rtl"] {
  text-align: right;
}

[dir="ltr"] {
  text-align: left;
}

/* Flex Direction Reversals for RTL */
[dir="rtl"] .controls,
[dir="rtl"] .button-group,
[dir="rtl"] .nav-menu,
[dir="rtl"] .btn-group {
  flex-direction: row-reverse;
}

/* Form Element Adjustments */
[dir="rtl"] label {
  margin-left: 0.5em;
  margin-right: 0;
}

[dir="ltr"] label {
  margin-right: 0.5em;
  margin-left: 0;
}

/* Language Flag Menu - Always right of cog */
.language-flag-container {
  position: fixed;
  top: 20px;
  left: 80px;
  z-index: 1000;
}

/* No RTL repositioning - always stays right of cog */
[dir="rtl"] .language-flag-container {
  left: 80px;
  right: auto;
}

.current-flag-btn {
  background: white;
  border: 2px solid var(--border-color, #ddd);
  cursor: pointer;
  padding: 4px;
  transition: all 0.2s ease;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.current-flag-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  border-color: var(--accent-color, #007bff);
}

.current-flag-btn:active {
  transform: scale(0.98);
}

.flag-icon {
  width: 32px;
  height: 32px;
  display: block;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Flag Menu Dropdown */
.flag-menu {
  position: absolute;
  top: 52px;
  left: 0;
  background: white;
  border: 2px solid var(--border-color, #ddd);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  min-width: 150px;
}

.flag-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.flag-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 15px;
  background: white;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
  font-size: 14px;
  color: var(--base-text, #333);
}

.flag-menu-item:hover {
  background-color: var(--secondary-bg, #f5f5f5);
}

.flag-menu-item:active {
  background-color: var(--border-color, #e0e0e0);
}

.flag-menu-item .flag-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.flag-menu-item span {
  flex: 1;
  text-align: left;
}

/* Dark theme support */
:root[data-theme="dark"] .current-flag-btn {
  background: var(--secondary-bg, #2a2a2a);
  border-color: var(--border-color, #444);
}

:root[data-theme="dark"] .flag-menu {
  background: var(--secondary-bg, #2a2a2a);
  border-color: var(--border-color, #444);
}

:root[data-theme="dark"] .flag-menu-item {
  background: var(--secondary-bg, #2a2a2a);
  color: var(--base-text, #e0e0e0);
}

:root[data-theme="dark"] .flag-menu-item:hover {
  background-color: var(--base-bg, #1a1a1a);
}

/* Hebrew Font Support */
[dir="rtl"] {
  font-family: 'Arial', 'Helvetica', sans-serif;
}

/* Loading State */
.language-loading {
  pointer-events: none;
  opacity: 0.7;
  transition: opacity 0.2s;
}

/* Accordion and Panel Adjustments for RTL */
[dir="rtl"] .accordion-button {
  text-align: right;
}

[dir="rtl"] .accordion-button::after {
  margin-left: 0;
  margin-right: auto;
}

/* Button Adjustments for RTL */
[dir="rtl"] .btn-link {
  text-align: right;
}

/* Form Control Adjustments */
[dir="rtl"] .form-control,
[dir="rtl"] .form-select {
  text-align: right;
}

/* List Adjustments for RTL */
[dir="rtl"] ul,
[dir="rtl"] ol {
  padding-right: 2rem;
  padding-left: 0;
}

/* Navigation Adjustments */
[dir="rtl"] .navbar-nav {
  flex-direction: row-reverse;
}

/* Card Adjustments */
[dir="rtl"] .card {
  text-align: right;
}

/* Modal Adjustments */
[dir="rtl"] .modal-header {
  flex-direction: row-reverse;
}

[dir="rtl"] .modal-header .btn-close {
  margin-left: 0;
  margin-right: auto;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .language-flag-container {
    top: 15px;
    left: 70px;
  }

  [dir="rtl"] .language-flag-container {
    left: 70px;
    right: auto;
  }

  .current-flag-btn {
    width: 40px;
    height: 40px;
    padding: 3px;
  }

  .current-flag-btn .flag-icon {
    width: 28px;
    height: 28px;
  }

  .flag-menu {
    min-width: 140px;
  }

  .flag-menu-item {
    padding: 8px 12px;
    font-size: 13px;
  }

  .flag-menu-item .flag-icon {
    width: 20px;
    height: 20px;
  }

  /* Adjust display options button for mobile */
  #display-options-btn {
    width: 45px !important;
    height: 45px !important;
  }
}
