#app {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.sidebar {
  width: var(--cls-sidebar-width);
  background-color: var(--cls-color-bg-sidebar);
  color: var(--cls-color-text-white);
  display: flex;
  flex-direction: column;
  transition: width var(--cls-transition);
  overflow: hidden;
  flex-shrink: 0;
  z-index: 110;
}

.sidebar.collapsed {
  width: var(--cls-sidebar-collapsed-width);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--cls-space-base);
  height: var(--cls-header-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-title {
  font-size: var(--cls-font-size-md);
  font-weight: var(--cls-font-weight-bold);
  white-space: nowrap;
  overflow: hidden;
}

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

.sidebar-toggle {
  color: var(--cls-color-text-white);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--cls-radius-sm);
  transition: background-color var(--cls-transition-fast);
}

.sidebar-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.toggle-icon {
  display: block;
  width: 16px;
  height: 2px;
  background-color: var(--cls-color-text-white);
  position: relative;
}

.toggle-icon::before,
.toggle-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 16px;
  height: 2px;
  background-color: var(--cls-color-text-white);
}

.toggle-icon::before {
  top: -5px;
}

.toggle-icon::after {
  top: 5px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--cls-space-sm) 0;
  overflow-y: auto;
}

.sidebar-class-selector {
  padding: var(--cls-space-sm) var(--cls-space-base);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar.collapsed .sidebar-class-selector {
  display: none;
}

.class-selector-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--cls-radius-sm);
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--cls-color-text-white);
  font-size: var(--cls-font-size-sm);
  cursor: pointer;
  outline: none;
}

.class-selector-select:focus {
  border-color: var(--cls-color-primary-light);
}

.class-selector-select option {
  background-color: var(--cls-color-bg-sidebar);
  color: var(--cls-color-text-white);
}

.sidebar-footer {
  padding: var(--cls-space-sm) var(--cls-space-base);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: var(--cls-space-xs);
}

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

.network-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.network-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.network-dot.online {
  background: #4CAF50;
  box-shadow: 0 0 4px rgba(76, 175, 80, 0.5);
}

.network-dot.offline {
  background: #f44336;
  box-shadow: 0 0 4px rgba(244, 67, 54, 0.5);
}

.network-text {
  white-space: nowrap;
}

.autostart-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.autostart-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.autostart-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.autostart-checkbox {
  opacity: 0;
  width: 0;
  height: 0;
}

.autostart-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  transition: background-color 0.2s;
}

.autostart-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.autostart-checkbox:checked + .autostart-slider {
  background-color: var(--cls-color-primary, #1976D2);
}

.autostart-checkbox:checked + .autostart-slider::before {
  transform: translateX(16px);
}

.sidebar-logout-btn {
  width: 100%;
  color: rgba(255, 255, 255, 0.7);
  justify-content: center;
}

.sidebar-logout-btn:hover {
  color: #ff6b6b;
  background-color: rgba(255, 107, 107, 0.1);
}

.sidebar-download-app {
  margin-bottom: var(--cls-space-xs);
}

.sidebar-download-btn {
  width: 100%;
  background-color: var(--cls-color-primary);
  color: var(--cls-color-text-white);
  justify-content: center;
  border: none;
}

.sidebar-download-btn:hover {
  background-color: var(--cls-color-primary-dark);
}

.sidebar-class-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  margin-bottom: 8px;
}

.class-code-label {
  font-size: var(--cls-font-size-xs);
  color: rgba(255, 255, 255, 0.5);
}

.class-code-value {
  font-size: var(--cls-font-size-sm);
  font-family: monospace;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 2px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  padding: var(--cls-space-md) var(--cls-space-base);
  color: rgba(255, 255, 255, 0.7);
  transition: all var(--cls-transition-fast);
  white-space: nowrap;
  border-left: 3px solid transparent;
  font-size: var(--cls-font-size-base);
}

.nav-item:hover {
  color: var(--cls-color-text-white);
  background-color: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
  color: var(--cls-color-text-white);
  background-color: rgba(255, 255, 255, 0.12);
  border-left-color: var(--cls-color-primary-light);
}

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

.nav-text {
  margin-left: var(--cls-space-md);
  overflow: hidden;
}

.sidebar.collapsed .nav-text {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: var(--cls-space-md);
  border-left: none;
}

.sidebar.collapsed .nav-item.active {
  border-left: none;
  border-right: 3px solid var(--cls-color-primary-light);
}

/* 侧边栏分隔线 */
.nav-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 4px 12px;
}

/* 更多功能入口弱化 */
.nav-item-more {
  opacity: 0.8;
}

/* 取消固定按钮 */
.nav-unpin {
  display: none;
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 50%;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-item:hover .nav-unpin {
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-unpin:hover {
  color: #e53935;
  background: rgba(229, 57, 53, 0.2);
}

/* 侧边栏收起时隐藏取消固定按钮 */
.sidebar.collapsed .nav-unpin {
  display: none !important;
}

.content {
  flex: 1;
  overflow-y: auto;
  background-color: var(--cls-color-bg);
}

.page-container {
  max-width: var(--cls-content-max-width);
  margin: 0 auto;
  padding: var(--cls-space-lg);
  min-height: 100%;
  animation: fadeIn var(--cls-transition-slow) ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sidebar-about-link {
  display: block;
  padding: 8px 16px;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: var(--cls-font-size-sm);
  transition: color var(--cls-transition);
  cursor: pointer;
}

.sidebar-about-link:hover {
  color: rgba(255, 255, 255, 0.9);
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
  }

  .sidebar.mobile-open {
    transform: translateX(0) !important;
    width: var(--cls-sidebar-width) !important;
  }

  .sidebar.mobile-open .sidebar-title,
  .sidebar.mobile-open .sidebar-class-selector {
    display: block;
  }

  .sidebar.mobile-open .sidebar-footer {
    display: flex;
  }

  .sidebar.mobile-open .nav-text {
    display: inline;
  }

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

  .content {
    width: 100%;
  }

  .page-container {
    padding: var(--cls-space-base);
  }
}

/* ============ 底部导航栏 (移动端) ============ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--cls-bottom-nav-height);
  height: calc(var(--cls-bottom-nav-height) + var(--cls-safe-area-bottom));
  background: var(--cls-color-bg-white);
  border-top: 1px solid var(--cls-color-border);
  z-index: 120;
  padding-bottom: var(--cls-safe-area-bottom);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--cls-color-text-light);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  padding: 0;
  transition: color var(--cls-transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item.active {
  color: var(--cls-color-primary);
}

.bottom-nav-icon {
  font-size: 20px;
  line-height: 1;
}

.bottom-nav-label {
  font-size: 10px;
  line-height: 1;
}

.bottom-nav-more {
  font-family: inherit;
}

@media (max-width: 767px) {
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ============ 移动端内容区底部留白 ============ */
@media (max-width: 767px) {
  .content {
    padding-bottom: calc(var(--cls-bottom-nav-height) + var(--cls-safe-area-bottom) + var(--cls-space-base));
  }

  .mobile-menu-btn {
    z-index: 121;
  }
}
