/* ============================================
   SubHub - Premium Light Theme v2 (Large UI)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-primary: #f5f6fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f1f8;
  --bg-input: #f4f5f9;
  --bg-modal: rgba(0, 0, 0, 0.4);
  --bg-sidebar: #1e1f2e;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.06);
  --bg-sidebar-active: rgba(99, 102, 241, 0.2);

  --border-color: #e2e4ec;
  --border-hover: #d0d3de;
  --border-active: rgba(99, 102, 241, 0.5);

  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --text-accent: #6366f1;
  --text-sidebar: #cbd5e1;
  --text-sidebar-active: #ffffff;

  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: rgba(99, 102, 241, 0.06);
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-orange: #f59e0b;
  --accent-blue: #3b82f6;
  --accent-pink: #ec4899;

  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 30px rgba(0, 0, 0, 0.1);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-full: 9999px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* ---- Login ---- */
.login-container {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
  background: #fff; border-radius: var(--radius-lg);
  padding: 52px 44px; width: 100%; max-width: 440px;
  box-shadow: var(--shadow-xl); animation: slideUp 0.5s ease;
}

.login-card .logo { text-align: center; margin-bottom: 36px; }
.login-card .logo h1 {
  font-size: 2.2rem; font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.login-card .logo p { color: var(--text-secondary); margin-top: 10px; font-size: 1rem; }

/* ---- Forms ---- */
.form-group { margin-bottom: 22px; }
.form-group label {
  display: block; font-size: 0.93rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 9px;
}

.form-input {
  width: 100%; padding: 13px 16px;
  background: var(--bg-input); border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 1rem; font-family: inherit;
  transition: all 0.15s ease; outline: none;
}

.form-input:focus {
  border-color: var(--accent); background: #fff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}
.form-input::placeholder { color: var(--text-muted); }

select.form-input {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}

textarea.form-input {
  resize: vertical; min-height: 110px;
  font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.9rem; line-height: 1.6;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 20px; font-size: 0.95rem; font-weight: 600; font-family: inherit;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  transition: all 0.15s ease; white-space: nowrap;
}

.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35); }

.btn-secondary { background: var(--bg-input); color: var(--text-primary); border: 1.5px solid var(--border-color); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }

.btn-danger { background: rgba(239, 68, 68, 0.08); color: var(--accent-red); border: 1.5px solid rgba(239, 68, 68, 0.2); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.15); }

.btn-success { background: rgba(16, 185, 129, 0.08); color: var(--accent-green); border: 1.5px solid rgba(16, 185, 129, 0.2); }
.btn-success:hover { background: rgba(16, 185, 129, 0.15); }

.btn-sm { padding: 8px 14px; font-size: 0.88rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ---- Layout ---- */
.app-container { display: none; }
.app-container.active { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px; background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-header { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.sidebar-header h1 { font-size: 1.3rem; font-weight: 800; color: #fff; }
.sidebar-header p { font-size: 0.8rem; color: rgba(255,255,255,0.4); margin-top: 5px; }

.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  color: var(--text-sidebar); cursor: pointer;
  transition: all 0.15s ease; margin-bottom: 3px; font-size: 1rem; font-weight: 500;
}
.nav-item:hover { background: var(--bg-sidebar-hover); color: #fff; }
.nav-item.active { background: var(--bg-sidebar-active); color: var(--text-sidebar-active); }
.nav-item .icon { font-size: 1.2rem; width: 24px; text-align: center; }

.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,0.06); }
.sidebar-footer .btn { color: var(--text-sidebar); background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); font-size: 0.95rem; }
.sidebar-footer .btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

.main-content { flex: 1; margin-left: 230px; min-height: 100vh; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 32px; border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 50;
}
.page-header h2 { font-size: 1.5rem; font-weight: 700; }
.page-header .actions { display: flex; gap: 10px; flex-wrap: wrap; }

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

.page-section { display: none; }
.page-section.active { display: block; animation: fadeIn 0.25s ease; }

/* ---- Stats ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }

.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 22px;
  box-shadow: var(--shadow-sm); transition: all 0.25s ease;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius-md) var(--radius-md) 0 0; opacity: 0;
  transition: opacity 0.25s ease;
}
.stat-card:nth-child(1)::after { background: var(--accent); }
.stat-card:nth-child(2)::after { background: var(--accent-green); }
.stat-card:nth-child(3)::after { background: var(--accent-blue); }
.stat-card:nth-child(4)::after { background: var(--accent-orange); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card:hover::after { opacity: 1; }
.stat-card .stat-icon { font-size: 1.6rem; margin-bottom: 12px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-card .stat-label { font-size: 0.9rem; color: var(--text-secondary); margin-top: 6px; font-weight: 500; }

/* ---- Sub Links ---- */
.sub-links-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 24px; margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.sub-links-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }

.sub-link-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border-color);
}
.sub-link-row:last-child { border-bottom: none; }
.sub-link-label { width: 140px; font-weight: 600; font-size: 0.95rem; color: var(--text-secondary); flex-shrink: 0; }
.sub-link-url {
  flex: 1; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.85rem;
  color: var(--text-muted); background: var(--bg-input); padding: 10px 14px;
  border-radius: var(--radius-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 1px solid var(--border-color);
}
.sub-link-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---- Node Cards (replacing tiny table) ---- */
.node-list { display: flex; flex-direction: column; gap: 10px; }

.node-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 18px 22px;
  box-shadow: var(--shadow-sm); transition: all 0.2s ease;
  display: flex; align-items: center; gap: 16px;
}
.node-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-md); }

.node-status { flex-shrink: 0; }
.node-status .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.node-status .dot.active { background: var(--accent-green); box-shadow: 0 0 0 3px rgba(16,185,129,0.15); }
.node-status .dot.inactive { background: var(--text-muted); }

