html[dir="rtl"] body {
  font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  overflow-x: hidden;
}

html[dir="rtl"] .layout-navbar {
  right: 0;
  overflow: visible;
  direction: rtl;
}

/* محاذاة قوائم Select2 داخل الهيدر */
#layout-navbar {
  position: relative;
  z-index: 3050;
  overflow: visible;
}

#layout-navbar .navbar-dropdown,
#layout-navbar .navbar-dropdown .dropdown-menu {
  z-index: 3060;
}

#layout-navbar .dropdown-menu {
  z-index: 3060;
}

.layout-navbar,
.layout-navbar .navbar-nav,
.layout-navbar .nav-item,
.layout-navbar .dropdown {
  overflow: visible;
}

/* Keep Sneat sidebar on the right in RTL */
html[dir="rtl"] .layout-container {
  direction: rtl;
}

html[dir="rtl"] .layout-menu {
  left: auto !important;
  right: 0 !important;
}

html[dir="rtl"] .layout-page {
  padding-left: 0 !important;
  padding-right: 16.25rem;
}

html[dir="rtl"].layout-menu-collapsed .layout-page {
  padding-right: 5.25rem;
}

html[dir="rtl"] .layout-navbar {
  left: 0;
  right: 0;
}

html[dir="rtl"] .content-wrapper,
html[dir="rtl"] .content-wrapper .container-fluid {
  text-align: right;
}

html[dir="rtl"] .navbar-dropdown.dropdown-user .dropdown-menu {
  left: 0;
  right: auto;
  top: calc(100% + 0.35rem);
  z-index: 3060;
}

/* قائمة المستخدم — نفس أسلوب Sneat (رأس + أيقونات + فواصل) */
.dropdown-user-menu {
  min-width: 16.5rem;
  padding: 0;
  border-radius: 0.375rem;
  border: 1px solid rgba(67, 89, 113, 0.12);
  box-shadow: 0 0.25rem 1rem rgba(67, 89, 113, 0.14);
  overflow: hidden;
  position: absolute;
  z-index: 3060;
}

.dropdown-user-menu__header {
  background: #f5f5f9;
}

.dropdown-user-menu__name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: #566a7f;
}

.dropdown-user-menu__role {
  font-size: 0.8125rem;
  color: #a1acb8;
  margin-top: 0.15rem;
}

.dropdown-user-menu__header .avatar-md {
  width: 2.5rem;
  height: 2.5rem;
}

.dropdown-user-menu__header .avatar-md .avatar-initial {
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.dropdown-user-menu .dropdown-user-menu__item {
  color: #566a7f;
  font-size: 0.9375rem;
}

.dropdown-user-menu .dropdown-user-menu__item i {
  color: #697a8d;
}

.dropdown-user-menu .dropdown-user-menu__item:hover,
.dropdown-user-menu .dropdown-user-menu__item:focus {
  background-color: rgba(67, 89, 113, 0.06);
  color: #566a7f;
}

.dropdown-user-menu .dropdown-user-menu__logout {
  color: #ff3e1d;
}

.dropdown-user-menu .dropdown-user-menu__logout i {
  color: #ff3e1d;
}

.dropdown-user-menu .dropdown-user-menu__logout:hover,
.dropdown-user-menu .dropdown-user-menu__logout:focus {
  background-color: rgba(255, 62, 29, 0.08);
  color: #ff3e1d;
}

html[dir="rtl"] .dropdown-user-menu {
  text-align: right;
}

html[dir="rtl"] #layout-navbar .navbar-user-menu-end {
  order: 30;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-inline-start: 0 !important;
  margin-inline-end: 0 !important;
}

html[dir="rtl"] #layout-navbar .main-header-workspace {
  order: 1;
  flex: 0 1 auto;
  min-width: 0;
  gap: 0.5rem;
  margin-inline: 0.25rem 0.75rem;
}

#layout-navbar .navbar-spacer {
  order: 20;
  min-width: 1rem;
}

