/* ---------------------------------
   Language Switcher Styles
--------------------------------- */
.lang-switcher {
  position: relative;
  z-index: 1001;
}

/* Header (public pages) - space from logo */
.header-container > .lang-switcher {
  margin-inline-start: 60px;
}

.lang-switcher-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.lang-switcher-btn:hover {
  background: rgba(201, 168, 76, 0.1);
  border-color: var(--accent-gold);
}

.lang-arrow {
  font-size: 0.6rem;
  transition: transform 0.3s ease;
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 180px;
  background: var(--bg-color-light);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
  overflow: hidden;
  z-index: 1002;
}

/* RTL: dropdown opens to right */
[dir="rtl"] .lang-dropdown {
  left: auto;
  right: 0;
}

.lang-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

[dir="rtl"] .lang-option {
  text-align: right;
}

.lang-option:hover {
  background: rgba(201, 168, 76, 0.08);
  color: var(--text-main);
}

.lang-option.active {
  background: rgba(201, 168, 76, 0.12);
  color: var(--accent-gold);
  font-weight: 600;
}

.lang-flag {
  font-size: 1.2rem;
}

.lang-name {
  flex: 1;
}

/* Flag images */
.lang-flag-img {
  width: 24px;
  height: 16px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.lang-switcher-btn .lang-flag-img {
  width: 20px;
  height: 14px;
}

/* GLOBAL: Force LTR on ALL inputs regardless of page direction */
/* This ensures numbers always render as Western digits (0-9) */
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="url"],
select,
textarea {
  direction: ltr !important;
  text-align: left !important;
  unicode-bidi: bidi-override;
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
  -moz-font-feature-settings: "lnum" 1, "tnum" 1;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* EN-text always LTR with Western numerals */
.en-text {
  direction: ltr !important;
  unicode-bidi: bidi-override;
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* LTR body overrides */
body.ltr {
  direction: ltr;
  text-align: left;
}

body.ltr .en-text {
  direction: ltr;
}

body.ltr .sidebar {
  border-right: 1px solid var(--border-color);
  border-left: none;
}

body.ltr .nav-links a.active,
body.ltr .nav-links a:hover {
  border-left: 3px solid var(--accent-gold);
  border-right: none;
}

body.ltr .form-control {
  direction: ltr;
  text-align: left;
}

body.ltr header .header-container {
  flex-direction: row;
}

/* LTR: Fix dashboard tables, stats, and layout */
body.ltr table {
  text-align: center;
}

body.ltr table th,
body.ltr table td {
  text-align: center;
}

body.ltr .stat-card {
  text-align: center;
}

body.ltr .topbar {
  flex-direction: row;
}

body.ltr .form-group {
  text-align: left !important;
}

body.ltr .main-panel {
  text-align: left;
}

body.ltr .field-status,
body.ltr .field-hint,
body.ltr .strength-text {
  text-align: left !important;
}

/* Responsive language switcher */
@media (max-width: 992px) {
  .lang-switcher {
    order: -1;
  }
}

@media (max-width: 768px) {
  .lang-switcher {
    order: -1;
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;
  }
  
  /* Remove margin so it doesn't push things */
  .header-container > .lang-switcher {
    margin-inline-start: 0;
  }
  
  .lang-switcher-btn {
    padding: 5px 10px;
    font-size: 0.78rem;
    gap: 5px;
  }
  .lang-switcher-btn .lang-flag-img {
    width: 16px;
    height: 11px;
  }
  .lang-arrow { font-size: 0.5rem; }
  
  .lang-dropdown {
    position: fixed;
    top: 55px;
    left: 10px;
    right: 10px;
    width: auto;
  }
}

@media (max-width: 480px) {
  .lang-switcher-btn {
    padding: 4px 8px;
    font-size: 0.72rem;
  }
  .lang-name { font-size: 0.82rem; }
  .lang-option { padding: 10px 14px; }
}

/* Dashboard sidebar language switcher */
.sidebar .lang-switcher {
  margin: 0 0 25px;
}

.sidebar .lang-switcher-btn {
  width: 100%;
  justify-content: center;
}

.sidebar .lang-dropdown {
  width: 100%;
}
