/* ============ 后台框架：侧边栏 / 顶栏 ============ */
.admin-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--brand-background);
}

.admin-body {
  flex: 1;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.admin-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--brand-background);
}

.admin-content > * {
  flex: 1;
  min-height: 0;
}

/* ---------- 侧边栏 ---------- */
.admin-sidebar {
  width: 236px;
  flex-shrink: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--brand-card);
  border-right: 1px solid var(--brand-border);
  transition: width 0.2s ease, transform 0.22s ease;
  position: relative;
  z-index: 40;
}

.sidebar-head {
  flex-shrink: 0;
  height: 56px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--brand-border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
}

.sidebar-close {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--brand-muted-foreground);
  cursor: pointer;
  border-radius: var(--brand-radius-sm);
}

.sidebar-close:hover {
  color: var(--brand-primary);
  background: var(--brand-input);
}

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

.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-group-title {
  margin: 0 0 6px;
  padding: 0 10px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand-muted);
  white-space: nowrap;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--brand-radius-sm);
  background: transparent;
  color: var(--brand-muted-foreground);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.sidebar-link:hover {
  color: var(--brand-foreground);
  background: var(--brand-input);
}

.sidebar-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.sidebar-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme-style="nexus"] .sidebar-link.active {
  border-color: rgba(0, 240, 255, 0.45);
  background: rgba(0, 240, 255, 0.1);
  color: var(--brand-primary);
  box-shadow: inset 2px 0 0 var(--brand-primary), 0 0 12px rgba(0, 240, 255, 0.12);
}

[data-theme-style="ironcore"] .sidebar-link.active {
  background: rgba(240, 160, 48, 0.1);
  color: var(--brand-primary);
  border-left: 2px solid var(--brand-primary);
}

.sidebar-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-secondary);
  color: var(--brand-secondary-foreground);
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
}

/* 折叠态（仅桌面端） */
@media (min-width: 1024px) {
  .admin-shell.is-collapsed .admin-sidebar {
    width: 76px;
  }

  .admin-shell.is-collapsed .sidebar-head {
    justify-content: center;
    padding: 0 10px;
  }

  .admin-shell.is-collapsed .sidebar-brand .brand-logo-copy,
  .admin-shell.is-collapsed .sidebar-label {
    display: none;
  }

  .admin-shell.is-collapsed .sidebar-nav {
    padding: 14px 10px;
  }

  .admin-shell.is-collapsed .sidebar-group-title {
    height: 1px;
    margin: 4px 12px 8px;
    padding: 0;
    background: var(--brand-border);
    color: transparent;
    overflow: hidden;
  }

  .admin-shell.is-collapsed .sidebar-link {
    justify-content: center;
    padding: 0;
  }

  .admin-shell.is-collapsed .sidebar-badge {
    position: absolute;
    top: 3px;
    right: 9px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 9px;
  }
}

/* ---------- 顶栏 ---------- */
.admin-topbar {
  flex-shrink: 0;
  height: 56px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--brand-card);
  border-bottom: 1px solid var(--brand-border);
  position: relative;
  z-index: 30;
}

.topbar-divider {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--brand-border);
}

.topbar-crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.topbar-crumb-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-muted-foreground);
  transition: color 0.15s ease;
}

.topbar-crumb-home:hover {
  color: var(--brand-primary);
}

.topbar-crumb-current {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: var(--brand-radius-sm);
  background: transparent;
  color: var(--brand-muted-foreground);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.topbar-icon-btn:hover {
  color: var(--brand-primary);
  background: var(--brand-input);
}

.topbar-toggle-mobile {
  display: inline-flex;
}

.topbar-toggle-desktop {
  display: none;
}

@media (min-width: 1024px) {
  .topbar-toggle-mobile {
    display: none;
  }

  .topbar-toggle-desktop {
    display: inline-flex;
  }
}

[data-theme-style="nexus"] .topbar-icon-btn:hover {
  border-color: rgba(0, 240, 255, 0.3);
}

.topbar-unread {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand-secondary);
  border: 1px solid var(--brand-card);
  color: var(--brand-secondary-foreground);
  font-family: var(--font-display);
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1;
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  margin-left: 4px;
  border: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
  color: var(--brand-primary-foreground);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.topbar-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.topbar-avatar:hover {
  opacity: 0.88;
}

.topbar-menu {
  position: absolute;
  top: 42px;
  right: 0;
  width: 208px;
  z-index: 50;
  background: var(--brand-popover);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius-md);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.topbar-menu-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--brand-border);
}

.topbar-menu-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-menu-mail {
  margin-top: 2px;
  font-size: 11px;
  color: var(--brand-muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-menu-role {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--brand-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-menu-item {
  width: 100%;
  padding: 9px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  color: var(--brand-foreground);
  font-family: var(--font-body);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.topbar-menu-item:hover {
  background: var(--brand-input);
}

.topbar-menu-item.is-danger {
  color: var(--color-status-error);
}

.topbar-menu-item.is-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.topbar-menu-sep {
  height: 1px;
  background: var(--brand-border);
}

/* ---------- 移动端抽屉 ---------- */
@media (max-width: 1023px) {
  .admin-topbar {
    padding: 0 12px;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 248px;
    height: 100vh;
    height: 100dvh;
    z-index: 60;
    transform: translateX(-100%);
  }

  .admin-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 0 0 48px rgba(0, 0, 0, 0.6);
  }

  .admin-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(4, 4, 12, 0.62);
    backdrop-filter: blur(2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .admin-sidebar {
    transition: none;
  }
}