.node-info { flex: 1; min-width: 0; }
.node-info .node-name { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.node-info .node-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.node-info .node-meta span { font-size: 0.88rem; color: var(--text-secondary); }

.type-badge {
  display: inline-flex; padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.type-badge.hy2 { background: rgba(99,102,241,0.1); color: #6366f1; }
.type-badge.vless { background: rgba(59,130,246,0.1); color: #3b82f6; }
.type-badge.vmess { background: rgba(6,182,212,0.1); color: #0891b2; }
.type-badge.trojan { background: rgba(236,72,153,0.1); color: #db2777; }
.type-badge.ss { background: rgba(245,158,11,0.1); color: #d97706; }
.type-badge.tuic { background: rgba(16,185,129,0.1); color: #059669; }

.group-badge { font-size: 0.82rem; padding: 2px 10px; border-radius: 8px; background: var(--bg-input); color: var(--text-secondary); }
.group-badge.manual { border-left: 3px solid var(--accent); }
.group-badge.sub { border-left: 3px solid var(--accent-blue); }

.node-latency { flex-shrink: 0; min-width: 80px; text-align: center; }
.latency-badge { font-size: 0.92rem; font-weight: 700; padding: 4px 12px; border-radius: 8px; display: inline-block; }
.latency-badge.fast { background: rgba(16,185,129,0.1); color: #059669; }
.latency-badge.medium { background: rgba(245,158,11,0.1); color: #d97706; }
.latency-badge.slow { background: rgba(239,68,68,0.1); color: #dc2626; }
.latency-badge.fail { background: rgba(156,163,175,0.1); color: #9ca3af; }
.latency-badge.testing { animation: pulse 1.5s infinite; background: rgba(99,102,241,0.1); color: #6366f1; }

.node-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

/* ---- Modals ---- */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: var(--bg-modal); backdrop-filter: blur(4px);
  z-index: 200; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }

.modal {
  background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  width: 100%; max-width: 640px; max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow-xl); animation: slideUp 0.3s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: 1.15rem; font-weight: 700; }
.modal-close {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: none; background: transparent;
  color: var(--text-secondary); cursor: pointer; font-size: 1.2rem;
}
.modal-close:hover { background: var(--bg-input); }
.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border-color); }

/* ---- QR Code ---- */
.qr-modal-body { text-align: center; padding: 32px; }
.qr-label { margin-top: 16px; font-size: 0.88rem; color: var(--text-secondary); word-break: break-all; padding: 12px; background: var(--bg-input); border-radius: var(--radius-sm); }

/* ---- Tabs ---- */
.tab-group { display: flex; gap: 4px; background: var(--bg-input); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 20px; }
.tab-btn {
  padding: 9px 16px; border: none; background: transparent; color: var(--text-secondary);
  font-family: inherit; font-size: 0.93rem; font-weight: 500; border-radius: 8px; cursor: pointer;
}
.tab-btn.active { background: #fff; color: var(--accent); box-shadow: var(--shadow-sm); }

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

/* ---- Sub Sources ---- */
.sub-source-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 18px 22px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-sm); transition: all 0.15s ease;
}
.sub-source-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-md); }
.sub-source-info h4 { font-size: 1.05rem; font-weight: 600; margin-bottom: 6px; }
.sub-source-info p { font-size: 0.85rem; color: var(--text-muted); font-family: 'SF Mono', monospace; word-break: break-all; }
.sub-source-meta { display: flex; gap: 16px; margin-top: 6px; }
.sub-source-meta span { font-size: 0.85rem; color: var(--text-secondary); }
.sub-source-actions { display: flex; gap: 8px; flex-shrink: 0; margin-left: 16px; }

/* ---- Toast ---- */
.toast-container { position: fixed; top: 18px; right: 18px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 13px 20px;
  border-radius: var(--radius-sm); background: #fff; border: 1px solid var(--border-color);
  color: var(--text-primary); font-size: 0.95rem; box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease; min-width: 280px;
}
.toast.success { border-left: 4px solid var(--accent-green); }
.toast.error { border-left: 4px solid var(--accent-red); }
.toast.info { border-left: 4px solid var(--accent-blue); }
.toast.fade-out { animation: slideOutRight 0.3s ease forwards; }

/* ---- Settings ---- */
.settings-section {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 24px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.settings-section h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.settings-row:last-child { border-bottom: none; }
.settings-row label { font-weight: 600; font-size: 1rem; }
.settings-row p { font-size: 0.88rem; color: var(--text-muted); margin-top: 3px; }

/* ---- Empty State ---- */
.empty-state { text-align: center; padding: 60px 24px; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 1.05rem; margin-bottom: 20px; }

/* ---- Animations ---- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(80px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(80px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-header { padding: 16px 18px; }
  .page-body { padding: 16px 18px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .sub-link-row { flex-direction: column; align-items: stretch; }
  .sub-link-label { width: auto; }
  .mobile-menu-btn { display: flex !important; }
  .node-card { flex-wrap: wrap; }
  .node-actions { width: 100%; justify-content: flex-start; }
}

.mobile-menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 38px; height: 38px; border: none; background: var(--bg-input);
  color: var(--text-primary); border-radius: var(--radius-sm); cursor: pointer; font-size: 1.2rem;
}

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--text-accent); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.hidden { display: none !important; }

/* ---- 分享节点选择列表 ---- */
.share-node-list {
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  padding: 8px; background: var(--bg-input);
}
.share-node-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  transition: background 0.1s ease;
}
.share-node-item:hover { background: rgba(99, 102, 241, 0.06); }
.share-node-item input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer;
}
.share-node-item span:nth-child(3) { flex: 1; font-weight: 500; }

