.mobile-sidebar-flyout {
  position: fixed;
  z-index: 1034;
  display: none;
  pointer-events: none;
}

.mobile-sidebar-flyout.is-visible {
  display: block;
  pointer-events: auto;
}

.mobile-sidebar-flyout-surface {
  width: 100%;
  max-height: inherit;
  border-radius: 18px;
}

.mobile-sidebar-flyout-body {
  width: 100%;
  max-height: inherit;
}

.mobile-sidebar-flyout .bg-white {
  background-color: transparent !important;
}

.mobile-sidebar-flyout .collapse-inner {
  display: block !important;
  margin: 0 !important;
  padding: 0.55rem !important;
  border-radius: 18px !important;
  background: rgba(255, 255, 255, 0.98) !important;
  border: 2px solid rgba(233, 110, 28, 0.82);
  box-shadow: 0 18px 34px rgba(13, 25, 64, 0.24);
  max-height: inherit;
  overflow-y: auto;
}

.mobile-sidebar-flyout .collapse-header {
  padding: 0.8rem 0.95rem !important;
  margin-bottom: 0 !important;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.84rem !important;
  font-weight: 700;
  line-height: 1.25;
  color: #24324b !important;
  text-transform: uppercase;
  letter-spacing: 0.015em;
  background: rgba(78, 115, 223, 0.08);
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  cursor: pointer;
}

.mobile-sidebar-flyout .collapse-header + .collapse {
  border-top: 0 !important;
  display: none !important;
}

.mobile-sidebar-flyout .collapse-header.mobile-nested-open {
  background: rgba(78, 115, 223, 0.14);
  color: #18263f !important;
}

.mobile-sidebar-flyout .collapse-header i {
  color: inherit !important;
}

.mobile-sidebar-flyout .collapse-header.mobile-nested-open + .collapse {
  display: block !important;
}

.mobile-sidebar-flyout .collapse-inner > .collapse {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  width: auto !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0.22rem 0 0.5rem !important;
  padding: 0 !important;
  overflow: visible !important;
  z-index: auto !important;
  border-radius: 14px;
  background: rgba(37, 99, 235, 0.05);
}

.mobile-sidebar-flyout .collapse-item {
  display: block;
  padding: 0.72rem 0.9rem !important;
  border-radius: 10px;
  font-size: 0.92rem !important;
  line-height: 1.35;
  color: #30466a !important;
}

.mobile-sidebar-flyout .collapse-item:hover,
.mobile-sidebar-flyout .collapse-item:focus {
  background: rgba(48, 84, 196, 0.08) !important;
  color: #24324b !important;
  transform: none !important;
}

body.dark-mode .mobile-sidebar-flyout .collapse-inner {
  background: linear-gradient(180deg, #1a2130 0%, #171d2a 100%) !important;
  border-color: rgba(233, 110, 28, 0.72);
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.38);
}

body.dark-mode .mobile-sidebar-flyout .collapse-header,
body.dark-mode .mobile-sidebar-flyout .collapse-item {
  color: #f0f2ff !important;
}

