/* App Layout */
.app-layout {
  min-height: 100vh;
}

.main-wrap {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s ease;
}
.app-layout.sidebar-collapsed .main-wrap { margin-left: var(--sidebar-collapsed); }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--dark);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-logo-text { display: none; }
.sidebar.collapsed .sidebar-menu-link .label { display: none; }
.sidebar.collapsed .sidebar-menu-link { justify-content: center; padding: 0 16px; }
.sidebar.collapsed .sidebar-menu-link .icon { margin-right: 0; }
.sidebar.collapsed .sidebar-menu-group .sidebar-submenu { display: none; }
.sidebar.collapsed .sidebar-chevron { display: none; }
.sidebar.collapsed .sidebar-menu-group-header { justify-content: center; padding: 0 16px !important; }

.sidebar-logo {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar-logo-text {
  margin-left: 10px;
  color: var(--white);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}
.sidebar-logo-text small {
  display: block;
  font-size: 10px;
  font-weight: 400;
  opacity: 0.6;
  letter-spacing: 1px;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
}
.sidebar-menu-item { position: relative; }
.sidebar-menu-link {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 44px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap;
}
.sidebar-menu-link:hover {
  color: var(--white);
  background: rgba(255,255,255,0.08);
}
.sidebar-menu-link.active {
  color: var(--white);
  background: var(--primary);
}
.sidebar-menu-link .icon {
  font-size: 16px;
  margin-right: 10px;
  flex-shrink: 0;
}
.sidebar-menu-link .label { font-size: 13px; }
.sidebar-menu-link .badge {
  margin-left: auto;
  background: var(--primary);
  color: var(--white);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* Sub menu */
.sidebar-menu-group { border-bottom: 1px solid rgba(255,255,255,0.06); }
.sidebar-menu-group .sidebar-submenu {
  background: rgba(0,0,0,0.2);
  padding: 2px 0;
}
.sidebar-menu-group .sidebar-submenu .sidebar-menu-link {
  padding-left: 38px;
  height: 38px;
  font-size: 13px;
}
.sidebar-menu-group-header {
  padding-right: 12px !important;
  color: rgba(255,255,255,0.5) !important;
  font-size: 12px !important;
  height: 36px !important;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.sidebar-menu-group-header::-webkit-details-marker { display: none; }
.sidebar-menu-group-header::-moz-list-bullet { display: none; }
.sidebar-menu-group-header:hover { color: rgba(255,255,255,0.8) !important; }
.sidebar-menu-group-header .icon { font-size: 13px !important; }
.sidebar-menu-group-header .label { font-size: 12px !important; }
.sidebar-chevron {
  margin-left: auto;
  font-size: 8px;
  transition: transform 0.2s ease;
  opacity: 0.6;
}
details[open] > .sidebar-menu-group-header .sidebar-chevron {
  transform: rotate(180deg);
}

/* Header */
.header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 1px 4px rgba(10,37,64,0.08);
  z-index: 90;
}

.header-left { display: flex; align-items: center; gap: 8px; }
.header-toggle {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--secondary);
  border-radius: var(--border-radius);
  transition: var(--transition);
}
.header-toggle:hover { background: var(--gray-100); }

.header-breadcrumb {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--gray-600);
}
.header-breadcrumb a { color: var(--gray-600); }
.header-breadcrumb a:hover { color: var(--primary); }
.header-breadcrumb .separator { margin: 0 6px; color: var(--gray-400); }
.header-breadcrumb .current { color: var(--gray-800); font-weight: 500; }

.header-right { display: flex; align-items: center; gap: 12px; }
.header-action {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--gray-600);
  border-radius: var(--border-radius);
  transition: var(--transition);
}
.header-action:hover { background: var(--gray-100); }
.header-action .badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: var(--error);
  color: var(--white);
  font-size: 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--border-radius);
  transition: var(--transition);
  position: relative;
}
.header-user:hover { background: var(--gray-100); }
.header-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 13px;
  font-weight: 600;
}
.header-username { font-size: 13px; color: var(--gray-700); }

.header-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  padding: 6px 0;
  display: none;
  z-index: 200;
}
.header-user:hover .header-dropdown { display: block; }
/* 触屏设备无 hover：点击头像展开（.open 由 app.js 切换） */
@media (hover: none), (max-width: 768px) {
  .header-dropdown { display: none; }
  .header-user.open .header-dropdown,
  .header-user:focus-within .header-dropdown { display: block; }
  .header-user.open { background: var(--gray-100); }
}
.header-dropdown-item {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--gray-700);
  cursor: pointer;
  transition: var(--transition);
}
.header-dropdown-item:hover { background: var(--gray-50); }
.header-dropdown-item.danger { color: var(--error); }
.header-dropdown-item.danger:hover { background: rgba(255,77,79,0.05); }

/* Content */
.content {
  padding: 16px;
  min-height: calc(100vh - var(--header-height));
}

/* Page container */
.page-container { max-width: 100%; }

/* Mobile toggle */
.mobile-toggle {
  display: none;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--secondary);
}
