/* ===== 全局变量 ===== */
:root {
  --bg-primary: #0f0f14;
  --bg-secondary: #1a1a24;
  --bg-tertiary: #24243a;
  --bg-card: #1e1e30;
  --border: #2a2a40;
  --text-primary: #e8e8f0;
  --text-secondary: #9494b8;
  --text-muted: #5c5c80;
  --accent: #4f6ef7;
  --accent-hover: #6585ff;
  --danger: #e74c3c;
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-width: 260px;
  --toolbar-height: 44px;
  --transition: 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ===== 重置 ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

/* ===== 左侧边栏 ===== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.app-logo-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

/* ===== 用户栏 ===== */
.user-bar {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.user-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-name {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-text:hover {
  color: var(--danger);
  background: rgba(231, 76, 60, 0.1);
}

/* ===== 平台筛选 ===== */
.platform-filter {
  padding: 8px 12px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.filter-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

/* ===== 账号列表 ===== */
.account-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 20px;
}

.account-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
  position: relative;
}

.account-item:hover { background: var(--bg-tertiary); }
.account-item.active { background: rgba(79, 110, 247, 0.12); border: 1px solid rgba(79, 110, 247, 0.25); padding: 7px 9px; }
.account-item.active:hover { background: rgba(79, 110, 247, 0.18); }

.account-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  position: relative;
}

.platform-badge {
  position: absolute;
  bottom: -3px; right: -3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  font-size: 7px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  border: 2px solid var(--bg-secondary);
}

.badge-wechat_mp { background: #07c160; }
.badge-wechat_channels { background: #fa9d3b; }
.badge-douyin { background: #111; }
.badge-xiaohongshu { background: #ff2442; }

.account-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.account-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-platform {
  font-size: 10px;
  color: var(--text-muted);
}

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

.account-status.online { background: #10b981; }

/* ===== 顶部工具栏 ===== */
.top-toolbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--toolbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  z-index: 20;
}

.toolbar-left { display: flex; align-items: center; gap: 8px; }
.toolbar-center { flex: 1; display: flex; align-items: center; gap: 8px; }
.toolbar-right { display: flex; align-items: center; gap: 4px; }

.current-platform-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  white-space: nowrap;
}

.current-account-name {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.badge-wx { background: #07c160; }
.badge-wx-channels { background: #fa9d3b; }
.badge-dy { background: #000; border: 1px solid #333; }
.badge-xhs { background: #ff2442; }

.url-bar {
  flex: 1;
  height: 28px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  display: flex;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
}

.nav-btn, .btn-icon {
  width: 28px; height: 28px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.nav-btn:hover, .btn-icon:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-btn.disabled { opacity: 0.3; pointer-events: none; }

/* ===== 主内容区 ===== */
.main-content {
  flex: 1;
  margin-top: var(--toolbar-height);
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* ===== 欢迎页 ===== */
.welcome-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 5;
}

.welcome-inner {
  text-align: center;
  max-width: 400px;
}

.welcome-logo-wrap {
  width: 64px; height: 64px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-inner h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.welcome-inner p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

.welcome-platforms {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 28px;
}

.wp-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.wp-avatar {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: white;
}

.wp-avatar.wechat_mp { background: #07c160; }
.wp-avatar.wechat_channels { background: #fa9d3b; }
.wp-avatar.douyin { background: #111; border: 2px solid #333; }
.wp-avatar.xiaohongshu { background: #ff2442; }

.wp-item span {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover { background: var(--bg-card); }

/* ===== iframe 容器 ===== */
.iframe-container {
  position: absolute;
  inset: 0;
  display: flex;
}

.iframe-wrapper {
  flex: 1;
  position: relative;
  background: var(--bg-primary);
}

.iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

/* 加载遮罩 */
.webview-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 5;
  gap: 12px;
  pointer-events: none;
}

.loading-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.modal {
  width: 380px;
  max-width: 90vw;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.modal-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body { padding: 16px 20px; }
.modal-footer {
  padding: 12px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

.form-group input:focus { border-color: var(--accent); }

.platform-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.platform-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 12px;
  color: var(--text-secondary);
}

.platform-option:hover { border-color: var(--accent); }
.platform-option.active { border-color: var(--accent); background: rgba(79, 110, 247, 0.1); }

.platform-option .p-icon {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.platform-option[data-value="wechat_mp"] .p-icon { background: #07c160; }
.platform-option[data-value="wechat_channels"] .p-icon { background: #fa9d3b; }
.platform-option[data-value="douyin"] .p-icon { background: #111; border: 1px solid #333; }
.platform-option[data-value="xiaohongshu"] .p-icon { background: #ff2442; }

.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}

.color-dot:hover { transform: scale(1.1); border-color: var(--text-muted); }
.color-dot.active { border-color: white; box-shadow: 0 0 0 2px var(--accent); }

/* ===== 右键菜单 ===== */
.context-menu {
  position: fixed;
  z-index: 200;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 0;
  min-width: 160px;
  display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.context-menu.show { display: block; }

.context-item {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s;
}

.context-item:hover { background: var(--bg-tertiary); }
.context-item.danger { color: var(--danger); }
.context-item.danger:hover { background: rgba(231,76,60,0.1); }

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

/* ===== 登录页面 ===== */
.login-page {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}

.login-card {
  width: 360px;
  max-width: 90vw;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 28px 28px;
}

.login-logo { text-align: center; margin-bottom: 24px; }

.login-logo-icon {
  width: 48px; height: 48px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-logo h1 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-logo p {
  font-size: 12px;
  color: var(--text-muted);
}

.login-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.login-tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}

.login-tab:hover { color: var(--text-primary); }
.login-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.login-form .form-group { margin-bottom: 14px; }

.login-form .form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.login-form .form-group input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}

.login-form .form-group input:focus { border-color: var(--accent); }

.login-error {
  color: var(--danger);
  font-size: 12px;
  min-height: 20px;
  margin-bottom: 8px;
}

.btn-login {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-login:hover { background: var(--accent-hover); }
.btn-login:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar { width: 200px; min-width: 200px; }
  :root { --sidebar-width: 200px; }
}
