/* ── 123Subscribe v2 - 样式 ────────────────────────────────── */

:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #3730a3;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-width: 260px;
  --header-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  background: var(--gray-50);
  color: var(--gray-700);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── 布局 ──────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--gray-900) 0%, #0f0f1a 100%);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand h1 {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-brand .subtitle {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 2px;
  -webkit-text-fill-color: var(--gray-400);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

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

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  padding: 0 12px;
  margin-bottom: 8px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--gray-300);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

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

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

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

.nav-item .nav-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer .status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-400);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-500);
  animation: pulse 2s infinite;
}

.status-dot.running {
  background: var(--success);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── 主内容区 ──────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

.page-header {
  background: white;
  padding: 20px 32px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
}

.page-header .header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.page-body {
  padding: 24px 32px;
}

/* ── 统计卡片 ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  transition: all 0.2s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.2;
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

.stat-card.stat-primary { border-left: 4px solid var(--primary); }
.stat-card.stat-success { border-left: 4px solid var(--success); }
.stat-card.stat-info { border-left: 4px solid var(--info); }
.stat-card.stat-warning { border-left: 4px solid var(--warning); }

/* ── 面板卡片 ──────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
}

.card-body {
  padding: 20px;
}

/* ── 按钮 ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-success:hover:not(:disabled) {
  background: #059669;
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-outline {
  background: white;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-outline:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--gray-100);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 10px 20px;
  font-size: 16px;
}

/* ── 表格 ──────────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table thead th {
  background: var(--gray-50);
  padding: 10px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

table tbody td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

table tbody tr:hover {
  background: var(--gray-50);
}

table tbody tr:last-child td {
  border-bottom: none;
}

/* ── 徽章 ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  gap: 4px;
}

.badge-success { background: var(--success-light); color: #065f46; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ── 模态框 ──────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: white;
  border-radius: var(--radius);
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.2s ease;
}

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

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.modal-close:hover { color: var(--gray-600); }

.modal-body {
  padding: 24px;
}

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

/* ── 表单 ──────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group .form-hint {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

.form-input,
.form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--gray-800);
  background: white;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.form-input::placeholder { color: var(--gray-400); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border: 2px solid var(--gray-300);
  border-radius: 4px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ── Toast 通知 ────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: white;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--gray-300);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 420px;
  animation: toastIn 0.3s ease;
  font-size: 14px;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info { border-left-color: var(--info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-message { flex: 1; }
.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 18px;
  padding: 0;
}
.toast-close:hover { color: var(--gray-600); }

/* ── 任务列表 ──────────────────────────────────────────────── */
.task-list { display: flex; flex-direction: column; gap: 8px; }

.task-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  transition: all 0.15s ease;
}

.task-item:hover {
  box-shadow: var(--shadow);
  border-color: var(--gray-300);
}

.task-item .task-toggle {
  flex-shrink: 0;
}

.task-item .task-info {
  flex: 1;
  min-width: 0;
}

.task-item .task-name {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-item .task-meta {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 2px;
}

.task-item .task-url {
  font-size: 12px;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.task-item .task-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.task-item .task-status {
  flex-shrink: 0;
  text-align: right;
  min-width: 100px;
}

/* ── 空状态 ────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.empty-state .empty-text { font-size: 16px; }
.empty-state .empty-hint { font-size: 13px; margin-top: 8px; }

/* ── 进度条 ────────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ── 标签页 ────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 24px;
  gap: 0;
}

.tab-item {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s ease;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab-item:hover { color: var(--gray-700); }
.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.page-content { display: none; }
.page-content.active { display: block; }

/* ── 登录方式切换 ────────────────────────────────────────── */
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--gray-200);
}
.auth-tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s ease;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.auth-tab:hover { color: var(--gray-700); }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.auth-panel { display: none; }
.auth-panel.active { display: block; }

/* ── 日志查看器 ────────────────────────────────────────────── */
.log-viewer {
  background: #1a1b26;
  color: #a9b1d6;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  font-size: 12px;
  line-height: 1.7;
  padding: 16px;
  border-radius: var(--radius-sm);
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-viewer .log-time { color: #565f89; }
.log-viewer .log-info { color: #7aa2f7; }
.log-viewer .log-error { color: #f7768e; }
.log-viewer .log-warning { color: #e0af68; }
.log-viewer .log-debug { color: #565f89; }
.log-viewer .log-success { color: #9ece6a; }

/* ── 响应式 ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .page-header { padding: 16px; }
  .page-body { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .task-item { flex-wrap: wrap; }
  .task-item .task-status { min-width: auto; }
  .mobile-menu-btn {
    display: flex !important;
  }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-header h2 { font-size: 18px; }
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--gray-700);
  padding: 4px;
}

/* ── 加载动画 ────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

/* ── 复制提示 ────────────────────────────────────────────── */
.copy-hint {
  font-size: 11px;
  color: var(--gray-400);
  cursor: pointer;
  margin-left: 4px;
}
.copy-hint:hover { color: var(--primary); }
