/* Enhanced Sidebar Styles */

/* Ensure the sidebar nav is a flex container for better layout control */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  height: 100vh; /* Full viewport height */
  flex-shrink: 0; /* Prevent shrinking in flex layout */
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* Custom scrollbar for webkit */
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  color: #ccc; /* Default text color */

  /* Default Width on Desktop (Expanded) */
  width: 220px;
  transition:
    width 0.2s ease-out,
    transform 0.3s ease-in-out;
  z-index: 1000;
}

/* Collapsed Width on Desktop */
.sidebar-nav.collapsed {
  width: 60px;
}

/* Mobile Styles */
@media (max-width: 768px) {
  .sidebar-nav {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 250px !important; /* Fixed width for mobile menu */
    transform: translateX(-100%); /* Hidden by default */
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
  }

  .sidebar-nav.mobile-open {
    transform: translateX(0); /* Show when open */
  }

  /* Hamburger Menu Button (in Layout) */
  .mobile-menu-toggle {
    display: block; /* Visible on mobile */
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 900; /* Below sidebar (1000) */
    background: var(--button-background-color, #333);
    border: 1px solid var(--border-color, #555);
    color: #fff;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
  }

  /* Close Button (in Sidebar) */
  .sidebar-close-btn {
    display: flex !important; /* Show on mobile */
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #ccc;
    cursor: pointer;
    padding: 10px;
    position: absolute;
    top: 10px;
    right: 10px;
  }
}

/* Desktop: Hide Mobile specific elements */
@media (min-width: 769px) {
  .mobile-menu-toggle {
    display: none;
  }
  .sidebar-close-btn {
    display: none !important;
  }
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 3px;
}

/* Nav Links - Global styling for sidebar links */
.sidebar-nav a.nav-link,
.sidebar-nav button.nav-link {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  color: #ccc; /* Ensure text is not blue */
  text-decoration: none; /* Remove underline */
  border-radius: 4px;
  margin: 2px 10px;
  transition:
    background-color 0.2s,
    color 0.2s;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav a.nav-link:hover,
.sidebar-nav button.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
}

.sidebar-nav a.nav-link.active {
  background-color: var(
    --primary-color,
    #4caf50
  ); /* Use theme primary or fallback */
  color: #fff;
}

.sidebar-nav a.nav-link.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: transparent !important;
  color: #888 !important;
}

/* Nav Item Container - Center icons when collapsed */
.sidebar-nav.collapsed .nav-link {
  justify-content: center !important;
  padding: 10px 0; /* Adjust padding for collapsed state */
  margin: 5px; /* Tighter margins */
}

/* Tooltip behavior for collapsed sidebar */
.sidebar-nav.collapsed .nav-link[title]:hover::after {
  /* Optional: CSS-only tooltip if not using title attribute directly */
  /* content: attr(title); */
  /* Implementation depends on preference, browser title usually sufficient */
}

/* Icon centering */
.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px; /* Fixed width for alignment */
  margin-right: 10px;
}

.sidebar-nav.collapsed .nav-icon {
  margin-right: 0;
}

/* Fix blank space by ensuring nav groups take appropriate space */
.nav-group {
  /* No extra margin by default */
  display: flex;
  flex-direction: column;
}

.nav-section-label {
  padding: 10px 25px 5px;
  font-size: 0.75em;
  text-transform: uppercase;
  color: #666;
  font-weight: bold;
  letter-spacing: 0.5px;
}

/* Separator styling */
.nav-separator {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 10px 15px;
}

/* Footer Nav pushed to bottom if needed */
.footer-nav {
  margin-top: auto !important;
  padding-bottom: 20px;
}

/* Ensure separators look good in collapsed mode */
.sidebar-nav.collapsed .nav-separator {
  margin: 10px 5px;
}

/* Customizeable Background handling via inline styles in component,
   but defaults can be improved here */
:root {
  --sidebar-bg-custom: var(--sidebar-background-color);
}

.sidebar-nav {
  background-color: var(--sidebar-bg-custom);
  /* Improve contrast if needed, or rely on ThemeContext */
  backdrop-filter: blur(5px); /* Modern touch if background has transparency */
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

/* Sidebar Label Scrolling Support */
.nav-label-wrapper {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0; /* Important for flex containers to allow shrinking */
  display: block;
}

.nav-label-text {
  display: inline-block;
  transition: transform 0.5s ease-out; /* Smooth reset */
  will-change: transform;
}

/* Keyframes for scrolling animation */
@keyframes scroll-text {
  0%,
  15% {
    transform: translateX(0);
  }
  50%,
  65% {
    transform: translateX(var(--scroll-distance));
  }
  100% {
    transform: translateX(0);
  }
}

/* On hover of the link, if overflowing */
.sidebar-nav .nav-link:hover .nav-label-wrapper.overflowing {
  text-overflow: clip; /* Remove dots so we can see the text scrolling */
}

.sidebar-nav .nav-link:hover .nav-label-wrapper.overflowing .nav-label-text {
  /* Use a fixed duration for now. */
  animation: scroll-text 6s ease-in-out infinite;
}