.navbar-user-inline {
  max-width: 14rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bs-heading-color, #566a7f);
  vertical-align: middle;
}

/* Sidebar: logo ثم اسم المستخدم تحته بوضوح (بدون تداخل مع الصورة) */
.layout-menu .app-brand.app-brand-sidebar-wrap {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 64px;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.app-brand-sidebar-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  padding-inline: 0.35rem;
}

.app-brand-sidebar-inner .sidebar-brand-logo-wrap {
  justify-content: center;
  width: auto !important;
}

.layout-menu .app-brand .sidebar-user-name {
  opacity: 1;
  color: rgba(255, 255, 255, 0.96);
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
  max-width: 100%;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* قائمة فاتحة: اسم أوضح على خلفية فاتحة */
.layout-menu.menu-light .app-brand .sidebar-user-name,
html:not(.dark-style) .layout-menu.menu-vertical:not(.bg-menu-theme) .app-brand .sidebar-user-name {
  color: #566a7f;
  text-shadow: none;
}

.app-brand .layout-menu-toggle.app-brand-menu-toggle {
  position: absolute;
  top: 50%;
  left: -0.75rem !important;
  right: auto !important;
  width: 1.5rem;
  height: 1.5rem;
  min-width: 1.5rem;
  border-radius: 50%;
  transform: translateY(-50%);
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  color: #fff !important;
  background: #696cff;
  box-shadow: 0 0.125rem 0.375rem rgba(105, 108, 255, 0.35);
  z-index: 20;
  cursor: pointer;
  pointer-events: auto;
}

.app-brand .layout-menu-toggle.app-brand-menu-toggle i {
  font-size: 1rem;
  transition: transform 0.2s ease;
}

html.layout-menu-collapsed .app-brand .layout-menu-toggle.app-brand-menu-toggle {
  display: inline-flex !important;
}

html.layout-menu-collapsed .app-brand .layout-menu-toggle.app-brand-menu-toggle i {
  transform: rotate(180deg);
}

.app-brand .sidebar-brand-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  overflow: visible;
}

.app-brand .sidebar-brand-logo-img {
  display: block;
  max-height: 44px;
  max-width: 168px;
  width: auto;
  height: auto;
  object-fit: contain;
}

html[dir="rtl"] .menu-vertical .menu-sub .menu-link {
  padding-right: 3rem;
  padding-left: 1rem;
}

html[dir="rtl"] .menu-vertical .menu-sub .menu-sub .menu-link {
  padding-right: 3.65rem;
  padding-left: 1rem;
}

html[dir="rtl"] .menu-vertical .menu-sub .menu-sub .menu-sub .menu-link {
  padding-right: 4.3rem;
  padding-left: 1rem;
}

html[dir="rtl"] .menu-vertical .menu-item .menu-toggle {
  padding-right: 1rem;
  padding-left: calc(1rem + 1.26em);
}

html[dir="rtl"] .menu-vertical .menu-item .menu-toggle::after {
  right: auto;
  left: 1rem;
  transform: translateY(-50%) rotate(225deg);
}

html[dir="rtl"] .menu-vertical .menu-item.open:not(.menu-item-closing) > .menu-toggle::after {
  transform: translateY(-50%) rotate(135deg);
}

html[dir="rtl"] .bg-menu-theme .menu-sub > .menu-item > .menu-link:before {
  left: auto;
  right: 1.4375rem;
}

html[dir="rtl"] .bg-menu-theme .menu-sub > .menu-item.active > .menu-link:not(.menu-toggle):before {
  left: auto;
  right: 1.1875rem;
}

.main-header-workspace {
  min-width: 0;
}

/* Select2 في شريط الهيدر: أوضح + محاذاة أفضل مع theme bootstrap-5 */
#layout-navbar .main-header-workspace .select2-container {
  min-width: 260px;
  max-width: 320px;
}

