/* Global Font - Tajawal */
html, body {
  font-family: 'Tajawal', sans-serif !important;
}

body *:not(.fa):not(.fas):not(.far):not(.fab):not(.fal):not([class*="fa-"]):not(i.menu-icon) {
  font-family: 'Tajawal', sans-serif;
}

/* RTL Sidebar - Arrow direction fix */
[dir="rtl"] .sidebar .fa.arrow:before {
  content: "\f104" !important;
}

[dir="rtl"] .sidebar .active > a > .fa.arrow:before {
  content: "\f107" !important;
}

/* RTL Sidebar - Arrow float direction */
[dir="rtl"] .sidebar .arrow {
  float: left !important;
}

/* RTL Sidebar - Menu icon direction */
[dir="rtl"] .sidebar ul.nav li a i.menu-icon {
  float: right !important;
  margin-right: 0 !important;
  margin-left: 14px !important;
}

/* RTL Sidebar - Sub-menu padding */
[dir="rtl"] .sidebar ul.nav li .nav-second-level li a {
  padding: 5px 48px 5px 15px !important;
  text-align: right !important;
}

/* RTL Sidebar - Text alignment */
[dir="rtl"] .sidebar ul.nav li a {
  text-align: right;
}

/* Keep TinyMCE internals stable in LTR so menus continue to open correctly */
[dir="rtl"] .tox.tox-tinymce,
[dir="rtl"] .tox.tox-tinymce .tox-editor-header,
[dir="rtl"] .tox.tox-tinymce .tox-statusbar,
[dir="rtl"] .tox.tox-tinymce iframe {
  direction: ltr !important;
  text-align: left !important;
}

/* Show the visible menu and toolbar rows in RTL without changing popup positioning logic */
[dir="rtl"] .tox.tox-tinymce .tox-menubar,
[dir="rtl"] .tox.tox-tinymce .tox-toolbar,
[dir="rtl"] .tox.tox-tinymce .tox-toolbar__primary {
  direction: rtl !important;
  text-align: right !important;
}

[dir="rtl"] .tox.tox-tinymce .tox-menubar,
[dir="rtl"] .tox.tox-tinymce .tox-toolbar__primary {
  justify-content: flex-start;
}

[dir="rtl"] .tox.tox-tinymce .tox-toolbar__group,
[dir="rtl"] .tox.tox-tinymce .tox-mbtn,
[dir="rtl"] .tox.tox-tinymce .tox-tbtn--select,
[dir="rtl"] .tox.tox-tinymce .tox-listbox,
[dir="rtl"] .tox.tox-tinymce .tox-listboxfield {
  direction: rtl !important;
}

/* Keep TinyMCE popup container in LTR to preserve correct dropdown positioning */
.tox-tinymce-aux {
  direction: ltr !important;
  z-index: 2147483646 !important;
}

/* Render TinyMCE popup menus left-to-right in Arabic so dropdowns and submenus open correctly */
[dir="rtl"] .tox-tinymce-aux,
[dir="rtl"] .tox-tinymce-aux .tox-menu,
[dir="rtl"] .tox-tinymce-aux .tox-collection,
[dir="rtl"] .tox-tinymce-aux .tox-collection__group,
[dir="rtl"] .tox-tinymce-aux .tox-collection__item,
[dir="rtl"] .tox-tinymce-aux .tox-menu-nav,
[dir="rtl"] .tox-tinymce-aux .tox-pop {
  direction: ltr !important;
  text-align: left !important;
}

[dir="rtl"] .tox-tinymce-aux .tox-collection__item-label,
[dir="rtl"] .tox-tinymce-aux .tox-mbtn__select-label,
[dir="rtl"] .tox-tinymce-aux .tox-tbtn__select-label,
[dir="rtl"] .tox-tinymce-aux .tox-collection__item-accessory {
  text-align: left !important;
}

[dir="rtl"] .tox-tinymce-aux .tox-collection .tox-collection__item-caret,
[dir="rtl"] .tox-tinymce-aux .tox-collection__item-accessory {
  margin-left: 16px !important;
  margin-right: 0 !important;
}

[dir="rtl"] .tox-tinymce-aux .tox-collection .tox-collection__item-caret {
  transform: none !important;
}

.mce-content-body-ltr {
  direction: ltr;
  text-align: left;
}

