/* ============================================
   LANGUAGE TOGGLE BUTTON - Premium Floating UI
   ============================================ */

/* Floating Toggle Button */
.lang-toggle-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 50px;
  background: rgba(30, 30, 60, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Inter', 'Segoe UI', sans-serif;
  letter-spacing: 0.3px;
  user-select: none;
  -webkit-user-select: none;
}

.lang-toggle-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 28px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.15);
  background: rgba(40, 40, 80, 0.95);
}

.lang-toggle-btn:active {
  transform: translateY(0) scale(0.98);
}

.lang-toggle-btn .lang-icon {
  font-size: 18px;
  line-height: 1;
}

.lang-toggle-btn .lang-label {
  line-height: 1;
}

/* When showing Urdu option (currently English mode) */
.lang-toggle-btn[data-current-lang="en"] .lang-label {
  font-family: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', serif;
  font-size: 15px;
}

/* Tooltip on hover */
.lang-toggle-btn::after,
.header-lang-btn::after,
.lang-toggle-btn-header::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  padding: 6px 14px;
  border-radius: 8px;
  background: rgba(0,0,0,0.85);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
}

.lang-toggle-btn:hover::after,
.header-lang-btn:hover::after,
.lang-toggle-btn-header:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* Pulse animation on first load */
@keyframes langPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.1); }
  50% { box-shadow: 0 4px 20px rgba(99,102,241,0.5), 0 0 0 2px rgba(99,102,241,0.3); }
}

.lang-toggle-btn.pulse {
  animation: langPulse 2s ease-in-out 3;
}

/* ============================================
   LTR MODE ADJUSTMENTS (English)
   ============================================ */

/* When document is LTR (English mode) */
html[dir="ltr"] body {
  text-align: left;
}

html[dir="ltr"] .sidebar,
html[dir="ltr"] .dashboard-sidebar {
  left: 0;
  right: auto;
  border-right: 1px solid rgba(255,255,255,0.1);
  border-left: none;
}

html[dir="ltr"] .main-content,
html[dir="ltr"] .dashboard-main {
  margin-left: 260px;
  margin-right: 0;
}

html[dir="ltr"] .nav-links {
  flex-direction: row;
}

/* Tables in LTR */
html[dir="ltr"] th,
html[dir="ltr"] td {
  text-align: left;
}

/* Form labels */
html[dir="ltr"] label {
  text-align: left;
}

/* Input fields */
html[dir="ltr"] input,
html[dir="ltr"] textarea,
html[dir="ltr"] select {
  text-align: left;
  direction: ltr;
}

/* Buttons alignment */
html[dir="ltr"] .btn-group,
html[dir="ltr"] .form-actions {
  text-align: left;
}

/* Modal close buttons */
html[dir="ltr"] .modal-close {
  right: 15px;
  left: auto;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .lang-toggle-btn {
    bottom: 16px;
    left: 16px;
    padding: 8px 14px;
    font-size: 13px;
  }

  html[dir="ltr"] .main-content,
  html[dir="ltr"] .dashboard-main {
    margin-left: 0;
  }
}

/* Smooth transition when switching languages */
html {
  transition: direction 0s;
}

[data-lang-key],
[data-lang-placeholder] {
  transition: opacity 0.15s ease;
}

.lang-switching [data-lang-key],
.lang-switching [data-lang-placeholder] {
  opacity: 0.6;
}

/* ============================================
   HEADER LANGUAGE TOGGLE BUTTON STYLE
   ============================================ */
.header-lang-btn {
  position: static !important;
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  padding: 6px 12px !important;
  font-size: 0.95rem !important;
  border: 1px solid var(--glass-border) !important;
  background: var(--glass-bg) !important;
  color: var(--gold) !important;
  border-radius: var(--radius-md) !important;
  cursor: pointer;
  box-shadow: none !important;
  transition: all 0.3s ease;
  font-family: inherit !important;
  margin-left: 8px;
  margin-right: 8px;
}

.header-lang-btn:hover {
  transform: translateY(-1px) !important;
  background: rgba(255, 255, 255, 0.15) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
}

/* Tooltip adjustment when inside header */
.header-lang-btn::after,
.lang-toggle-btn-header::after {
  top: calc(100% + 10px) !important;
  bottom: auto !important;
}

/* Other Pages Header Language Button Style */
.lang-toggle-btn-header {
  position: static !important;
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  padding: 6px 12px !important;
  font-size: 0.9rem !important;
  cursor: pointer;
  box-shadow: none !important;
  transition: all 0.3s ease;
  font-family: inherit !important;
  border-radius: var(--radius-md) !important;
  background: white !important;
  color: var(--text-dark) !important;
  border: 1px solid var(--border-color) !important;
  margin-left: 8px;
  margin-right: 8px;
}

.lang-toggle-btn-header:hover {
  background: var(--bg-app) !important;
  border-color: var(--text-light) !important;
  transform: translateY(-1px) !important;
}

/* ============================================
   PREVENT HEADER LAYOUT SHIFT (LTR/RTL SWITCH)
   ============================================ */
.header-container {
  direction: ltr !important;
}

/* Maintain standard text flow inside header elements */
.header-container .logo,
.header-container .nav-links {
  direction: ltr !important;
}

/* ============================================
   RTL/LTR SEARCH & DROPDOWN LAYOUT FIXES
   ============================================ */
html[dir="ltr"] .category-select-wrapper::after {
  left: auto !important;
  right: 12px !important;
}

html[dir="ltr"] .category-select-wrapper span {
  left: auto !important;
  right: 15px !important;
}

html[dir="ltr"] .category-select {
  padding: 10px 35px 10px 15px !important;
}

html[dir="ltr"] #dashSearchInput {
  padding-right: 15px !important;
  padding-left: 40px !important;
}

html[dir="ltr"] #dashSearchInput + span {
  right: auto !important;
  left: 15px !important;
}

/* ============================================
   DYNAMIC DATABASE TEXT DIRECTION CONTROLS
   ============================================ */
.force-urdu-dir {
  direction: rtl !important;
  font-family: var(--font-urdu), 'Noto Nastaliq Urdu', serif !important;
}

h3.force-urdu-dir,
p.force-urdu-dir,
span.force-urdu-dir,
div.force-urdu-dir:not(.wholesaler-info) {
  text-align: right !important;
}

.force-english-dir {
  direction: ltr !important;
  font-family: var(--font-primary), 'Inter', sans-serif !important;
}

h3.force-english-dir,
p.force-english-dir,
span.force-english-dir,
div.force-english-dir:not(.wholesaler-info) {
  text-align: left !important;
}

/* Exclude centered header business name from alignment force */
.wholesaler-info h3.force-urdu-dir,
.wholesaler-info h3.force-english-dir {
  text-align: center !important;
}
