/* 零三维保 - 管理后台布局：侧边栏、顶栏、内容区 */

/* ========== 整体布局 ========== */
body.admin-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-page);
  margin: 0;
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ========== 侧边栏（类名与 layout.js 一致）========== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-canvas-bg);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, min-width 0.2s ease;
  z-index: 100;
  box-shadow: none;
  flex-shrink: 0;
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card);
  flex-shrink: 0;
}

.sidebar-brand .sidebar-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex-shrink: 0;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.sidebar-brand .sidebar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-title { display: none; }

.sidebar-toggle {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}

.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 8px 18px;
  -webkit-overflow-scrolling: touch;
}

/* 方案 D：灰画布上的白圆角分组（Apple「设置」式，与主内容白卡片统一） */
.sidebar-module {
  margin: 0 0 12px;
  padding: 0;
  background: var(--sidebar-group-bg);
  border: 1px solid var(--sidebar-group-border);
  border-radius: var(--radius);
  box-shadow: var(--sidebar-group-shadow);
}

.sidebar-module:last-child {
  margin-bottom: 4px;
}

.sidebar-group {
  margin-bottom: 0;
}

.sidebar-group-title {
  padding: 12px 14px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: none;
  color: var(--text-hint);
  user-select: none;
  border-bottom: none;
  margin-bottom: 0;
}

/* 分组内单列列表 */
.sidebar-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 8px 10px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 500;
  border-radius: var(--radius-sm);
  margin: 0;
  transition: background 0.18s, color 0.18s;
  box-sizing: border-box;
}

.sidebar-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
  font-weight: 600;
  border: none;
}

.sidebar-item.active .sidebar-icon { opacity: 1; color: var(--primary-green); }

.sidebar-item .sidebar-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.88;
}

.sidebar-item .sidebar-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-item .sidebar-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========== 顶栏 ========== */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  flex-shrink: 0;
  min-width: 0;
}

.topbar-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--text-primary);
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.topbar-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 13px;
  color: var(--text-secondary);
}

.topbar-user-name {
  font-weight: 500;
  color: var(--text-primary);
}

.topbar-user-role {
  font-size: 12px;
  color: var(--text-hint);
}

.topbar-notify {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-orange);
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.topbar-notify:hover {
  opacity: 0.9;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--border-light);
}

.topbar-action-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
}

.topbar-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.topbar-action-btn.topbar-logout {
  color: var(--danger-red);
}

.topbar-action-btn.topbar-logout:hover {
  background: #FFEBEE;
  border-color: rgba(229, 57, 53, 0.2);
  color: var(--danger-red);
}

.topbar-change-pwd {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: var(--radius);
  transition: background 0.2s, color 0.2s;
}

.topbar-change-pwd:hover {
  background: var(--bg-hover);
  color: var(--primary-blue);
}

.topbar-logout {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: var(--radius);
  transition: background 0.2s, color 0.2s;
}

.topbar-logout:hover {
  background: var(--bg-hover);
  color: var(--primary-blue);
}

/* ========== 内容区 ========== */
.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.breadcrumb-wrap {
  margin-bottom: 20px;
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
}

.breadcrumb a {
  color: var(--primary-blue);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  margin: 0 8px;
  color: var(--text-hint);
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

.breadcrumb-section {
  color: var(--text-hint);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.page-content {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
}

/* ========== 移动端侧边栏遮罩 ========== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 150;
}

/* ========== 响应式（仅小屏隐藏侧边栏，需点击顶栏菜单展开）========== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 200;
  }

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

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

  .topbar-menu-btn {
    display: flex;
  }

  .content {
    padding: 16px;
  }

  /* 抽屉内宽度有限时改回单列，避免字被压得过扁 */
  .sidebar-group-items {
    grid-template-columns: 1fr;
  }

  .sidebar-group-items .sidebar-item:last-child:nth-child(odd) {
    grid-column: auto;
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 0 16px;
  }

  .topbar-title {
    font-size: 16px;
  }

  .content {
    padding: 16px;
  }
}
