/* 管理后台样式 */

/* ========== 变量定义 ========== */
:root {
  /* 主题色 */
  --primary-color: #6e8efb;
  --primary-dark: #5c7df3;
  --primary-light: #8aa3fa;
  --secondary-color: #14b8a6;

  /* 背景颜色 */
  --bg-color: #f8f9fa;
  --sidebar-bg: #2a3042;
  --navbar-bg: #2a3042;
  --content-bg: #ffffff;

  /* 文本颜色 */
  --text-color: #333333;
  --text-muted: #6c757d;
  --sidebar-text: #a7b1c2;
  --sidebar-active: #ffffff;
  --navbar-text: #a7b1c2;
  --navbar-text-hover: #ffffff;

  /* 边框颜色 */
  --border-color: #e9ecef;
  --hover-bg: #f1f3fa;

  /* 尺寸 */
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 70px;
  --navbar-height: 60px;
  --border-radius: 6px;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;

  /* 其他 */
  --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --box-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --transition: all 0.3s ease;
}

/* 暗黑模式变量 */
[data-theme="dark"] {
  --primary-color: #6e8efb;
  --primary-dark: #5c7df3;
  --primary-light: #8aa3fa;

  --bg-color: #1a1d21;
  --sidebar-bg: #111827;
  --navbar-bg: #1e2433;
  --content-bg: #1a1d21;

  --text-color: #e9ecef;
  --text-muted: #adb5bd;
  --sidebar-text: #9ca3af;
  --sidebar-active: #ffffff;

  --border-color: #2c3344;
  --hover-bg: #2c3344;

  --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
  --box-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.25);
}

/* ========== 基础布局 ========== */
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

.admin-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-color);
  position: relative;
}

/* ========== 导航栏样式 ========== */
.admin-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-md);
  background-color: var(--navbar-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--box-shadow);
  z-index: 1000;
  transition: var(--transition);
}

.navbar-left {
  display: flex;
  align-items: center;
}

.navbar-brand {
  display: flex;
  align-items: center;
  color: var(--sidebar-active);
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
  margin-left: var(--spacing-md);
}

.navbar-brand:hover {
  color: var(--primary-color);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  margin-right: var(--spacing-sm);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.navbar-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--navbar-text);
  text-decoration: none;
  padding: 0.5rem;
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.navbar-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--navbar-text-hover);
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--border-radius);
  transition: var(--transition);
  color: var(--navbar-text);
}

.navbar-user:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--navbar-text-hover);
}

.user-avatar {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  font-weight: 600;
}

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  width: 200px;
  background-color: var(--sidebar-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-lg);
  padding: 0.5rem 0;
  list-style: none;
  margin: 0;
  z-index: 1001;
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.dropdown-menu.show {
  display: block;
}

.dropdown-menu li a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  color: var(--navbar-text);
  text-decoration: none;
  transition: var(--transition);
}

.dropdown-menu li a:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--navbar-text-hover);
}

/* ========== 侧边栏样式 ========== */
.admin-sidebar {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  z-index: 990;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: 1px 0 5px rgba(0, 0, 0, 0.1);
  border-radius: 0 !important;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--sidebar-active);
  font-weight: 600;
}

.sidebar-logo i {
  font-size: 1.25rem;
}

.sidebar-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
  z-index: 1000;
}

.sidebar-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-active);
}

.sidebar-content {
  flex: 1;
  padding-top: 0; /* 不再需要为顶部折叠按钮留出空间 */
}

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

.sidebar-item {
  margin: 2px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 0.75rem var(--spacing-md);
  color: var(--sidebar-text);
  text-decoration: none;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--sidebar-active);
}

.sidebar-item.active .sidebar-link {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--sidebar-active);
  border-left-color: var(--primary-color);
}

.sidebar-link i {
  font-size: 1.25rem;
  min-width: 25px;
  margin-right: var(--spacing-md);
}

/* 侧边栏折叠状态 */
.sidebar-collapsed .admin-sidebar {
  width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar-link span {
  display: none;
}

.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 0.75rem;
  text-align: center;
}

.sidebar-collapsed .sidebar-link i {
  margin-right: 0;
  font-size: 1.25rem;
}

.sidebar-collapsed .sidebar-item.active .sidebar-link {
  border-left: none;
  border-left-width: 0;
  border-radius: 0;
  border-right: 3px solid var(--primary-color);
}

/* 覆盖层（移动端使用） */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 980;
  display: none;
}

/* ========== 主内容区域 ========== */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  margin-top: var(--navbar-height);
  transition: var(--transition);
  min-height: calc(100vh - var(--navbar-height));
}

.admin-container {
  padding: var(--spacing-lg);
  max-width: 1400px;
  margin: 0 auto;
}

.sidebar-collapsed .admin-main {
  margin-left: var(--sidebar-collapsed-width);
}

/* ========== 响应式样式 ========== */
@media (max-width: 991.98px) {
  .admin-main {
    margin-left: 0;
  }

  .admin-sidebar {
    transform: translateX(-100%);
    top: 0; /* 在移动设备上，侧边栏从顶部开始 */
  }

  .menu-toggle {
    display: block;
  }

  .sidebar-collapsed .admin-main {
    margin-left: 0;
  }

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

  .sidebar-mobile-open .sidebar-overlay {
    display: block;
  }

  /* 移动设备上的侧边栏和折叠按钮 */
  .sidebar-toggle {
    top: auto;
    position: relative;
  }

  .sidebar-content {
    padding-top: 0;
  }

  /* 移动设备上折叠状态下的仪表盘 */
  .sidebar-mobile-open .dashboard-header {
    margin-top: 60px; /* 为移动设备上的navbar留出空间 */
  }
}

/* 新增仪表盘头部区域样式 */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem var(--spacing-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background-color: rgba(255, 255, 255, 0.05);
  min-height: 52px;
}

.dashboard-link {
  display: flex;
  align-items: center;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: var(--transition);
  flex: 1;
}

.dashboard-link.active,
.dashboard-link:hover {
  color: var(--sidebar-active);
}

.dashboard-link i {
  font-size: 1.25rem;
  min-width: 25px;
  margin-right: var(--spacing-md);
}

/* 折叠状态下仪表盘样式 */
.sidebar-collapsed .dashboard-header {
  flex-direction: column;
  padding: 0.75rem 0;
  gap: 0.75rem;
  min-height: 90px;
}

.sidebar-collapsed .dashboard-link {
  justify-content: center;
}

.sidebar-collapsed .dashboard-link span {
  display: none;
}

.sidebar-collapsed .dashboard-link i {
  margin-right: 0;
}

.sidebar-collapsed .sidebar-toggle {
  margin-right: 0;
}