body.dark-mode .mobile-sidebar-flyout .collapse-header {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

body.dark-mode .mobile-sidebar-flyout .collapse-header.mobile-nested-open {
  background: rgba(78, 115, 223, 0.2);
  border-color: rgba(78, 115, 223, 0.28);
  color: #ffffff !important;
}

body.dark-mode .mobile-sidebar-flyout .collapse-inner > .collapse {
  background: rgba(8, 12, 20, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

body.dark-mode .mobile-sidebar-flyout .collapse-item {
  color: #d8def3 !important;
}

body.dark-mode .mobile-sidebar-flyout .collapse-item:hover,
body.dark-mode .mobile-sidebar-flyout .collapse-item:focus {
  background: rgba(78, 115, 223, 0.18) !important;
  color: #fff !important;
}

@media (min-width: 769px) {
  .mobile-top-bar {
    display: none;
  }

  .sidebar-backdrop {
    display: none !important;
  }

  .mobile-sidebar-flyout {
    top: 12px;
    left: calc(6.5rem + 12px);
    width: min(320px, calc(100vw - 8.5rem));
    max-width: 320px;
    max-height: calc(100vh - 24px);
    z-index: 1040;
  }

  .sidebar.toggled > .nav-item > .collapse {
    display: none !important;
  }

  .sidebar.toggled .nav-item.mobile-flyout-active .nav-link,
  .sidebar.toggled .nav-item .nav-link:hover,
  .sidebar.toggled .nav-item .nav-link:focus {
    background: rgba(255, 255, 255, 0.14) !important;
    transform: none !important;
  }

  .sidebar.toggled .nav-item.mobile-flyout-active .nav-link i,
  .sidebar.toggled .nav-item .nav-link:hover i,
  .sidebar.toggled .nav-item .nav-link:focus i {
    color: #fff !important;
  }
}

@media (max-width: 768px) {
  body.sidebar-open {
    overflow: hidden;
  }

  .mobile-top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    background: linear-gradient(45deg, #4e73df, #4a4ac7);
    border-bottom: 2px solid #e96e1c;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1032;
  }

  .mobile-logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    height: 40px;
    width: auto;
  }

  .mobile-logo img {
    height: 100%;
    width: auto;
  }

  #sidebarBurger,
  .mobile-user-profile {
    position: relative;
    z-index: 2;
  }

  #sidebarBurger {
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 1px solid #e96e1c !important;
    background: rgba(255, 255, 255, 0.9) !important;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #sidebarBurger i {
    font-size: 1rem;
    color: #4e73df;
  }

  .mobile-user-profile {
    width: 32px;
    height: 32px;
    padding: 1px;
    border-radius: 50%;
    border: 2px solid #e96e1c;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }

  .mobile-user-profile img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
  }

  .mobile-user-profile .status-indicator {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 6px;
    height: 6px;
    background: #1cc88a;
    border: 1px solid #fff;
    border-radius: 50%;
  }

  .dropdown-menu.mobile-dropdown {
    position: fixed !important;
    top: 50px !important;
    right: 10px !important;
    left: auto !important;
    margin: 0 !important;
    min-width: 220px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    transform: none !important;
  }

  .dropdown-menu.mobile-dropdown::before {
    content: "";
    position: absolute;
    top: -8px;
    right: 10px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #fff;
  }

  body.dark-mode .dropdown-menu.mobile-dropdown::before {
    border-bottom-color: var(--tb-bg-subtle);
  }

  .dropdown-menu.mobile-dropdown .dropdown-item {
    white-space: normal;
    word-break: break-word;
  }

  .topbar {
    display: none !important;
  }

  #wrapper,
  #content-wrapper,
  body.sidebar-toggled #wrapper {
    padding-left: 0 !important;
    margin-left: 0 !important;
  }

  #content-wrapper {
    padding-top: 50px !important;
    transition: none !important;
  }

  .sidebar {
    position: fixed !important;
    top: 50px;
    left: 0;
    width: 104px !important;
    min-width: 104px !important;
    max-width: 104px !important;
    height: calc(100dvh - 50px);
    transform: translateX(-100%);
    transition: transform 0.24s ease, box-shadow 0.24s ease;
    overflow-y: auto !important;
    overflow-x: visible !important;
    z-index: 1031 !important;
    border-right: 1px solid rgba(233, 110, 28, 0.7);
    background: linear-gradient(45deg, #4e73df, #4a4ac7) !important;
    -webkit-overflow-scrolling: touch;
    box-shadow: none;
    padding-top: 0.35rem;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 14px 0 34px rgba(0, 0, 0, 0.24);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    z-index: 1030;
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .sidebar-toggle-container,
  .sidebar-desktop-brand,
  .mobile-sidebar-header,
  .scroll-to-top {
    display: none !important;
  }

  .sidebar .sidebar-divider {
    margin: 0.3rem 0.75rem !important;
    border-top-color: rgba(255, 255, 255, 0.14);
  }

  .sidebar > .sidebar-divider.my-0 {
    display: none !important;
  }

  .sidebar .nav-item {
    position: relative;
    display: flex;
    justify-content: center;
    padding: 0 0.3rem !important;
  }

  .sidebar .nav-item .nav-link {
    width: 100%;
    max-width: 100%;
    min-height: 72px;
    padding: 0.8rem 0.2rem 0.72rem !important;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.42rem;
    color: rgba(255, 255, 255, 0.92) !important;
    font-weight: 600;
    text-align: center;
  }

  .sidebar .nav-item .nav-link i {
    width: auto;
    text-align: center;
    font-size: 1.15rem !important;
    margin: 0 !important;
    color: rgba(255, 255, 255, 0.82) !important;
  }

  .sidebar .nav-item.active .nav-link,
  .sidebar .nav-item.mobile-flyout-active .nav-link,
  .sidebar .nav-item .nav-link:hover,
  .sidebar .nav-item .nav-link:focus {
    background: rgba(255, 255, 255, 0.14) !important;
    transform: none !important;
  }

  .sidebar .nav-item.active .nav-link i,
  .sidebar .nav-item.mobile-flyout-active .nav-link i,
  .sidebar .nav-item .nav-link:hover i,
  .sidebar .nav-item .nav-link:focus i {
    color: #fff !important;
  }

  .sidebar .nav-item .nav-link span {
    display: block !important;
    width: 100% !important;
    max-width: 78px;
    margin: 0 !important;
    min-width: 0;
    font-size: 0.64rem !important;
    line-height: 1.2;
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: break-word;
    opacity: 1 !important;
  }

  .sidebar.toggled,
  .sidebar.toggled .nav-item .nav-link {
    width: auto !important;
  }

  .sidebar.toggled .nav-item .nav-link span {
    display: block !important;
  }

  .sidebar .nav-item .nav-link[data-toggle="collapse"]::after,
  .sidebar.toggled .nav-item .nav-link[data-toggle="collapse"]::after {
    display: none !important;
  }

  .sidebar > .nav-item > .collapse {
    display: none !important;
  }

  .mobile-sidebar-flyout {
    top: 58px;
    left: 114px;
    width: min(calc(100vw - 126px), 292px);
    max-width: 292px;
    max-height: calc(100dvh - 74px);
  }
}
