/**
 * MLT Globe Toggle - CSS (زر الكرة الأرضية + قائمة اللغات)
 * @version 1.6.0
 */

:root {
  --mlt-globe-size: 58px;
  --mlt-globe-bg: linear-gradient(145deg, #0a84ff 0%, #0055d4 100%);
  --mlt-globe-fg: #ffffff;
  --mlt-globe-shadow: 0 10px 30px rgba(10, 132, 255, 0.35), 0 2px 8px rgba(0, 0, 0, 0.18);
  --mlt-globe-menu-bg: rgba(255, 255, 255, 0.92);
  --mlt-globe-menu-border: rgba(0, 0, 0, 0.06);
  --mlt-globe-text: #1d1d1f;
  --mlt-globe-text-2: #6e6e73;
  --mlt-globe-accent: #0a84ff;
  --mlt-globe-radius: 18px;
  --mlt-anim: 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

/* الحاوية العائمة */
.mlt-globe {
  position: fixed;
  z-index: 99990;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.mlt-globe--bottom-right { right: 22px; bottom: 22px; }
.mlt-globe--bottom-left  { left: 22px;  bottom: 22px; align-items: flex-start; }
.mlt-globe--top-right    { right: 22px; top: 22px; }
.mlt-globe--top-left     { left: 22px;  top: 22px; align-items: flex-start; }

/* زر الكرة الأرضية (FAB) */
.mlt-globe__fab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--mlt-globe-size);
  height: var(--mlt-globe-size);
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--mlt-globe-bg);
  color: var(--mlt-globe-fg);
  box-shadow: var(--mlt-globe-shadow);
  cursor: pointer;
  transition: transform var(--mlt-anim), box-shadow var(--mlt-anim);
  -webkit-tap-highlight-color: transparent;
}

.mlt-globe__fab:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 14px 36px rgba(10, 132, 255, 0.45), 0 3px 10px rgba(0, 0, 0, 0.2);
}

.mlt-globe__fab:active { transform: scale(0.96); }

.mlt-globe__fab:focus-visible {
  outline: 3px solid var(--mlt-globe-accent);
  outline-offset: 3px;
}

.mlt-globe__icon { display: block; }

/* شارة اللغة الحالية على الزر */
.mlt-globe__badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 4px;
  border-radius: 12px;
  background: #ffffff;
  border: 2px solid var(--mlt-globe-accent);
  font-size: 13px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* القائمة */
.mlt-globe__menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 210px;
  padding: 8px;
  background: var(--mlt-globe-menu-bg);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid var(--mlt-globe-menu-border);
  border-radius: var(--mlt-globe-radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transform-origin: bottom center;
  pointer-events: none;
  transition: opacity 0.18s ease, transform var(--mlt-anim);
}

.mlt-globe.is-open .mlt-globe__menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* المواضع العلوية: نقطة origin من الأعلى */
.mlt-globe--top-right .mlt-globe__menu,
.mlt-globe--top-left .mlt-globe__menu {
  transform-origin: top center;
  transform: translateY(-8px) scale(0.96);
}
.mlt-globe--top-right.is-open .mlt-globe__menu,
.mlt-globe--top-left.is-open .mlt-globe__menu {
  transform: translateY(0) scale(1);
}

/* خيار لغة */
.mlt-globe__option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--mlt-globe-text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s ease;
}

.mlt-globe__option:hover,
.mlt-globe__option:focus-visible {
  background: rgba(10, 132, 255, 0.1);
  outline: none;
}

.mlt-globe__option.is-current {
  background: rgba(10, 132, 255, 0.14);
  color: var(--mlt-globe-accent);
  font-weight: 600;
}

.mlt-globe__flag { font-size: 20px; line-height: 1; }
.mlt-globe__name { flex: 1 1 auto; }

.mlt-globe__tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--mlt-globe-text-2);
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 8px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.mlt-globe__check { color: var(--mlt-globe-accent); flex: 0 0 auto; }

