.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background-color: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.navbar__stats {
  display: none;
}

.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  width: 280px;
  background-color: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: none;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6);
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

html.authenticated .sidebar,
body.authenticated .sidebar {
  display: flex;
}

html.authenticated .navbar__stats,
body.authenticated .navbar__stats {
  display: flex;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.sidebar__profile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar__avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background-color: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-on-surface);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.sidebar__user {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.sidebar__name {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--color-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__handle {
  font-size: var(--text-xs);
  color: var(--color-accent);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


.sidebar__close {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  transition: color var(--transition-fast);
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.sidebar__close:hover {
  color: var(--color-on-surface);
}

.sidebar__guest {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
  padding: var(--space-6) var(--space-2);
}

.sidebar__guest-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background-color: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
}

.sidebar__guest-icon .material-symbols-rounded {
  font-size: 28px;
}

.sidebar__guest-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-on-surface);
}

.sidebar__guest-desc {
  font-size: var(--text-xs);
  color: var(--color-muted);
  line-height: 1.5;
}

.sidebar__login-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background-color: var(--color-accent);
  color: var(--color-surface);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  transition: opacity var(--transition-fast);
}

.sidebar__login-btn:hover {
  opacity: 0.85;
}

.sidebar__login-btn .material-symbols-rounded {
  font-size: 18px;
}

.sidebar__logged {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  flex: 1;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar__nav-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-muted-2);
  padding-inline: var(--space-3);
  margin-bottom: var(--space-1);
  display: block;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-muted);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.sidebar__link .material-symbols-rounded {
  font-size: 20px;
}

.sidebar__link:hover {
  background-color: var(--color-surface-raised);
  color: var(--color-on-surface);
}

.sidebar__link:hover::before {
  content: ">";
  background-color: var(--color-surface-raised);
  color: var(--color-on-surface);
}

.sidebar__link--active {
  background-color: var(--color-surface-raised);
  color: var(--color-on-surface);
}

.sidebar__link--danger {
  color: var(--color-danger);
}

.sidebar__link--danger:hover {
  background-color: rgba(248, 113, 113, 0.08);
  color: var(--color-danger);
}

.sidebar__link--danger:hover::before {
  content: ">";
  background-color: var(--color-surface-raised);
  color: var(--color-danger);
}

.sidebar__footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-subtle);
}

.hidden {
  display: none !important;
}

.sidebar__version {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  color: var(--color-muted);
  margin-top: auto;
  padding-inline: var(--space-3);
}

@media (min-width: 1024px) {
  html.authenticated body,
  body.authenticated {
    padding-left: 280px;
  }

  html.authenticated body::before,
  body.authenticated::before {
    content: "";
    position: fixed;
    top: calc(var(--navbar-height) + var(--notif-bar-height, 0px));
    left: 0;
    bottom: 0;
    width: 280px;
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-border);
    z-index: 199;
  }

  .sidebar {
    top: var(--navbar-height);
    left: 0;
    right: auto;
    transform: translateX(0) !important;
    border-top: none;
    border-right: 1px solid var(--color-border);
    border-left: none;
  }

  .sidebar-overlay {
    display: none !important;
  }

  .sidebar__close,
  .avatar {
    display: none !important;
  }
}
