/* Modern Cyber Sidebar Styles */
:root {
  --sidebar-bg: #0a1929;
  --sidebar-hover: #1e3a5f;
  --sidebar-active: #2d6bdb;
  --sidebar-text: #e0e7ff;
  --sidebar-icon: #64b5f6;
  --cyber-glow: 0 0 10px rgba(77, 208, 225, 0.4);
  --sidebar-width: 280px;
  /* Increased width for better grouping */
  --group-bg: rgba(0, 0, 0, 0.15);
  --group-hover: rgba(45, 107, 219, 0.1);
  --group-active: rgba(45, 107, 219, 0.2);
}

/* Container styles */
.container-scroller {
  position: relative;
  width: 100%;
  overflow-x: hidden;
}

.page-body-wrapper {
  min-height: calc(100vh - 70px);
  display: flex;
  width: 100%;
  position: relative;
}

/* Sidebar styles */
.sidebar {
  background: var(--sidebar-bg, #0a1929);
  background-image: linear-gradient(180deg, var(--sidebar-bg, #0a1929) 0%, var(--sidebar-secondary, var(--secondary-color, #0f2942)) 100%);
  border-right: 1px solid var(--sidebar-border, var(--border-color, rgba(66, 153, 225, 0.2)));
  transition: all 0.3s ease;
  position: fixed;
  height: 100vh;
  width: var(--sidebar-width);
  z-index: 100;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: none !important;
}

@media (max-width: 991px) {
  .sidebar {
    z-index: 1050 !important;
  }

  /* Ensure sidebar is always visible when active */
  .sidebar.active {
    transform: translateX(0) !important;
    visibility: visible !important;
    opacity: 1 !important;
    display: flex !important;
  }
}

/* Remove any unwanted shadows or overlays */
body {
  position: relative;
}

/* Remove modal backdrop shadows that might persist */
.modal-backdrop {
  display: none !important;
  opacity: 0 !important;
  z-index: -1 !important;
}

body.modal-open {
  overflow: auto !important;
  padding-right: 0 !important;
}

body.modal-open .modal-backdrop {
  display: none !important;
}

/* Remove any overlay shadows */
.overlay,
.backdrop,
.shadow-overlay {
  display: none !important;
}

/* Main content area */
.main-panel {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  min-height: calc(100vh - 70px);
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  flex-direction: column;
}

.content-wrapper {
  padding: 2rem 1.5rem;
  width: 100%;
  flex-grow: 1;
}

.sidebar .nav {
  padding-top: 0.5rem;
}

.sidebar .nav .nav-item {
  padding: 0.3rem 1rem;
  margin-bottom: 0.3rem;
}

.sidebar .nav .nav-item .nav-link {
  display: flex;
  align-items: center;
  color: var(--sidebar-text, #e0e7ff);
  padding: 0.8rem 1rem;
  border-radius: 8px;
  transition: all 0.3s ease;
  position: relative;
  overflow: visible;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color, rgba(66, 153, 225, 0.1));
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.sidebar .nav .nav-item .nav-link:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: transparent;
  transition: all 0.3s ease;
}

.sidebar .nav .nav-item .nav-link:hover {
  background: var(--sidebar-hover, #1e3a5f);
  box-shadow: var(--cyber-glow, 0 0 10px rgba(77, 208, 225, 0.4));
  transform: translateY(-2px);
}

.sidebar .nav .nav-item .nav-link:hover:before {
  background: var(--sidebar-icon, #64b5f6);
}

.sidebar .nav .nav-item.active .nav-link {
  background: var(--sidebar-active, #2d6bdb);
  box-shadow: var(--cyber-glow, 0 0 10px rgba(77, 208, 225, 0.4));
}

.sidebar .nav .nav-item.active .nav-link:before {
  background: var(--sidebar-icon, #ffffff);
}

.sidebar .nav .nav-item .nav-link i {
  color: var(--sidebar-icon, #64b5f6);
  font-size: 1.1rem;
  transition: all 0.3s;
  flex-shrink: 0;
  min-width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar .nav .nav-item .nav-link .menu-title {
  font-size: 0.9rem;
  transition: all 0.3s;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .nav .nav-item.active .nav-link i,
.sidebar .nav .nav-item.active .nav-link .menu-title {
  color: white;
}

/* Collapsed sidebar styles - Mobile */
@media (max-width: 991px) {

  /* Hide sidebar by default on mobile */
  .sidebar,
  .sidebar-offcanvas {
    position: fixed !important;
    height: 100vh !important;
    top: 0 !important;
    left: -280px !important;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    width: 280px !important;
    z-index: 1050 !important;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.6) !important;
    display: flex !important;
    flex-direction: column !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: translateX(0) !important;
  }

  /* Show sidebar when active */
  .sidebar.active,
  .sidebar-offcanvas.active,
  #sidebar.active {
    left: 0 !important;
    transform: translateX(0) !important;
    z-index: 1050 !important;
    visibility: visible !important;
    opacity: 1 !important;
    display: flex !important;
  }

  /* Ensure sidebar content is visible */
  .sidebar.active .sidebar-menu,
  .sidebar.active .sidebar-brand-wrapper {
    visibility: visible !important;
    opacity: 1 !important;
  }

  .main-panel {
    margin-left: 0 !important;
    width: 100% !important;
  }
}

/* Cyber badge for notifications */
.cyber-badge {
  position: absolute;
  right: 10px;
  top: 10px;
  background: #ff1744;
  color: white;
  border-radius: 50%;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  box-shadow: 0 0 10px rgba(255, 23, 68, 0.6);
}

/* Divider */
.sidebar-divider {
  border-top: 1px solid rgba(66, 153, 225, 0.2);
  margin: 1rem 1.5rem;
  position: relative;
}

.sidebar-divider::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  width: 30px;
  height: 1px;
  background: linear-gradient(90deg, var(--sidebar-icon), transparent);
}

/* Section title */
.sidebar-heading {
  color: var(--sidebar-icon);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 0.75rem 1.5rem 0.5rem;
  opacity: 0.9;
  font-weight: 600;
  position: relative;
}

.sidebar-heading::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 1.5rem;
  right: 1.5rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(66, 153, 225, 0.3), transparent);
}

/* Logo container */
.sidebar-brand-wrapper {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(66, 153, 225, 0.2);
  padding: 0 1.5rem;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

/* Close button in sidebar for mobile */
.sidebar-close-btn {
  display: none;
  background: rgba(100, 181, 246, 0.1);
  border: 1px solid rgba(100, 181, 246, 0.3);
  border-radius: 8px;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
  margin-left: auto;
  min-width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-close-btn:hover {
  background: rgba(100, 181, 246, 0.2);
  border-color: rgba(100, 181, 246, 0.5);
  box-shadow: 0 0 10px rgba(100, 181, 246, 0.3);
  transform: scale(1.1);
}

.sidebar-close-btn:active {
  transform: scale(0.95);
}

@media (max-width: 991px) {
  .sidebar-close-btn {
    display: flex !important;
  }
}

@media (min-width: 992px) {
  .sidebar-close-btn {
    display: none !important;
  }
}

.sidebar-brand-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(66, 153, 225, 0.1), transparent);
  transition: left 0.5s ease;
}

.sidebar-brand-wrapper:hover::before {
  left: 100%;
}

.sidebar-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  text-decoration: none;
  transition: all 0.3s ease;
  flex-wrap: nowrap;
}

.sidebar-brand:hover {
  transform: translateX(3px);
}

.sidebar-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  background: rgba(66, 153, 225, 0.1);
  border-radius: 12px;
  border: 1px solid rgba(66, 153, 225, 0.2);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

/* Hide brand icon if no logo */
.sidebar-brand:not(:has(.sidebar-brand-icon)) .sidebar-brand-text {
  margin-left: 0;
}

.sidebar-brand:hover .sidebar-brand-icon {
  background: rgba(66, 153, 225, 0.2);
  border-color: rgba(66, 153, 225, 0.4);
  box-shadow: 0 0 15px rgba(66, 153, 225, 0.3);
}

.sidebar-brand-icon::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle, rgba(100, 181, 246, 0.3), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-brand:hover .sidebar-brand-icon::before {
  opacity: 1;
}

.sidebar-brand-logo {
  max-height: 32px;
  max-width: 32px;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  position: relative;
  z-index: 1;
  transition: transform 0.3s ease;
  display: block;
}

.sidebar-brand:hover .sidebar-brand-logo {
  transform: scale(1.1);
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--sidebar-icon, #64b5f6);
  text-shadow: 0 0 10px var(--accent-color, rgba(100, 181, 246, 0.5));
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
  white-space: nowrap;
  line-height: 1.2;
  display: block;
}

.sidebar-brand:hover .brand-title {
  color: #ffffff;
  text-shadow: 0 0 15px rgba(100, 181, 246, 0.8);
}

/* Hover animation for icons */
.sidebar .nav .nav-item .nav-link:hover i {
  transform: translateY(-2px);
}

/* Modern scrollbar */
.sidebar::-webkit-scrollbar {
  width: 5px;
}

.sidebar::-webkit-scrollbar-track {
  background: var(--sidebar-bg);
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--sidebar-hover);
  border-radius: 5px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--sidebar-active);
}

/* Sidebar Menu Container */
.sidebar-menu {
  padding: 1rem 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  /* Important for flex scrolling */
}

/* Menu Groups */
.menu-group {
  margin-bottom: 0.5rem;
  padding: 0 0.75rem;
}

.menu-group-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--sidebar-text);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s ease;
  background: var(--group-bg);
  border: 1px solid rgba(66, 153, 225, 0.1);
  margin-bottom: 0.25rem;
  position: relative;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.menu-group-header:hover {
  background: var(--group-hover);
  border-color: rgba(66, 153, 225, 0.3);
  transform: translateX(3px);
}

.menu-group-header[aria-expanded="true"] {
  background: var(--group-active);
  border-color: rgba(66, 153, 225, 0.4);
  box-shadow: 0 0 10px rgba(66, 153, 225, 0.2);
}

.group-icon {
  color: var(--sidebar-icon);
  font-size: 1.15rem;
  transition: all 0.3s ease;
  opacity: 0.9;
  flex-shrink: 0;
  min-width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.menu-group-header:hover .group-icon {
  opacity: 1;
  transform: scale(1.1);
}

.menu-group-header[aria-expanded="true"] .group-icon {
  opacity: 1;
  color: #ffffff;
}

.group-title {
  flex: 1;
  color: var(--sidebar-icon);
  text-shadow: 0 0 8px rgba(100, 181, 246, 0.3);
  transition: all 0.3s ease;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-group-header:hover .group-title {
  color: #ffffff;
  text-shadow: 0 0 12px rgba(100, 181, 246, 0.6);
}

.menu-group-header[aria-expanded="true"] .group-title {
  color: #ffffff;
  text-shadow: 0 0 12px rgba(100, 181, 246, 0.6);
}

.group-arrow {
  color: var(--sidebar-icon);
  font-size: 1rem;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.8;
  flex-shrink: 0;
  min-width: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.menu-group-header[aria-expanded="true"] .group-arrow {
  transform: rotate(180deg);
  opacity: 1;
}

/* Sub-menu (Collapsible content) */
.sub-menu {
  padding-left: 0.5rem;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
  border-left: 2px solid rgba(66, 153, 225, 0.2);
  margin-left: 1.5rem;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.sub-menu .nav-item {
  padding: 0.25rem 0;
  margin-bottom: 0.15rem;
}

.sub-menu .nav-item .nav-link {
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(66, 153, 225, 0.05);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
}

.sub-menu .nav-item .nav-link:before {
  width: 2px;
  left: 1.5rem;
}

.sub-menu .nav-item .nav-link:hover {
  background: var(--sidebar-hover);
  border-color: rgba(66, 153, 225, 0.2);
  transform: translateX(3px);
}

.sub-menu .nav-item.active .nav-link {
  background: var(--sidebar-active);
  border-color: rgba(66, 153, 225, 0.3);
  box-shadow: 0 0 8px rgba(66, 153, 225, 0.3);
}

.sub-menu .nav-item .nav-link {
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.sub-menu .nav-item .nav-link i {
  position: static;
  left: auto;
  font-size: 1rem;
  transition: all 0.3s ease;
  flex-shrink: 0;
  min-width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0;
}

.sub-menu .nav-item .nav-link:hover i {
  transform: translateY(-2px);
  color: #ffffff;
}

.sub-menu .nav-item .nav-link .menu-title {
  margin-left: 0;
  transition: color 0.3s ease;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub-menu .nav-item.active .nav-link .menu-title,
.sub-menu .nav-item.active .nav-link i {
  color: #ffffff;
}

/* Menu Badge for notifications */
.menu-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  background: linear-gradient(135deg, #ff1744 0%, #e53935 100%);
  color: white;
  border-radius: 11px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: auto;
  margin-right: 0.5rem;
  box-shadow: 0 0 10px rgba(255, 23, 68, 0.6);
  animation: pulse 2s infinite;
  position: relative;
  z-index: 1;
}

@keyframes pulse {

  0%,
  100% {
    box-shadow: 0 0 8px rgba(255, 23, 68, 0.5);
  }

  50% {
    box-shadow: 0 0 12px rgba(255, 23, 68, 0.8);
  }
}

/* Logout item special styling in sub-menu */
.sub-menu .nav-item:last-child .nav-link {
  border-top: 1px solid rgba(66, 153, 225, 0.2);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
}

.sub-menu .nav-item:last-child .nav-link:hover {
  background: rgba(244, 67, 54, 0.15);
  border-color: rgba(244, 67, 54, 0.3);
}

.sub-menu .nav-item:last-child .nav-link:hover i,
.sub-menu .nav-item:last-child .nav-link:hover .menu-title {
  color: #ef5350;
}

/* Improved active state for grouped items */
.menu-group .nav-item.active .nav-link {
  background: var(--sidebar-active);
  box-shadow: var(--cyber-glow);
  border-color: rgba(66, 153, 225, 0.4);
}

.menu-group .nav-item.active .nav-link:before {
  background: #ffffff;
  width: 3px;
}

/* Smooth collapse animation */
.collapse {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.collapsing {
  transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* Add subtle animation when group expands */
.collapse.show {
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive adjustments */
@media (max-width: 991px) {
  :root {
    --sidebar-width: 280px;
  }

  .sidebar {
    z-index: 1000;
  }

  .sidebar-offcanvas {
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  }
}

/* Enhanced scrollbar for menu */
.sidebar-menu::-webkit-scrollbar {
  width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
  background: rgba(66, 153, 225, 0.3);
  border-radius: 3px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(66, 153, 225, 0.5);
}

/* Standalone menu items (not in groups) */
.menu-group>.nav>.nav-item {
  padding: 0.25rem 0;
  margin-bottom: 0.15rem;
}

.menu-group>.nav>.nav-item .nav-link {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(66, 153, 225, 0.1);
  transition: all 0.3s ease;
}

.menu-group>.nav>.nav-item .nav-link:hover {
  background: var(--sidebar-hover);
  border-color: rgba(66, 153, 225, 0.3);
  transform: translateX(3px);
}

.menu-group>.nav>.nav-item.active .nav-link {
  background: var(--sidebar-active);
  border-color: rgba(66, 153, 225, 0.4);
  box-shadow: var(--cyber-glow);
}

.menu-group>.nav>.nav-item.active .nav-link i,
.menu-group>.nav>.nav-item.active .nav-link .menu-title {
  color: #ffffff;
}