/* ===== App Container ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ===== Top Bar ===== */
#topbar {
  height: var(--topbar-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  flex-shrink: 0;
  -webkit-app-region: drag;
}

#topbar .tb-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
  -webkit-app-region: no-drag;
  min-width: 180px;
}

#topbar .tb-left #tb-welcome {
  font-weight: 500;
  color: var(--text-primary);
}

#topbar .tb-left .tb-sep {
  color: var(--text-tertiary);
  font-weight: 300;
}

#topbar .tb-left #page-title {
  font-weight: 450;
  color: var(--text-secondary);
}

#topbar .tb-right {
  display: flex;
  align-items: center;
  gap: 16px;
  -webkit-app-region: no-drag;
}

/* Search Box */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrap .search-input {
  width: 180px;
  padding: 7px 12px 7px 32px;
  border-radius: 4px;
  background: var(--bg-secondary);
  border: 1px solid transparent;
  font-size: 13px;
  transition: all var(--transition-fast);
}

.search-wrap .search-input:focus {
  width: 260px;
  border-color: var(--accent);
  background: var(--bg-primary);
}

/* Message Bell */
.msg-bell {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.msg-bell:hover { background: var(--bg-hover); }

.msg-bell .bell-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--bg-primary);
}

/* Notification Panel */
.notif-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: -20px;
  width: 300px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 250;
  animation: fadeIn 0.2s ease-out;
  overflow: hidden;
}

.notif-header {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.notif-item {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.notif-item:hover { background: var(--bg-hover); }

.notif-item strong {
  color: var(--text-primary);
  font-weight: 550;
}

/* User Menu */
.user-menu {
  position: relative;
}

/* 透明桥接——填补头像和下拉菜单之间的空隙，防止鼠标划过时菜单消失 */
.user-menu::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 14px;
  z-index: 199;
}

.user-menu .avatar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.user-menu .avatar-wrap:hover { background: var(--bg-hover); }

.user-menu .avatar-wrap .status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
}

.status-dot.online { background: var(--green); }
.status-dot.away   { background: var(--orange); }
.status-dot.busy   { background: var(--red); }

.user-menu .user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Dropdown */
.user-menu .dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
  z-index: 200;
  animation: fadeIn 0.2s ease-out;
}

.user-menu:hover .dropdown,
.user-menu .dropdown:hover {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.dropdown-item:hover { background: var(--bg-hover); }

.dropdown-item .item-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.dropdown-item.danger {
  color: var(--red);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.dropdown-item .status-toggle {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.dropdown-item .status-toggle span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.dropdown-item .status-toggle span:hover { transform: scale(1.4); }
.dropdown-item .status-toggle span.active { transform: scale(1.6); box-shadow: 0 0 0 2px currentColor; }

/* ===== Body Wrapper ===== */
.body-wrap {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===== Sidebar ===== */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  overflow: hidden;
  z-index: 90;
  flex-shrink: 0;
  position: relative;
}

#sidebar.expanded {
  width: var(--sidebar-expanded);
}

/* Sidebar Trigger Area */
#sidebar .sb-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 12px 0 8px;
  width: var(--sidebar-expanded);
}

#sidebar .sb-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 0;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 450;
}

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

.nav-item.active {
  background: var(--bg-active);
  color: var(--accent);
  font-weight: 550;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.nav-item .nav-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-label {
  opacity: 0;
  transition: opacity var(--transition);
}

#sidebar.expanded .nav-item .nav-label {
  opacity: 1;
}

.nav-item .nav-arrow {
  margin-left: auto;
  font-size: 10px;
  opacity: 0;
  transition: opacity var(--transition), transform var(--transition-fast);
}

#sidebar.expanded .nav-item .nav-arrow {
  opacity: 1;
}

.nav-item.has-sub.open .nav-arrow {
  transform: rotate(90deg);
}

/* Subnav */
.nav-sub {
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--transition);
  padding: 0 8px;
}

.nav-sub.open {
  max-height: 200px;
}

.nav-sub .nav-sub-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 36px;
  border-radius: 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition-fast);
}

#sidebar.expanded .nav-sub .nav-sub-item {
  opacity: 1;
}

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

.nav-sub-item.active {
  color: var(--accent);
  background: var(--bg-active);
}

/* Sidebar Footer */
.sb-footer {
  padding: 8px;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.sb-footer .theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
  transition: background var(--transition-fast);
  color: var(--text-secondary);
}

.sb-footer .theme-toggle:hover { background: var(--bg-hover); }

/* ===== Main Content ===== */
#main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-secondary);
  position: relative;
}

[data-theme="dark"] #main {
  background: var(--bg-secondary);
}

/* Page panels */
.page {
  display: none;
  padding: 24px 32px;
  min-height: 100%;
  animation: fadeIn 0.25s ease-out;
}

.page.active {
  display: block;
}

/* Page Header */
.page-header {
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 650;
  color: var(--text-primary);
  margin-bottom: 4px;
}

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

/* Section Title */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-top: 8px;
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
}
