/**
 * Consolidated Layout Fix
 * This file combines all previous gap-fixing CSS into a single optimized solution
 * Prioritized using specificity to ensure proper override
 */

/* Base Layout Fixes */

/* Ensure sidebar has proper width and appearance */
#accordionSidebar {
  width: 14rem !important;
  min-height: 100vh !important;
  transition: width 0.3s ease, transform 0.3s ease !important;
  margin: 0 !important;
  padding: 0 !important;
  box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15) !important;
}

/* Ensure content wrapper aligns perfectly with sidebar */
#content-wrapper {
  margin-left: 14rem !important;
  width: calc(100% - 14rem) !important;
  transition: margin-left 0.3s ease, width 0.3s ease !important;
  min-height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Fix for toggled sidebar state */
body.sidebar-toggled #accordionSidebar {
  width: 6.5rem !important;
}

body.sidebar-toggled #content-wrapper {
  margin-left: 6.5rem !important;
  width: calc(100% - 6.5rem) !important;
}

/* Eliminate vertical gaps */
.topbar {
  height: 4.375rem !important;
  margin: 0 !important;
  padding: 0 !important;
}

.container-fluid {
  padding: 1.5rem !important;
  margin: 0 !important;
}

/* Ensure proper stacking and layout */
#wrapper {
  display: flex !important;
  width: 100% !important;
  overflow: hidden !important;
}

#content {
  flex: 1 0 auto !important;
  width: 100% !important;
}

/* Mobile-specific fixes */
@media (max-width: 767.98px) {
  #accordionSidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 280px !important;
    height: 100vh !important;
    z-index: 1030 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1) !important;
  }
  
  #content-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    transition: margin-left 0.3s ease-in-out !important;
  }
  
  body.sidebar-toggled #accordionSidebar {
    transform: translateX(0) !important;
    width: 280px !important;
  }
  
  body.sidebar-toggled #content-wrapper {
    margin-left: 0 !important;
  }
  
  /* Mobile menu overlay */
  #mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1025;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  /* Topbar adjustments for mobile */
  .topbar {
    height: 4rem !important;
    padding: 0 !important;
  }
  
  /* Container adjustments for mobile */
  .container-fluid {
    padding: 1rem !important;
    margin-top: 0 !important;
  }
}

/* Animation for collapsible items */
.sidebar .nav-item .collapse {
  animation: collapseIn 0.3s ease-out;
}

@keyframes collapseIn {
  0% {
    opacity: 0;
    transform: scaleY(0);
  }
  100% {
    opacity: 1;
    transform: scaleY(1);
  }
}

/* Dark mode specific adjustments */
body.dark-theme #accordionSidebar {
  background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%) !important;
}

body.dark-theme .container-fluid {
  background-color: #171923 !important;
}

/* Specific fix for any remaining gaps */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* Prevent any unwanted scrollbars */
#content-wrapper::-webkit-scrollbar {
  width: 0.5rem;
}

#content-wrapper::-webkit-scrollbar-track {
  background-color: transparent;
}

#content-wrapper::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}
