/*--------------------------------------------------------------
# Sidebar - EliteAdmin
# Dark violet sidebar with accent edge indicators,
# icon containers, and smooth submenu reveals
--------------------------------------------------------------*/

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}

/* Mobile: Hidden by default */
@media (max-width: 1199px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }
}

/* Sidebar Collapsed State (Desktop) */
@media (min-width: 1200px) {
  .sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
    overflow: visible;
  }

  .sidebar-collapsed .sidebar-nav {
    overflow: visible;
  }
}

/*--------------------------------------------------------------
# Sidebar Header
--------------------------------------------------------------*/

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--spacing-lg);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-collapsed .sidebar-header {
  justify-content: center;
  padding: 0 var(--spacing-sm);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  white-space: nowrap;
}

.sidebar-logo:hover {
  opacity: 0.9;
}

.sidebar-logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  background: rgba(167, 139, 250, 0.15);
  flex-shrink: 0;
}

.sidebar-logo-icon img {
  height: 16px;
  width: auto;
  filter: brightness(0) invert(1);
}

.sidebar-logo-text {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--contrast-color);
  letter-spacing: -0.01em;
  transition: opacity var(--transition-fast), width var(--transition-fast);
}

.sidebar-collapsed .sidebar-logo {
  gap: 0;
  justify-content: center;
}

.sidebar-collapsed .sidebar-logo-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--sidebar-muted-color);
  background: none;
  border: none;
  cursor: pointer;
}

.sidebar-close:hover {
  background-color: var(--sidebar-hover-bg);
  color: var(--sidebar-color);
}

@media (min-width: 1200px) {
  .sidebar-close {
    display: none;
  }
}

/*--------------------------------------------------------------
# Sidebar Navigation
--------------------------------------------------------------*/

.sidebar-nav {
  flex: 1;
  padding: var(--spacing-md) var(--spacing-sm);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Scrollbar styling */
.sidebar-nav {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.5) transparent;
}

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

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.5);
  border-radius: 4px;

  &:hover {
    background: rgba(255, 255, 255, 0.65);
  }
}

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

/* Nav Menu - Reset list styles */
.nav-menu,
.nav-submenu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/*--------------------------------------------------------------
# Nav Heading (Section Title)
--------------------------------------------------------------*/

.nav-heading {
  padding: var(--spacing-xl) var(--spacing-md) var(--spacing-sm);
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-muted-color);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-collapsed .nav-heading {
  text-align: center;
  padding: var(--spacing-lg) var(--spacing-xs) var(--spacing-xs);
}

.sidebar-collapsed .nav-heading span {
  display: none;
}

.sidebar-collapsed .nav-heading::before {
  content: "";
  display: block;
  width: 16px;
  height: 1px;
  background: var(--sidebar-muted-color);
  margin: 0 auto;
  opacity: 0.4;
}

/*--------------------------------------------------------------
# Nav Item & Nav Link
--------------------------------------------------------------*/

.nav-item {
  position: relative;
}

/* Main nav link style */
.nav-item > .nav-link {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border-radius: var(--radius-lg);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--sidebar-color);
  text-decoration: none;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-item > .nav-link:hover {
  background-color: var(--sidebar-hover-bg);
  color: var(--contrast-color);
}

/* Icon container in nav link */
.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  margin-right: 12px;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.nav-icon i {
  font-size: 1.375rem;
}

/* Text in nav link */
.nav-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Arrow icon for submenus */
.nav-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.nav-arrow i {
  font-size: 0.625rem;
  opacity: 0.5;
}

.nav-link[aria-expanded="true"] > .nav-arrow,
.has-submenu.open > .nav-link > .nav-arrow {
  transform: rotate(90deg);
}

/* Active State - with left accent edge */
.nav-item > .nav-link.active {
  background-color: var(--sidebar-active-bg);
  color: var(--sidebar-active-color);
}

.nav-item > .nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--sidebar-active-color);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.nav-item > .nav-link.active .nav-icon {
  background: rgba(167, 139, 250, 0.15);
  color: var(--sidebar-active-color);
}

/* Open submenu parent */
.nav-item.has-submenu.open > .nav-link {
  color: var(--contrast-color);
}

/* Badge in nav */
.nav-badge {
  padding: 2px 8px;
  font-size: 0.625rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--accent-color);
  color: var(--contrast-color);
  flex-shrink: 0;
  margin-left: auto;
}

/*--------------------------------------------------------------
# Collapsed Sidebar State
--------------------------------------------------------------*/

@media (min-width: 1200px) {
  .sidebar-collapsed .nav-item > .nav-link {
    justify-content: center;
    padding: 10px;
  }

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

  .sidebar-collapsed .nav-text,
  .sidebar-collapsed .nav-arrow,
  .sidebar-collapsed .nav-badge {
    display: none;
  }
}

/*--------------------------------------------------------------
# Submenu (2nd Level)
--------------------------------------------------------------*/