.mce-content-body-rtl {
  direction: rtl;
  text-align: right;
}

/* =====================================================
   Fix: sidebar and header stay fixed during scroll
   ===================================================== */

/* Keep the top header bar fixed to the viewport */
#header {
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

/* Keep ONLY the main sidebar (#menu) fixed — NOT the setup-menu-wrapper */
#menu.sidebar {
  position: fixed !important;
  top: 57px;
  bottom: 0;
  height: auto !important;
  min-height: 0 !important;
  max-height: 100vh !important;
  display: flex !important;
  flex-direction: column;
  overflow: hidden !important;
}

/* Prevent profile and company selector from shrinking — let the menu list scroll */
#menu.sidebar .sidebar-user-profile,
#menu.sidebar .mc-company-widget,
#menu.sidebar > div {
  flex-shrink: 0;
}

/* Make the nav menu list scroll independently inside the fixed sidebar */
#menu.sidebar ul#side-menu {
  flex: 1 1 auto;
  overflow-y: auto !important;
  overflow-x: hidden;
  min-height: 0;
  padding-bottom: 16px;
}

/* Keep setup-menu-wrapper positioned inside the fixed #menu area */
#setup-menu-wrapper {
  position: fixed !important;
  top: 57px;
  bottom: 0;
  overflow-y: auto !important;
}

/* Offset wrapper content below the fixed header */
#wrapper {
  padding-top: 57px;
}

/* =====================================================
   Company Selector - Multi-Company Widget
   ===================================================== */

/* ---- Toggle Button ---- */
.mc-dropdown {
  position: relative;
}

.mc-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(0,0,0,.1);
  border-radius: 10px;
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
  cursor: pointer;
  transition: all .2s ease;
  font-size: 13px;
  color: #334155;
  text-align: inherit;
}

.mc-dropdown-toggle:hover {
  border-color: rgba(var(--primary-rgb, 84,130,53), .45);
  background: linear-gradient(135deg, #f0f5ff 0%, #e8eef6 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.mc-dropdown.open .mc-dropdown-toggle {
  border-color: rgba(var(--primary-rgb, 84,130,53), .5);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 84,130,53), .1);
}

/* ---- Icon circle ---- */
.mc-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #548235 0%, #6a9f45 100%);
  color: #fff;
  font-size: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(84,130,53,.25);
}

/* ---- Company name ---- */
.mc-company-name {
  flex: 1 1 auto;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* ---- Chevron ---- */
.mc-chevron {
  flex-shrink: 0;
  font-size: 10px;
  color: #94a3b8;
  transition: transform .25s ease;
}

.mc-dropdown.open .mc-chevron {
  transform: rotate(180deg);
}

/* ---- Dropdown Menu ---- */
.mc-dropdown-menu {
  display: none;
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 4px);
  z-index: 1050;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,.12), 0 4px 6px -2px rgba(0,0,0,.06);
  max-height: 220px;
  overflow-y: auto;
}

.mc-dropdown.open .mc-dropdown-menu {
  display: block;
  animation: mcSlideDown .2s ease;
}

@keyframes mcSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Dropdown Item ---- */
.mc-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  color: #475569;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none !important;
  transition: background .15s ease, color .15s ease;
  cursor: pointer;
}

.mc-dropdown-item:hover,
.mc-dropdown-item:focus {
  background: #f1f5f9;
  color: #1e293b;
  text-decoration: none !important;
}

.mc-dropdown-item.active {
  background: linear-gradient(135deg, rgba(84,130,53,.08) 0%, rgba(84,130,53,.04) 100%);
  color: #548235;
  font-weight: 600;
}

.mc-dropdown-item .mc-item-icon {
  font-size: 11px;
  opacity: .5;
}

.mc-dropdown-item.active .mc-item-icon {
  opacity: 1;
  color: #548235;
}

.mc-dropdown-item .mc-check-icon {
  margin-inline-start: auto;
  font-size: 11px;
  color: #548235;
}

/* ---- Single company badge ---- */
.mc-single-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 10px;
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
  font-size: 13px;
  color: #334155;
}

/* ---- RTL adjustments ---- */
[dir="rtl"] .mc-dropdown-menu {
  text-align: right;
}

[dir="rtl"] .mc-dropdown-item .mc-check-icon {
  margin-right: auto;
  margin-left: 0;
}
