/* ===== Admin Layout ===== */
.admin-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid #e8e8e8;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.2s ease;
  overflow: hidden;
  min-height: 100vh;
}

/* 侧边栏容器确保正确滚动 */
.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.sidebar.collapsed { width: 64px; }

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  border-bottom: 1px solid #f0f0f0;
  background: aliceblue;
}
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 18px 0; }
.sidebar.collapsed .sidebar-logo > span { display: none; }

/* ── 环境标识 (非生产环境) ── */
.env-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 8px 12px;
  padding: 6px 10px;
  border-radius: var(--border-radius);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  background: var(--color-error, #ff4d4f);
  box-shadow: 0 0 0 1px rgba(255, 77, 79, 0.35), 0 2px 6px rgba(255, 77, 79, 0.35);
  white-space: nowrap;
  user-select: none;
  animation: env-badge-pulse 2.4s ease-in-out infinite;
}
.env-badge-short { display: none; }

/* 非生产环境里, 开发(development)用更克制的橙黄, staging 保持红色警示 */
.env-badge-development {
  background: var(--color-warning, #faad14);
  color: #613400;
  box-shadow: 0 0 0 1px rgba(250, 173, 20, 0.35), 0 2px 6px rgba(250, 173, 20, 0.3);
  animation: none;
}

/* 收起侧边栏时只显示首字 */
.sidebar.collapsed .env-badge { margin: 8px 8px; padding: 6px 4px; }
.sidebar.collapsed .env-badge .env-badge-full { display: none; }
.sidebar.collapsed .env-badge .env-badge-short { display: inline; }

@keyframes env-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255, 77, 79, 0.35), 0 2px 6px rgba(255, 77, 79, 0.35); }
  50%      { box-shadow: 0 0 0 1px rgba(255, 77, 79, 0.55), 0 2px 12px rgba(255, 77, 79, 0.6); }
}
@media (prefers-reduced-motion: reduce) {
  .env-badge { animation: none; }
}

/* Menu scroll */
.sidebar-menu { flex: 1; overflow-y: auto; padding: 8px 0; }

/* ── Menu Group ── */
.menu-group { }