.nav-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-base);
}

/* Open state */
.has-submenu.open > .nav-submenu,
.nav-submenu.show {
  max-height: none;
  margin-top: 2px;
}

/* Nav dot indicator for submenu items */
.nav-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--sidebar-muted-color);
  margin-right: 12px;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

/* Submenu items */
.nav-submenu > li > .nav-link {
  display: flex;
  align-items: center;
  padding: 7px 12px 7px 36px;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--sidebar-muted-color);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.nav-submenu > li > .nav-link:hover {
  color: var(--contrast-color);
  background-color: var(--sidebar-hover-bg);
}

.nav-submenu > li > .nav-link:hover .nav-dot {
  border-color: var(--sidebar-active-color);
  background: var(--sidebar-active-color);
}

.nav-submenu > li > .nav-link.active {
  color: var(--sidebar-active-color);
}

.nav-submenu > li > .nav-link.active .nav-dot {
  border-color: var(--sidebar-active-color);
  background: var(--sidebar-active-color);
}

/*--------------------------------------------------------------
# Nested Submenu (3rd Level)
--------------------------------------------------------------*/

.nav-submenu .has-submenu {
  position: relative;
}

.nav-submenu .has-submenu > .nav-link {
  display: flex;
  align-items: center;
  padding-right: 12px;
  font-weight: 500;
}

.nav-submenu .has-submenu > .nav-link .nav-arrow {
  margin-left: auto;
}

.nav-submenu .has-submenu > .nav-link > .nav-arrow {
  transition: transform var(--transition-fast);
}

.nav-submenu .has-submenu > .nav-link > .nav-arrow i {
  font-size: 0.625rem;
}

.nav-submenu .has-submenu.open > .nav-link > .nav-arrow {
  transform: rotate(90deg);
}

.nav-submenu .has-submenu.open > .nav-submenu {
  margin-top: 2px;
}

.nav-submenu .nav-submenu > li > .nav-link {
  padding-left: 48px;
}

.nav-submenu .nav-submenu .nav-dot {
  width: 5px;
  height: 5px;
  margin-right: 10px;
}

/*--------------------------------------------------------------
# Collapsed Sidebar - Flyout Submenus
--------------------------------------------------------------*/

@media (min-width: 1200px) {
  .sidebar-collapsed .nav-submenu {
    display: none !important;
    max-height: none !important;
  }

  .sidebar-collapsed .nav-item.has-submenu:hover > .nav-submenu {
    display: block !important;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 220px;
    max-height: none !important;
    padding: var(--spacing-sm);
    margin: 0;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
  }

  .sidebar-collapsed .nav-item.has-submenu:hover > .nav-submenu > li > .nav-link {
    padding-left: 12px;
  }
}

/*--------------------------------------------------------------
# Sidebar Footer
--------------------------------------------------------------*/

.sidebar-footer {
  padding: var(--spacing-sm) var(--spacing-sm);
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-footer-user {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) 10px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-footer-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: opacity var(--transition-fast);
}

.sidebar-footer-profile:hover {
  opacity: 0.85;
}

.sidebar-footer-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(167, 139, 250, 0.3);
}

.sidebar-footer-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.sidebar-footer-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--contrast-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.sidebar-footer-role {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--sidebar-muted-color);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sidebar-footer-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.sidebar-footer-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  color: var(--sidebar-muted-color);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.sidebar-footer-action:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--contrast-color);
}

.sidebar-footer-action i {
  font-size: 0.9375rem;
}

.sidebar-footer-logout:hover {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--danger-color);
}

/* Collapsed state */
@media (min-width: 1200px) {
  .sidebar-collapsed .sidebar-footer {
    padding: var(--spacing-sm);
  }

  .sidebar-collapsed .sidebar-footer-user {
    flex-direction: column;
    padding: var(--spacing-xs);
    gap: var(--spacing-xs);
  }

  .sidebar-collapsed .sidebar-footer-profile {
    justify-content: center;
  }

  .sidebar-collapsed .sidebar-footer-info {
    display: none;
  }

  .sidebar-collapsed .sidebar-footer-avatar {
    width: 34px;
    height: 34px;
  }

  .sidebar-collapsed .sidebar-footer-actions {
    width: 100%;
    justify-content: center;
    border-top: 1px solid var(--sidebar-border);
    padding-top: var(--spacing-xs);
    margin-top: 2px;
  }

  .sidebar-collapsed .sidebar-footer-action {
    width: 28px;
    height: 28px;
  }

  .sidebar-collapsed .sidebar-footer-action i {
    font-size: 0.875rem;
  }
}

/*--------------------------------------------------------------
# Sidebar Overlay (Mobile)
--------------------------------------------------------------*/

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.sidebar-open .sidebar-overlay {
  opacity: 1;
  visibility: visible;
}

@media (min-width: 1200px) {
  .sidebar-overlay {
    display: none;
  }
}
