/* public/css/custom_sidebar.css */

.bd-sidebar {
  --bs-offcanvas-bg: var(--theme-light-sidebar-bg);
  background-color: var(--bs-offcanvas-bg);
  backdrop-filter: blur(var(--theme-glass-blur));

  border-right: 0.5px solid var(--theme-light-sidebar-border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  width: 280px;
  overflow-x: hidden;
  flex-shrink: 0;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease,
    border-color 0.3s ease, left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
}

[data-bs-theme="dark"] .bd-sidebar {
  --bs-offcanvas-bg: var(--theme-dark-sidebar-bg);
  border-right-color: var(--theme-dark-sidebar-border-color);
}

.bd-sidebar.sidebar-is-floating {
  z-index: 1020;
}

@media (min-width: 992px) {
  .bd-sidebar {
    top: 0;
    height: 100vh;
    padding-top: 60px;
    z-index: 1020;
  }
  .bd-sidebar.sidebar-expanded {
    width: 280px;
    transform: translateX(0);
  }
  .bd-sidebar.sidebar-mini {
    width: 63px;
    transform: translateX(0);
  }
  .bd-sidebar.sidebar-hidden {
    transform: translateX(-100%);
  }

  .bd-sidebar.sidebar-mini .sidebar-brand-text,
  .bd-sidebar.sidebar-mini .sidebarbutton-text,
  .bd-sidebar.sidebar-mini
    .sidebar-footer-area
    .theme-toggle-button
    .toggle-text-label,
  .bd-sidebar.sidebar-mini .sidebar-submenu .sidebarbutton-text,
  .bd-sidebar.sidebar-mini .sidebarbutton .submenu-caret {
    opacity: 0;
    width: 0;
    overflow: hidden;
    display: none !important;
  }
  .bd-sidebar.sidebar-mini #sidebarHeader {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    justify-content: center;
  }
  .bd-sidebar.sidebar-mini #sidebarHeader .navbar-brand {
    margin-right: 0 !important;
  }
  .bd-sidebar.sidebar-mini #sidebarHeader .sidebar-brand-icon {
    margin-right: 0;
  }
  .bd-sidebar.sidebar-mini .sidebarbutton button,
  .bd-sidebar.sidebar-mini .sidebarbutton > a {
    justify-content: center;
  }
  .bd-sidebar.sidebar-mini .sidebarbutton .sidebarbutton-icon {
    margin-right: 0 !important;
    font-size: 1.3rem !important;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .bd-sidebar.sidebar-mini
    .sidebarbutton:not(.SideBtnActive)
    button:hover
    .sidebarbutton-icon,
  .bd-sidebar.sidebar-mini
    .sidebarbutton:not(.SideBtnActive)
    > a:hover
    .sidebarbutton-icon {
    transform: none !important;
  }
  .bd-sidebar.sidebar-mini .sidebarbutton:not(.SideBtnActive) button:hover,
  .bd-sidebar.sidebar-mini .sidebarbutton:not(.SideBtnActive) > a:hover {
    transform: none !important;
  }
  .bd-sidebar.sidebar-mini .sidebar-footer-area .theme-toggle-button {
    justify-content: center;
  }
  .bd-sidebar.sidebar-mini .sidebar-footer-area .theme-toggle-button svg {
    margin-right: 0 !important;
  }
}

@media (max-width: 991.98px) {
  .bd-sidebar {
    width: 280px;
    transform: translateX(-100%);
    padding-top: 0;
    height: 100vh;
    z-index: 1045;
  }
  .bd-sidebar.offcanvas.show {
    transform: translateX(0);
  }
  .bd-sidebar .offcanvas-header .btn-close {
    filter: brightness(0) invert(var(--bs-dark-rgb), 1);
  }
  [data-bs-theme="dark"] .bd-sidebar .offcanvas-header .btn-close {
    filter: none;
  }
}

