/* ============ CSS Variables ============ */
:root {
  /* 颜色系统 */
  --color-primary: #6366f1;
  --color-primary-light: #818cf8;
  --color-primary-dark: #4f46e5;
  --color-secondary: #8b5cf6;
  
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #3b82f6;
  
  /* 圆角 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  /* 侧边栏 */
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 64px;
  
  /* 动画 */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.35s ease;
  
  /* 渐变 */
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --gradient-accent: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
  --gradient-dark: linear-gradient(180deg, #1a1a2e 0%, #0f0f1a 100%);
}

/* 浅色模式 (默认) */
:root,
:root[data-theme="light"] {
  /* 背景色 */
  --bg-base: #ececee;
  --bg-surface: #f5f5f7;
  --bg-elevated: #fafafa;
  --bg-hover: #e5e5e7;
  --bg-active: #dcdcde;
  
  /* 文字色 */
  --text-primary: #1a1a1a;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --text-disabled: #a1a1aa;
  
  /* 边框 */
  --border-color: #e5e7eb;
  --border-light: #f3f4f6;
  
  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
}

/* 深色模式 */
:root[data-theme="dark"] {
  /* 背景色 */
  --bg-base: #0f0f1a;
  --bg-surface: #1a1a2e;
  --bg-elevated: #252542;
  --bg-hover: #2f2f4a;
  --bg-active: #3a3a5c;
  
  /* 文字色 */
  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-disabled: #52525b;
  
  /* 边框 */
  --border-color: #2e2e45;
  --border-light: #3f3f5a;
  
  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);
}

/* ============ Reset & Base ============ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

img {
  max-width: 100%;
  height: auto;
}

/* ============ App Layout ============ */
#app {
  display: flex;
  min-height: 100vh;
}

/* ============ Sidebar ============ */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition-normal), transform var(--transition-normal);
}

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

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .status-text {
  display: none;
}

.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-header {
  padding: 16px 12px;
  justify-content: center;
}

.sidebar.collapsed .logo {
  display: none;
}

.sidebar.collapsed .sidebar-toggle {
  width: 32px;
  height: 32px;
}

.sidebar.collapsed .sidebar-nav {
  padding: 12px 8px;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 12px;
  gap: 0;
}

.sidebar.collapsed .nav-icon {
  width: auto;
  font-size: 20px;
}

.sidebar.collapsed .sidebar-footer {
  padding: 12px 8px;
}

.sidebar.collapsed .connection-status {
  justify-content: center;
}

.sidebar-header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  min-height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon svg {
  width: 18px;
  height: 18px;
  color: white;
}

.logo-text {
  font-size: 17px;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
  position: relative;
}

.sidebar-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

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

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform var(--transition-normal);
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.nav-section {
  margin-bottom: 20px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 0 10px;
  margin-bottom: 6px;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}

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

.nav-item.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-text {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  flex: 1;
}

.nav-text-scroll {
  display: block;
  height: 18px;
  overflow: hidden;
  position: relative;
}

.nav-text-scroll .scroll-item {
  display: block;
  height: 18px;
  line-height: 18px;
  position: absolute;
  width: 100%;
  top: 0;
  left: 0;
}

.nav-text-scroll .scroll-item:first-child {
  animation: scrollTextShow 10s ease-in-out infinite;
}

.nav-text-scroll .scroll-item:last-child {
  animation: scrollTextHide 10s ease-in-out infinite;
}