/* 板块标题 */
.menu-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #000;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  margin: 12px 12px 0;
  padding: 6px 0;
  border-radius: 4px;
  transition: background-color 0.15s;
}
.menu-group-title:hover {
  background-color: rgba(0, 0, 0, 0.03);
}
.menu-group-arrow {
  font-size: 12px;
  color: #999;
  width: 16px;
  text-align: left;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.menu-group-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.menu-group-label {
  flex: 1;
  text-align: left;
}

/* 子菜单容器 */
.menu-group-body {
  overflow: hidden;
  max-height: 1000px;
  transition: max-height 0.3s ease-in-out, opacity 0.2s ease;
  opacity: 1;
  margin: 0;
  padding: 0;
  border: none;
  box-sizing: border-box;
}
.menu-group-body.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* 子板块标题（二级分组标题） */
.menu-subgroup-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 100;
  color: #000;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  padding: 8px 12px 4px 28px;
}
.menu-subgroup-title .menu-group-arrow {
  font-size: 11px;
  color: #999;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

/* 二级/三级菜单项缩进 */
.menu-subgroup .menu-item {
  padding: 8px 20px 8px 40px;
  margin: 1px 12px;
  font-size: 13px;
}
.menu-subgroup .menu-item .menu-icon {
  font-size: 14px;
  width: 16px;
}

/* Menu Item */
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px 10px 28px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 6px;
  margin: 2px 12px;
}
.menu-item:hover { color: var(--color-primary); background: #f5f8ff; border-color: #d0dff5; }
.menu-item.active { color: #fff; background: var(--color-primary); border-color: var(--color-primary); font-weight: 500; }
.menu-item-indent { padding-left: 36px !important; font-size: 13px; }
.menu-item-indent .menu-icon { font-size: 14px !important; width: 16px !important; }
.menu-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.menu-text { overflow: hidden; text-overflow: ellipsis; }

.menu-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 9px;
  line-height: 1;
  margin-left: auto;
  flex-shrink: 0;
}
.sidebar.collapsed .menu-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 14px;
  height: 14px;
  font-size: 9px;
  padding: 0 3px;
}
.sidebar.collapsed .menu-item { position: relative; }
.menu-item-disabled { color: #d0d0d0 !important; cursor: not-allowed !important; }
.menu-item-disabled:hover { background: transparent !important; color: #d0d0d0 !important; }

/* Collapsed sidebar */
.sidebar.collapsed .menu-group-title { justify-content: center; padding: 8px 0; }
.sidebar.collapsed .menu-group-title .menu-group-arrow { display: none; }
.sidebar.collapsed .menu-group-title::after {
  display: none;
}
.sidebar.collapsed .menu-group-body { max-height: none !important; }
.sidebar.collapsed .menu-item { justify-content: center; padding: 12px 0; border-radius: 0; margin: 2px 4px; }
.sidebar.collapsed .menu-item:hover { background: #f5f8ff; }
.sidebar.collapsed .menu-item.active { background: #e6f0ff; }
.sidebar.collapsed .menu-item .menu-text { display: none; }
.sidebar.collapsed .menu-icon { font-size: 20px; width: auto; }

/* ── Main Content ── */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.2s ease;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.sidebar.collapsed ~ .main-area { margin-left: 64px; }

/* ── Header ── */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--spacing-lg);
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.header-left { display: flex; align-items: center; gap: var(--spacing-sm); }
.header-toggle { font-size: 18px; color: var(--text-secondary); cursor: pointer; padding: 4px; border-radius: 4px; flex-shrink: 0; }
.header-toggle:hover { color: var(--text-primary); background: var(--bg-hover); }
.header-title { font-size: 16px; font-weight: 600; white-space: nowrap; }
.header-title-area { display: flex; align-items: center; gap: 8px; overflow: hidden; }
.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-tertiary); overflow: hidden; flex-wrap: nowrap; white-space: nowrap; }
.breadcrumb-item { color: var(--text-tertiary); text-decoration: none; cursor: default; }
.breadcrumb-item[href] { color: #1a6dff; text-decoration: none; cursor: pointer; }
.breadcrumb-item[href]:hover { text-decoration: underline; }
.breadcrumb-current { color: var(--text-primary); font-weight: 500; }
.breadcrumb-sep { color: var(--text-tertiary); margin: 0 2px; }
.header-right { display: flex; align-items: center; gap: var(--spacing-md); }
.header-user { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.header-user:hover { background: var(--bg-hover); }
.header-user .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.header-user .name { font-size: 14px; color: var(--text-primary); }
.header-user .role-tag { font-size: 11px; padding: 1px 6px; border-radius: 3px; background: var(--bg-component); color: var(--text-secondary); }

/* ── Content ── */
.content-body { flex: 1; padding: var(--spacing-lg); overflow-y: auto; }

/* ── Page Header ── */
.page-header { margin-bottom: var(--spacing-lg); }
.page-header h1 { font-size: 20px; font-weight: 600; }
.page-header .breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 13px; margin-bottom: 8px; }
.page-header .breadcrumb a { color: var(--text-secondary); }
.page-header .breadcrumb a:hover { color: var(--color-primary); text-decoration: none; }
.page-header .breadcrumb .sep { color: var(--text-tertiary); }

/* ── Toolbar ── */
.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--spacing-sm); margin-bottom: var(--spacing-md); }
.toolbar-left { display: flex; align-items: center; gap: var(--spacing-sm); flex-wrap: wrap; }
.toolbar-right { display: flex; gap: var(--spacing-sm); }

/* Main content */
.main-area { flex: 1; margin-left: var(--sidebar-width); transition: margin-left var(--transition-normal); display: flex; flex-direction: column; min-height: 100vh; }
.sidebar.collapsed + .main-area { margin-left: var(--sidebar-collapsed-width); }

/* Header */
.header { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; height: var(--header-height); padding: 0 var(--spacing-lg); background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.header-left { display: flex; align-items: center; gap: var(--spacing-sm); }
.header-toggle { font-size: 20px; color: var(--text-secondary); cursor: pointer; border-radius: 4px; padding-bottom: 7px; }
.header-toggle:hover { color: var(--text-primary); background: var(--bg-hover); }
.header-title { font-size: 16px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: var(--spacing-md); }
.header-user { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.header-user:hover { background: var(--bg-hover); }
.header-user .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.header-user .name { font-size: 14px; color: var(--text-primary); }
.header-user .role-tag { font-size: 11px; padding: 1px 6px; border-radius: 3px; background: var(--bg-component); color: var(--text-secondary); }

/* Content body */
.content-body { flex: 1; padding: var(--spacing-lg); overflow-y: auto; }

/* Page header with breadcrumb */
.page-header { margin-bottom: var(--spacing-lg); }
.page-header h1 { font-size: 20px; font-weight: 600; }
.page-header .breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 13px; margin-bottom: 8px; }
.page-header .breadcrumb a { color: var(--text-secondary); }
.page-header .breadcrumb a:hover { color: var(--color-primary); text-decoration: none; }
.page-header .breadcrumb .sep { color: var(--text-tertiary); }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--spacing-sm); margin-bottom: var(--spacing-md); }
.toolbar-left { display: flex; align-items: center; gap: var(--spacing-sm); flex-wrap: wrap; }
.toolbar-right { display: flex; gap: var(--spacing-sm); }

/* Read-only status display */
.input-like { padding: 8px 12px; background: #f5f5f5; border: 1px solid #e0e0e0; border-radius: 6px; color: #666; font-size: 14px; margin: 0; min-height: 20px; }