#sidebarHeader {
  padding: 0.75rem 1rem;
  border-bottom: 0.5px solid var(--theme-light-sidebar-border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  min-height: 50px;
  color: var(--theme-light-sidebar-header-text-color);
  transition: color 0.3s ease, border-color 0.3s ease, padding 0.3s ease-in-out;
}
[data-bs-theme="dark"] #sidebarHeader {
  border-bottom-color: var(--theme-dark-sidebar-border-color);
  color: var(--theme-dark-sidebar-header-text-color);
}
#sidebarHeader .navbar-brand {
  cursor: pointer;
  margin-right: auto;
  display: flex;
  align-items: center;
  text-decoration: none;
}
#sidebarHeader .navbar-brand:hover {
  opacity: 0.9;
}
#sidebarHeader .sidebar-brand-icon {
  color: inherit;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  margin-right: 0.75rem;
  transition: margin-right 0.3s ease-in-out;
}
#sidebarHeader .sidebar-brand-text {
  color: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transition: opacity 0.2s ease-in-out, width 0.2s ease-in-out;
}
#sidebarHeader .sidebar-brand-text .topbar-brand-highlight {
  color: var(--theme-light-primary-color);
}
[data-bs-theme="dark"]
  #sidebarHeader
  .sidebar-brand-text
  .topbar-brand-highlight {
  color: var(--theme-dark-primary-color);
}
#sidebarSizeModeToggle {
  color: var(--theme-light-sidebar-header-text-color);
  background-color: transparent;
  border: none;
  font-size: 1.4rem;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  border-radius: 0.25rem;
  transition: color 0.2s ease, background-color 0.2s ease;
}
#sidebarSizeModeToggle:hover {
  color: var(--theme-light-primary-color);
  background-color: rgba(var(--theme-light-primary-rgb), 0.1);
}
[data-bs-theme="dark"] #sidebarSizeModeToggle {
  color: var(--theme-dark-sidebar-header-text-color);
}
[data-bs-theme="dark"] #sidebarSizeModeToggle:hover {
  color: var(--theme-dark-primary-color);
  background-color: rgba(var(--theme-dark-primary-rgb), 0.1);
}

#appSidebar .offcanvas-body {
  overflow-y: auto;
  flex-grow: 1;
  padding: 0;
}
#custom-cards.vertical-list-layout {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
}
.vertical-list-layout .sidebarbutton {
  margin-bottom: 0.35rem;
  width: 100%;
  position: relative;
}

.sidebarbutton button,
.sidebarbutton > a {
  background: transparent !important;
  border: none !important;
  padding: 0.9rem 1.35rem !important;
  margin: 0 !important;
  border-radius: var(--theme-sidebar-item-border-radius) !important;
  font-size: 0.98rem !important;
  width: 100% !important;
  text-align: left !important;
  display: flex !important;
  align-items: center !important;
  color: var(--theme-light-sidebar-text-color) !important;
  box-shadow: none !important;
  position: relative;
  overflow: hidden;
  transition: color 0.25s ease-in-out;
  transform-style: preserve-3d;
  text-decoration: none;
}
[data-bs-theme="dark"] .sidebarbutton button,
[data-bs-theme="dark"] .sidebarbutton > a {
  color: var(--theme-dark-sidebar-text-color) !important;
}
.sidebarbutton .sidebarbutton-icon {
  color: var(--theme-light-sidebar-icon-color) !important;
  font-size: 1.3rem !important;
  margin-right: 1.1rem;
  flex-shrink: 0;
  transition: color 0.25s ease-in-out, transform 0.2s ease;
  opacity: 1 !important;
  z-index: 1;
}
[data-bs-theme="dark"] .sidebarbutton .sidebarbutton-icon {
  color: var(--theme-dark-sidebar-icon-color) !important;
}
.sidebarbutton .sidebarbutton-text {
  color: var(--theme-light-sidebar-text-color) !important;
  font-weight: 500 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.25s ease-in-out, opacity 0.2s ease-in-out;
  opacity: 1 !important;
  z-index: 1;
  flex-grow: 1;
}
[data-bs-theme="dark"] .sidebarbutton .sidebarbutton-text {
  color: var(--theme-dark-sidebar-text-color) !important;
}

.sidebarbutton button::before,
.sidebarbutton > a::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--theme-light-sidebar-hover-bg) 50%,
    var(--theme-light-sidebar-hover-bg) 100%
  );
  transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
  border-radius: var(--theme-sidebar-item-border-radius);
}
[data-bs-theme="dark"] .sidebarbutton button::before,
[data-bs-theme="dark"] .sidebarbutton > a::before {
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--theme-dark-sidebar-hover-bg) 50%,
    var(--theme-dark-sidebar-hover-bg) 100%
  );
}
.sidebarbutton:not(.SideBtnActive):not(.SideBtnParentActive) button:hover::before, /* Ensure hover doesn't show if parent is active */
.sidebarbutton:not(.SideBtnActive):not(.SideBtnParentActive) > a:hover::before {
  left: 0;
}
.sidebarbutton:not(.SideBtnActive):not(.SideBtnParentActive) button:hover,
.sidebarbutton:not(.SideBtnActive):not(.SideBtnParentActive) > a:hover {
  color: var(--theme-light-sidebar-hover-text-color) !important;
}
.sidebarbutton:not(.SideBtnActive):not(.SideBtnParentActive)
  button:hover
  .sidebarbutton-icon,
.sidebarbutton:not(.SideBtnActive):not(.SideBtnParentActive)
  > a:hover
  .sidebarbutton-icon {
  color: var(--theme-light-sidebar-hover-icon-color) !important;
}
[data-bs-theme="dark"]
  .sidebarbutton:not(.SideBtnActive):not(.SideBtnParentActive)
  button:hover,
