/* 添加必要的变量 */
:root {
  --primary-color-rgb: 112, 73, 240; /* 主色调的RGB值 */
}

.sidebar {
  position: fixed;
  top: var(--navbar-height);
  left: calc(-1 * var(--sidebar-width));
  width: var(--sidebar-width);
  height: calc(100vh - var(--navbar-height));
  background: var(--bg-secondary);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
  z-index: 1030;
  transition: var(--transition-base);
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

body.sidebar-active .sidebar {
  left: 0;
}

.sidebar-overlay {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  width: 100%;
  height: calc(100% - var(--navbar-height));
  background: rgba(0, 0, 0, 0.5);
  z-index: 1025;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
  body.sidebar-active .sidebar-overlay {
    display: block;
    opacity: 1;
  }
}

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

.sidebar-header {
  padding: 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-sm) 0;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE 10+ */
}

/* Chrome/Safari/Edge */
.sidebar-content::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Edge */
}

.sidebar-group {
  margin-bottom: var(--spacing-sm);
}

.sidebar-group-title {
  font-size: 1.1rem;
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--text-secondary);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-menu-item {
  display: block;
}

.sidebar-menu-link {
  display: flex;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition-base);
  font-size: 1rem;
  font-weight: 600;
  border-left: 3px solid transparent;
}

.sidebar-menu-link:hover {
  background: var(--bg-hover);
  color: var(--primary-color);
  border-left-color: var(--primary-color);
  font-weight: 600;
}

.sidebar-menu-icon {
  margin-right: var(--spacing-sm);
  font-size: var(--font-size-lg);
  width: 25px;
  text-align: center;
  color: var(--text-secondary);
}

.sidebar-footer {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-secondary);
  border-top: 1px solid #eee;
}

.auth-buttons {
  display: flex;
  gap: var(--spacing-sm);
}

.auth-button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm);
  border-radius: var(--border-radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition-base);
  text-decoration: none;
  font-size: var(--font-size-sm);
}

.auth-button.login {
  background: var(--primary-gradient);
  color: white;
}

.auth-button.login:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.auth-button.register {
  background: var(--bg-primary);
  border: 1px solid #ddd;
  color: var(--text-primary);
}

.auth-button.register:hover {
  background: var(--bg-hover);
}

.auth-button i {
  margin-right: var(--spacing-xs);
}

.user-box {
  display: flex;
  align-items: center;
  padding: var(--spacing-sm);
  background: var(--bg-primary);
  border-radius: var(--border-radius);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--secondary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  margin-right: var(--spacing-sm);
}

.user-info {
  flex: 1;
}

.user-name {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.user-actions-list {
  list-style: none;
  padding: 0;
  margin: var(--spacing-sm) 0 0;
}

.user-action-item {
  margin-bottom: var(--spacing-xs);
}

.user-action-link {
  display: flex;
  align-items: center;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  text-decoration: none;
  padding: var(--spacing-xs);
  border-radius: var(--border-radius-sm);
  transition: var(--transition-base);
}

.user-action-link:hover {
  background: var(--bg-hover);
  color: var(--primary-color);
}

.user-action-link i {
  margin-right: var(--spacing-xs);
  font-size: var(--font-size-sm);
  width: 20px;
  text-align: center;
}

/* 分类拖拽排序相关样式 */
.sidebar-menu-item .sidebar-drag-handle {
  display: none;
  cursor: grab;
  opacity: 0.6;
  margin-left: auto;
  padding-left: 8px;
  flex-shrink: 0;
  color: var(--primary-color);
  font-size: 14px;
  transition: opacity 0.2s ease;
}

.user-admin .sidebar-menu-item .sidebar-drag-handle {
  display: inline-block !important; /* 使用 !important 覆盖全局设置 */
}

.sidebar-menu-item:hover .sidebar-drag-handle {
  opacity: 0.9;
}

/* 拖拽相关样式 */
.sidebar-menu-item.dragging {
  opacity: 0.8;
  background: var(--bg-hover);
  position: relative;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.sidebar-menu-item.drag-over {
  border-top: 2px solid var(--primary-color);
  background-color: rgba(var(--primary-color-rgb), 0.1);
  margin-top: -2px; /* 补偿边框高度，避免元素跳动 */
}

/* 拖拽时的视觉反馈 */
.sidebar-menu .sidebar-menu-item {
  transition: transform 0.2s ease, box-shadow 0.2s ease,
    background-color 0.2s ease;
}

.sidebar-menu .sidebar-menu-item.dragging {
  box-shadow: var(--shadow-md);
  cursor: grabbing;
}

.sidebar-menu .sidebar-menu-item.during-drag:not(.dragging) {
  transform: translateY(0);
  transition: transform 0.3s ease;
}

.sidebar-menu .sidebar-menu-item.during-drag.drag-over {
  position: relative;
}

/* 确保拖拽项的链接正确显示 */
.sidebar-menu-item .sidebar-menu-link {
  display: flex;
  align-items: center;
  width: 100%;
}

/* 删除伪元素指示器 */
/* 为管理员模式添加指示器 */
.user-admin .sidebar-menu-item .sidebar-menu-link::after {
  display: none;
}

.user-admin .sidebar-menu-item:hover .sidebar-menu-link::after {
  display: none;
}

/* 侧边栏相关CSS调整，确保半透明背景层适配 */
.sidebar-menu-item a {
  padding: 10px 15px;
  transition: all 0.3s ease;
}

/* 保留侧边栏透明背景，但移除菜单项特殊样式
body:not(.bg-none) .sidebar {
  background-color: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body:not(.bg-none) .sidebar-menu-item a:hover {
  background-color: rgba(255, 255, 255, 0.95);
}
*/

/* 使侧边栏更加明显以避免背景干扰 */
body:not(.bg-none) .sidebar {
  background-color: rgba(0, 0, 0, 0.4); /* 黑色毛玻璃 */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body:not(.bg-none) .sidebar,
body:not(.bg-none) .sidebar-menu-link,
body:not(.bg-none) .sidebar-group-title,
body:not(.bg-none) .sidebar-menu-icon {
  color: #f3f3f3;
}

body:not(.bg-none) .sidebar-menu-link:hover {
  color: #ffd86b;
  background: rgba(255, 255, 255, 0.08);
}

body:not(.bg-none) .sidebar-menu-link.active {
  color: #ffd86b;
  background: rgba(255, 255, 255, 0.12);
}

body:not(.bg-none) .sidebar-submenu-link {
  color: #e0e0e0;
}
body:not(.bg-none) .sidebar-submenu-link:hover {
  color: #ffd86b;
  background: rgba(255, 255, 255, 0.08);
}
body:not(.bg-none) .sidebar-submenu-link.active {
  color: #ffd86b;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-drag-handle {
  display: none !important;
}