#layout-navbar .main-header-workspace .select2-container--bootstrap-5 .select2-selection,
#layout-navbar .main-header-workspace .select2-container--default .select2-selection--single {
  min-height: 42px;
  border-radius: 0.375rem;
  border: 1px solid #d9dee3;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #566a7f;
  box-shadow: 0 0.0625rem 0.125rem rgba(67, 89, 113, 0.08);
}

#layout-navbar .main-header-workspace .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered,
#layout-navbar .main-header-workspace .select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 2.5rem;
  padding-top: 0.125rem;
  padding-bottom: 0.125rem;
}

html[dir="rtl"] #layout-navbar .main-header-workspace .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered,
html[dir="rtl"] #layout-navbar .main-header-workspace .select2-container--default .select2-selection--single .select2-selection__rendered {
  padding-right: 0.85rem;
  padding-left: 2.25rem;
}

#layout-navbar .main-header-workspace .select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow,
#layout-navbar .main-header-workspace .select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 2.5rem;
}

#layout-navbar .main-header-workspace .select2-dropdown {
  z-index: 2005;
  border-radius: 0.375rem;
  border: 1px solid rgba(67, 89, 113, 0.14);
  box-shadow: 0 0.35rem 1rem rgba(67, 89, 113, 0.16);
}

.select2-dropdown.ws-header-select2-dropdown .select2-results__option {
  font-size: 0.9375rem;
  padding: 0.55rem 0.85rem;
  line-height: 1.35;
}

.select2-dropdown.ws-header-select2-dropdown .select2-results__option--highlighted {
  font-weight: 600;
}

.select2-dropdown.ws-header-select2-dropdown .select2-search--dropdown .select2-search__field {
  font-size: 0.9375rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid #d9dee3;
}

.select2-container--default .select2-selection--single {
  min-height: 38px;
  border-color: #d9dee3;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 36px;
  padding-right: 0.75rem;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 36px;
}

/* Bootstrap 4 compatibility classes used by current auth views */
.btn-block {
  display: block;
  width: 100%;
}

/* Bootstrap 4 form grid compatibility for report pages */
.form-row {
  display: flex;
  flex-wrap: wrap;
  margin-left: -0.5rem;
  margin-right: -0.5rem;
}

.form-row > [class*="col-"] {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.custom-control {
  position: relative;
  display: block;
  min-height: 1.5rem;
  padding-right: 1.5rem;
}

.custom-control-input {
  position: absolute;
  right: 0;
  z-index: 1;
  width: 1rem;
  height: 1.25rem;
  opacity: 0;
}

.custom-control-label::before,
.custom-control-label::after {
  position: absolute;
  top: 0.2rem;
  right: -1.5rem;
  display: block;
  width: 1rem;
  height: 1rem;
  content: "";
  pointer-events: none;
}

.custom-control-label::before {
  border: 1px solid #c7cdd4;
  border-radius: 0.25rem;
  background-color: #fff;
}

.custom-control-input:checked ~ .custom-control-label::before {
  border-color: #696cff;
  background-color: #696cff;
}

.custom-control-input:checked ~ .custom-control-label::after {
  background: center/70% 70% no-repeat;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23fff' d='M6.564 1.146 3.27 5.2 1.43 3.36 0 4.79l3.06 3.06L8 2.575z'/%3e%3c/svg%3e");
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f5f5f9;
}

.login-box {
  width: 420px;
  max-width: calc(100% - 2rem);
}

.auth-logo-wrap {
  text-align: center;
  margin-bottom: 1rem;
}

.auth-logo-img {
  display: inline-block;
  width: 220px;
  max-width: 85%;
  height: auto;
  object-fit: contain;
}

@media (max-width: 1199.98px) {
  html[dir="rtl"] .layout-page,
  html[dir="rtl"] .layout-menu-collapsed .layout-page {
    padding-right: 0;
  }

  html[dir="rtl"] .layout-menu {
    right: -16.25rem !important;
  }

  html[dir="rtl"] .layout-menu-expanded .layout-menu {
    right: 0 !important;
  }

  .main-header-workspace {
    min-width: 220px;
  }
}