[data-bs-theme="dark"]
  .sidebarbutton:not(.SideBtnActive):not(.SideBtnParentActive)
  > a:hover {
  color: var(--theme-dark-sidebar-hover-text-color) !important;
}
[data-bs-theme="dark"]
  .sidebarbutton:not(.SideBtnActive):not(.SideBtnParentActive)
  button:hover
  .sidebarbutton-icon,
[data-bs-theme="dark"]
  .sidebarbutton:not(.SideBtnActive):not(.SideBtnParentActive)
  > a:hover
  .sidebarbutton-icon {
  color: var(--theme-dark-sidebar-hover-icon-color) !important;
}

/* Parent Active Button Styles (when a child is active) */
.sidebarbutton.SideBtnParentActive > button,
.sidebarbutton.SideBtnParentActive > a {
  background-color: var(--theme-light-sidebar-parent-active-bg) !important;
  border-radius: var(
    --theme-sidebar-item-border-radius
  ) !important; /* Standard radius, not pill */
  box-shadow: none !important; /* No shadow for parent active */
}
.sidebarbutton.SideBtnParentActive > button .sidebarbutton-text,
.sidebarbutton.SideBtnParentActive > a .sidebarbutton-text {
  color: var(--theme-light-sidebar-parent-active-text-color) !important;
  font-weight: 500 !important; /* Or slightly bolder if desired, e.g., 500 or 600 */
}
.sidebarbutton.SideBtnParentActive > button .sidebarbutton-icon,
.sidebarbutton.SideBtnParentActive > a .sidebarbutton-icon {
  color: var(--theme-light-sidebar-parent-active-icon-color) !important;
}
.sidebarbutton.SideBtnParentActive button::before, /* Hide hover effect when parent is active */
.sidebarbutton.SideBtnParentActive > a::before {
  display: none !important;
}

[data-bs-theme="dark"] .sidebarbutton.SideBtnParentActive > button,
[data-bs-theme="dark"] .sidebarbutton.SideBtnParentActive > a {
  background-color: var(--theme-dark-sidebar-parent-active-bg) !important;
}
[data-bs-theme="dark"]
  .sidebarbutton.SideBtnParentActive
  > button
  .sidebarbutton-text,
[data-bs-theme="dark"]
  .sidebarbutton.SideBtnParentActive
  > a
  .sidebarbutton-text {
  color: var(--theme-dark-sidebar-parent-active-text-color) !important;
}
[data-bs-theme="dark"]
  .sidebarbutton.SideBtnParentActive
  > button
  .sidebarbutton-icon,
[data-bs-theme="dark"]
  .sidebarbutton.SideBtnParentActive
  > a
  .sidebarbutton-icon {
  color: var(--theme-dark-sidebar-parent-active-icon-color) !important;
}

/* Directly Active Button Styles - Ensure these take precedence if an item is directly active */
.sidebarbutton.SideBtnActive button,
.sidebarbutton.SideBtnActive > a {
  background-color: var(--theme-light-sidebar-active-bg) !important;
  color: var(--theme-light-sidebar-active-text-color) !important;
  border-radius: var(--theme-sidebar-active-pill-border-radius) !important;
  font-weight: 600 !important;
  box-shadow: 0 2px 10px rgba(var(--theme-light-primary-rgb), 0.3);
}
.sidebarbutton.SideBtnActive button::before,
.sidebarbutton.SideBtnActive > a::before {
  display: none;
}
.sidebarbutton.SideBtnActive .sidebarbutton-icon {
  color: var(--theme-light-sidebar-active-icon-color) !important;
}
.sidebarbutton.SideBtnActive .sidebarbutton-text {
  color: var(--theme-light-sidebar-active-text-color) !important;
}

[data-bs-theme="dark"] .sidebarbutton.SideBtnActive button,
[data-bs-theme="dark"] .sidebarbutton.SideBtnActive > a {
  background-color: var(--theme-dark-sidebar-active-bg) !important;
  color: var(--theme-dark-sidebar-active-text-color) !important;
  box-shadow: 0 2px 10px rgba(var(--theme-dark-primary-rgb), 0.3);
}
[data-bs-theme="dark"] .sidebarbutton.SideBtnActive .sidebarbutton-icon {
  color: var(--theme-dark-sidebar-active-icon-color) !important;
}
[data-bs-theme="dark"] .sidebarbutton.SideBtnActive .sidebarbutton-text {
  color: var(--theme-dark-sidebar-active-text-color) !important;
}