/* الوضع الليلي */
@media (prefers-color-scheme: dark) {
  :root {
    --mlt-globe-menu-bg: rgba(28, 28, 30, 0.92);
    --mlt-globe-menu-border: rgba(255, 255, 255, 0.1);
    --mlt-globe-text: #f5f5f7;
    --mlt-globe-text-2: #98989d;
  }
  .mlt-globe__badge { background: #1c1c1e; }
  .mlt-globe__tag { background: rgba(255, 255, 255, 0.12); }
}

/* شاشات صغيرة */
@media (max-width: 480px) {
  :root { --mlt-globe-size: 52px; }
  .mlt-globe--bottom-right { right: 14px; bottom: 14px; }
  .mlt-globe--bottom-left  { left: 14px;  bottom: 14px; }
  .mlt-globe--top-right    { right: 14px; top: 14px; }
  .mlt-globe--top-left     { left: 14px;  top: 14px; }
  .mlt-globe__menu { min-width: 190px; }
}

@media (prefers-reduced-motion: reduce) {
  .mlt-globe__fab,
  .mlt-globe__menu,
  .mlt-globe__option { transition: none; }
}

/* كلاس للقارئات الشاشة (sr-only) */
.mlt-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ===== الأعلام كـ SVG (تعمل على كل الأنظمة) ===== */
.mlt-globe__flag--svg svg,
.mlt-globe__badge svg {
    display: block;
    width: 22px;
    height: 15px;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.mlt-globe__option .mlt-globe__flag--svg svg {
    width: 24px;
    height: 16px;
}
/* شارة العلم على الزر: أكبر قليلاً */
.mlt-globe__badge svg {
    width: 26px;
    height: 18px;
}
.mlt-globe__badge {
    font-size: 0; /* نخفي أي نص emoji احتياطاً */
}

/* ===== تكبير أيقونة الكرة الأرضية بمقدار 1.7 (26px → 44px) ===== */
.mlt-globe__fab .mlt-globe__icon {
    width: 44px;
    height: 44px;
}
/* fabricant slightly bigger FAB to fit the bigger icon */
.mlt-globe__fab {
    width: 64px;
    height: 64px;
}

/* ============================================================
 * v1.6.1 — أوضاع إضافية (وسط) + الأشكال (globe / pill / square)
 * ============================================================ */

/* المواضع الوسطى */
.mlt-globe--bottom-center { left: 50%; transform: translateX(-50%); bottom: 22px; }
.mlt-globe--top-center    { left: 50%; transform: translateX(-50%); top: 22px; align-items: center; flex-direction: column-reverse; }

/* المواضع العلوية: القائمة تُفتح أسفل الزر */
.mlt-globe--top-right,
.mlt-globe--top-left { flex-direction: column-reverse; }
.mlt-globe--top-right .mlt-globe__menu,
.mlt-globe--top-left .mlt-globe__menu,
.mlt-globe--top-center .mlt-globe__menu {
  transform-origin: top center;
  transform: translateY(-8px) scale(0.96);
}
.mlt-globe--top-right.is-open .mlt-globe__menu,
.mlt-globe--top-left.is-open .mlt-globe__menu,
.mlt-globe--top-center.is-open .mlt-globe__menu {
  transform: translateY(0) scale(1);
}

/* تلميح معرض الـ focus */
.mlt-globe__fab:focus-visible,
.mlt-globe__option:focus-visible {
  outline: 3px solid rgba(10, 132, 255, 0.55);
  outline-offset: 2px;
}

/* label داخل الزر (يُعرض في شكل pill فقط) */
.mlt-globe__fab-label {
  display: none;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.mlt-globe__fab-flag { display: inline-flex; width: 20px; height: 20px; }
.mlt-globe__fab-flag svg { width: 20px; height: 20px; border-radius: 50%; }

/* ---- الشكل 1: كرة أرضية (افتراضي) ---- */
.mlt-shape--globe .mlt-globe__fab-label { display: none; }
.mlt-shape--globe .mlt-globe__badge { display: block; }

/* ---- الشكل 2: كبسولة (pill) ---- */
.mlt-shape--pill .mlt-globe__fab {
  width: auto;
  height: 46px;
  padding: 0 18px 0 12px;
  border-radius: 999px;
  gap: 4px;
}
.mlt-shape--pill .mlt-globe__icon { width: 24px; height: 24px; }
.mlt-shape--pill .mlt-globe__fab-label { display: inline-flex; }
.mlt-shape--pill .mlt-globe__badge { display: none; }
.mlt-shape--pill .mlt-globe__menu { min-width: 190px; }

/* ---- الشكل 3: مربع (square) ---- */
.mlt-shape--square .mlt-globe__fab {
  width: 56px;
  height: 56px;
  border-radius: 16px;
}
.mlt-shape--square .mlt-globe__icon { width: 30px; height: 30px; }
.mlt-shape--square .mlt-globe__fab-label { display: none; }

/* تحسين المظهر العام للقائمة */
.mlt-globe__menu {
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22), 0 4px 14px rgba(0, 0, 0, 0.12);
}
.mlt-globe__option:hover { background: rgba(10, 132, 255, 0.10); }
.mlt-globe__option .mlt-globe__flag { width: 22px; height: 22px; }
.mlt-globe__option .mlt-globe__flag svg { width: 22px; height: 22px; }

/* الجوال: أوضاع وسط */
@media (max-width: 600px) {
  .mlt-globe--bottom-center { bottom: 14px; }
  .mlt-globe--top-center    { top: 14px; }
}