@keyframes scrollTextShow {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  45% {
    transform: translateY(0);
    opacity: 1;
  }
  50% {
    transform: translateY(-100%);
    opacity: 0;
  }
  95% {
    transform: translateY(-100%);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes scrollTextHide {
  0% {
    transform: translateY(100%);
    opacity: 0;
  }
  45% {
    transform: translateY(100%);
    opacity: 0;
  }
  50% {
    transform: translateY(0);
    opacity: 1;
  }
  95% {
    transform: translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateY(100%);
    opacity: 0;
  }
}

.nav-badge {
  margin-left: auto;
  background: var(--color-primary);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.nav-badge.vip-badge {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: white;
  font-weight: 700;
  padding: 2px 8px;
  box-shadow: 0 2px 6px rgba(251, 191, 36, 0.3);
}

.nav-badge.svip-badge {
  background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
  color: white;
  font-weight: 700;
  padding: 2px 8px;
  box-shadow: 0 2px 6px rgba(139, 92, 246, 0.3);
}

.nav-badge.hot {
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  animation: pulse-hot 2s infinite;
}

@keyframes pulse-hot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.nav-item.active .nav-badge {
  background: rgba(255, 255, 255, 0.2);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-color);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.status-dot.connected {
  background: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
}

.status-dot.disconnected {
  background: var(--color-danger);
}

.status-text {
  white-space: nowrap;
  transition: opacity var(--transition-normal);
}

.version {
  font-size: 11px;
  color: var(--text-disabled);
}

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

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 50;
}

.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
}

.topbar-info {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: 1;
}

.topbar-datetime {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-time {
  font-size: 22px;
  font-weight: 600;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  color: var(--text-primary);
  letter-spacing: 1px;
}

.topbar-date {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.topbar-weather {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  font-size: 13px;
  color: var(--text-secondary);
}

.weather-icon {
  font-size: 16px;
}

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

.topbar-title {
  font-size: 18px;
  font-weight: 600;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

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

.topbar-btn svg {
  width: 20px;
  height: 20px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
}

/* Page Container */
.page-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ============ Responsive ============ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .mobile-menu-btn {
    display: flex;
  }
}

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

/* ============ Scrollbar ============ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ============ Selection ============ */
::selection {
  background: var(--color-primary);
  color: white;
}
/* ============ Modern Icon System ============ */
.section-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
  color: var(--color-primary);
}

.section-title {
  display: flex;
  align-items: center;
}

.btn svg {
  width: 14px;
  height: 14px;
  margin-right: 4px;
}

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon svg {
  width: 100%;
  height: 100%;
}

/* SVG 图标通用样式 */
.tool-icon svg,
.service-card-icon svg,
.contact-icon svg,
.resource-icon svg,
.stat-icon svg,
.banner-icon svg,
.empty-icon svg,
.engine-icon svg,
.engine-item-icon svg,
.extension-icon svg {
  width: 100%;
  height: 100%;
}

.tool-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.tool-item:hover .tool-icon {
  color: var(--color-primary);
}

.service-card-icon svg {
  width: 24px;
  height: 24px;
  color: white;
}

.service-card-icon .service-icon-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 4px;
}

.contact-icon,
.resource-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.stat-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.banner-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.empty-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.engine-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.engine-item-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
}

.extension-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.extension-stats .icon,
.extension-stats span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.extension-stats svg {
  width: 14px;
  height: 14px;
}

.promo-tips svg {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 4px;
}

.weather-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.weather-icon svg {
  width: 100%;
  height: 100%;
}

/* Toast 图标 */
.toast-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-icon svg {
  width: 100%;
  height: 100%;
}

.toast-close {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.toast-close:hover {
  opacity: 1;
}

.toast-close svg {
  width: 100%;
  height: 100%;
}

/* Section 标题中的 SVG 图标 */
.section-title svg {
  width: 20px;
  height: 20px;
  vertical-align: middle;
  margin-right: 8px;
}

/* 用户下拉菜单图标 */
.user-dropdown-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
}

.user-dropdown-icon svg {
  width: 100%;
  height: 100%;
}

/* 认证表单图标 */
.auth-input-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.auth-input-icon svg {
  width: 100%;
  height: 100%;
}

/* 关于页面 logo */
.about-logo {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.about-logo svg {
  width: 100%;
  height: 100%;
}

/* 旋转动画 */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin {
  animation: spin 1s linear infinite;
}