/* --- Sidebar Submenu Styles --- */
.sidebarbutton .submenu-caret {
  margin-left: auto;
  transition: transform 0.3s ease;
  font-size: 0.8rem;
}
.sidebarbutton button.has-submenu.submenu-open .submenu-caret,
.sidebarbutton a.has-submenu.submenu-open .submenu-caret {
  transform: rotate(90deg);
}
.sidebar-submenu {
  list-style: none;
  padding-left: 0;
  margin-left: 1.5rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease-out, opacity 0.3s ease-in-out;
  opacity: 0;
  background-color: rgba(0, 0, 0, 0.03);
  border-radius: var(--theme-sidebar-item-border-radius);
  margin-top: 0.25rem;
}
[data-bs-theme="dark"] .sidebar-submenu {
  background-color: rgba(255, 255, 255, 0.03);
}
.sidebar-submenu.submenu-open {
  max-height: 1000px;
  opacity: 1;
}
.sidebar-submenu li > div.sidebarbutton > button,
.sidebar-submenu li > div.sidebarbutton > a {
  padding: 0.6rem 1rem !important;
  padding-left: 0.8rem !important;
  font-size: 0.9rem !important;
  border-radius: calc(var(--theme-sidebar-item-border-radius) - 4px) !important;
  margin: 0.2rem 0.5rem !important;
}
.sidebar-submenu li .sidebarbutton-icon {
  font-size: 1rem !important;
  margin-right: 0.8rem !important;
}
.sidebar-submenu .sidebar-submenu {
  margin-left: 1rem;
  margin-top: 0.1rem;
  background-color: rgba(0, 0, 0, 0.02);
}
[data-bs-theme="dark"] .sidebar-submenu .sidebar-submenu {
  background-color: rgba(255, 255, 255, 0.02);
}
.sidebar-submenu .sidebar-submenu li > div.sidebarbutton > button,
.sidebar-submenu .sidebar-submenu li > div.sidebarbutton > a {
  padding-left: 0.5rem !important;
  font-size: 0.85rem !important;
}
.sidebar-submenu .sidebar-submenu li .level3-dot {
  width: 6px;
  height: 6px;
  background-color: currentColor;
  border-radius: 50%;
  margin-right: 0.8rem;
  display: inline-block;
  flex-shrink: 0;
}
.sidebar-submenu .sidebar-submenu li .sidebarbutton-icon {
  display: none !important;
}

/* Footer Area */
.sidebar-footer-area {
  margin-top: auto;
  padding: 0.5rem 0.75rem;
  border-top: 0.5px solid var(--theme-light-sidebar-border-color);
  flex-shrink: 0;
  transition: padding 0.3s ease-in-out, border-color 0.3s ease;
}
[data-bs-theme="dark"] .sidebar-footer-area {
  border-top-color: var(--theme-dark-sidebar-border-color);
}
.sidebar-footer-area .theme-toggle-button,
.sidebar-footer-area .floating-toggle-button {
  background-color: var(--theme-light-toggle-bg) !important;
  color: var(--theme-light-toggle-text-color) !important;
  width: 100%;
  padding: 0.7rem;
  border-radius: var(--theme-sidebar-item-border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out;
  border: none;
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.sidebar-footer-area .floating-toggle-button:last-child {
  margin-bottom: 0;
}
[data-bs-theme="dark"] .sidebar-footer-area .theme-toggle-button,
[data-bs-theme="dark"] .sidebar-footer-area .floating-toggle-button {
  background-color: var(--theme-dark-toggle-bg) !important;
  color: var(--theme-dark-toggle-text-color) !important;
}
.sidebar-footer-area .theme-toggle-button:hover,
.sidebar-footer-area .floating-toggle-button:hover {
  background-color: var(--theme-light-toggle-hover-bg) !important;
}
[data-bs-theme="dark"] .sidebar-footer-area .theme-toggle-button:hover,
[data-bs-theme="dark"] .sidebar-footer-area .floating-toggle-button:hover {
  background-color: var(--theme-dark-toggle-hover-bg) !important;
}
.sidebar-footer-area .theme-toggle-button svg,
.sidebar-footer-area .floating-toggle-button svg,
.sidebar-footer-area .floating-toggle-button i {
  width: 1.25em;
  height: 1.25em;
  margin-right: 0.6rem;
  transition: margin-right 0.3s ease-in-out;
  flex-shrink: 0;
}
.sidebar-footer-area .theme-toggle-button .toggle-text-label,
.sidebar-footer-area .floating-toggle-button .toggle-text-label {
  font-size: 0.9rem;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.2s ease-in-out, display 0.2s ease-in-out;
}
.bd-sidebar.sidebar-mini
  .sidebar-footer-area
  .floating-toggle-button
  .toggle-text-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  display: none !important;
}
.bd-sidebar.sidebar-mini .sidebar-footer-area .floating-toggle-button svg,
.bd-sidebar.sidebar-mini .sidebar-footer-area .floating-toggle-button i {
  margin-right: 0 !important;
}
