/* Language switcher, light/dark theme and RTL support.
   Inactive on the home page (html.bl-home). Loaded by components/layouts/app.blade.php */

/* ---- Hide until translated (CSS-only failsafe reveals after 1.6s) ---- */
html.bl-i18n-pending body {
  visibility: hidden;
  animation: bl-reveal 0s linear 1.6s forwards;
}
@keyframes bl-reveal { to { visibility: visible; } }

/* ---- Switcher (lives inside the header menu drawer) ---- */
html.bl-home .bl-switcher [data-bl-theme-btn], html.bl-home .bl-header-tools [data-bl-theme-btn] { display: none !important; }

.bl-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 12px 6px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  position: relative;
}
.bl-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(1, 255, 167, 0.45);
  border-radius: 10px;
  background: rgba(1, 255, 167, 0.08);
  color: #01ffa7;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}
.bl-switch-btn:hover,
.bl-switch-btn:focus-visible { background: rgba(1, 255, 167, 0.18); outline: none; }
.bl-switch-btn i { font-size: 17px; }

.bl-lang-wrap { position: relative; }
.bl-lang-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 190px;
  padding: 6px;
  border: 1px solid rgba(1, 255, 167, 0.35);
  border-radius: 12px;
  background: #07120f;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  z-index: 5;
}
.bl-lang-menu[hidden] { display: none; }
.bl-lang-menu button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 15px;
  text-align: start;
  cursor: pointer;
}
.bl-lang-menu button:hover { background: rgba(1, 255, 167, 0.14); }
.bl-lang-menu button.is-active { color: #01ffa7; font-weight: 700; }

/* ---- Light theme: the site is dark by design, so light is a colour inversion.
        Media and maps are inverted back so they keep their real colours. ---- */
html[data-bl-theme="light"] {
  filter: invert(1) hue-rotate(180deg);
  background-color: #000;
  color-scheme: light;
}
html[data-bl-theme="light"] :is(img, video, canvas, iframe, picture, .leaflet-container, .bl-keep-colors) {
  filter: invert(1) hue-rotate(180deg);
}
html[data-bl-theme="light"] .leaflet-container img,
html[data-bl-theme="light"] .leaflet-container canvas,
html[data-bl-theme="light"] .bl-keep-colors img {
  filter: none;
}

/* ---- RTL (Persian & other right-to-left languages) ---- */
html[dir="rtl"] body {
  direction: rtl;
  text-align: right;
}
html[dir="rtl"] :where(.navbar-header, .leaflet-container, #earth-container, #countryModal, .bazaar-loader) {
  direction: ltr;
}
html[dir="rtl"] .header-drawer { direction: rtl; text-align: right; }
html[dir="rtl"] .bl-lang-menu { left: auto; right: 0; }
html[dir="rtl"] :where(body, h1, h2, h3, h4, h5, h6, p, a, span, small, strong, b, button, input, select, textarea, label, li, td, th, div):not(.fas):not(.far):not(.fab):not(.fa):not([class*="fa-"]) {
  font-family: "Vazirmatn", "IRANSans", Tahoma, "Segoe UI", sans-serif !important;
}

/* ---- Icon buttons in the header, right after the sign-up button (desktop) ---- */

.bl-header-tools { display: inline-flex; align-items: center; gap: 8px; margin-inline-start: 10px; position: relative; }
.bl-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; padding: 0; border-radius: 50%;
  border: 1px solid rgba(1, 255, 167, 0.5); background: rgba(1, 255, 167, 0.08);
  color: #01ffa7; font-size: 17px; cursor: pointer; transition: background .2s;
}
.bl-icon-btn:hover, .bl-icon-btn:focus-visible { background: rgba(1, 255, 167, 0.2); outline: none; }
.bl-header-tools .bl-lang-wrap { position: relative; }

/* ---- Language popup (modal) with search ---- */
.bl-lang-modal {
  position: fixed; inset: 0; z-index: 2147483000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px);
}
.bl-lang-modal[hidden] { display: none; }
html.bl-lang-open { overflow: hidden; }
.bl-lang-panel {
  width: 100%; max-width: 560px; max-height: 86vh; display: flex; flex-direction: column;
  padding: 18px; border: 1px solid rgba(1, 255, 167, 0.5); border-radius: 16px;
  background: #07120f; color: #fff; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.bl-lang-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; color: #01ffa7; font-size: 18px; }
.bl-lang-close {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid #467264;
  background: #18332a; color: #fff; font-size: 24px; line-height: 1; cursor: pointer;
}
.bl-lang-search {
  width: 100%; box-sizing: border-box; margin-bottom: 12px; padding: 12px 14px;
  border: 1px solid rgba(1, 255, 167, 0.5); border-radius: 10px;
  background: #101c1a; color: #fff; font-size: 16px; outline: none;
}
.bl-lang-search:focus { border-color: #01ffa7; box-shadow: 0 0 0 2px rgba(1, 255, 167, 0.25); }
.bl-lang-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 2px; }
.bl-lang-list button {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 12px; text-align: start;
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 10px; background: rgba(255, 255, 255, 0.04);
  color: #fff; font-size: 16px; cursor: pointer;
}
.bl-lang-list button:hover, .bl-lang-list button:focus-visible { background: rgba(1, 255, 167, 0.14); border-color: #01ffa7; outline: none; }
.bl-lang-list button.is-active { border-color: #01ffa7; color: #01ffa7; font-weight: 700; }
.bl-lang-list button[hidden] { display: none; }
.bl-lang-list small { margin-inline-start: auto; color: #8fa8a0; font-size: 12px; }
.bl-lang-list button i { color: #01ffa7; }
.bl-lang-empty { padding: 16px; color: #8fa8a0; font-size: 15px; text-align: center; }
@media (max-width: 480px) { .bl-lang-list { grid-template-columns: 1fr; } }
