/* ============================================================
   YSearch 管理后台样式
   ============================================================ */

.admin-body { background: var(--bg); }
.admin-layout { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.admin-sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none !important;
}
.admin-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.admin-brand-text strong { color: var(--text); font-size: 16px; }
.admin-brand-text small { color: var(--text-3); font-size: 11.5px; }

.admin-nav { flex: 1; padding: 12px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  transition: all .15s ease;
}
.admin-nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.admin-nav-item.active { background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(99, 102, 241, .3); }
.nav-icon { width: 20px; text-align: center; font-size: 15px; }

.admin-sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-user { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.admin-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.admin-user-info { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.admin-user-info strong { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.admin-user-info small { font-size: 11px; color: var(--text-3); }
.admin-logout {
  width: 34px; height: 34px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 16px;
  border: 1px solid var(--border);
  transition: all .15s;
}
.admin-logout:hover { color: #ef4444; border-color: #ef4444; background: rgba(239, 68, 68, .08); text-decoration: none; }

/* ---------- 主区 ---------- */
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 30;
}
.admin-page-title { font-size: 19px; font-weight: 700; }
.admin-topbar-right { display: flex; align-items: center; gap: 10px; }

.flash {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  animation: rise .3s ease both;
}
.flash-success { background: rgba(34, 197, 94, .14); color: #16a34a; }
[data-theme="dark"] .flash-success { color: #4ade80; }
.flash-error { background: rgba(239, 68, 68, .14); color: #dc2626; }
[data-theme="dark"] .flash-error { color: #f87171; }
.flash-info { background: var(--primary-soft); color: var(--primary-strong); }

.admin-content { padding: 24px 28px 40px; flex: 1; }
.admin-footer {
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
}

/* ---------- 统计卡片 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-num { font-size: 27px; font-weight: 800; letter-spacing: -.5px; }
.stat-card .stat-label { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.stat-card.grad-1 .stat-num { background: linear-gradient(135deg, #6366f1, #8b5cf6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-card.grad-2 .stat-num { background: linear-gradient(135deg, #0ea5e9, #6366f1); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-card.grad-3 .stat-num { background: linear-gradient(135deg, #10b981, #0ea5e9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-card.grad-4 .stat-num { background: linear-gradient(135deg, #f59e0b, #ef4444); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- 面板 ---------- */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.panel-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.panel-sub { font-size: 12.5px; color: var(--text-3); margin-bottom: 16px; }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.admin-table th {
  text-align: left;
  padding: 11px 14px;
  background: var(--bg-hover);
  color: var(--text-2);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.admin-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr { transition: background .12s; }
.admin-table tbody tr:hover { background: var(--bg-hover); }
.td-title { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-title a { color: var(--text); font-weight: 500; }
.td-title a:hover { color: var(--primary-strong); }
.td-url { color: var(--text-3); font-family: var(--mono); font-size: 12px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green { background: rgba(34, 197, 94, .13); color: #16a34a; }
.badge-amber { background: rgba(245, 158, 11, .15); color: #d97706; }
.badge-red { background: rgba(239, 68, 68, .13); color: #dc2626; }
.badge-blue { background: var(--primary-soft); color: var(--primary-strong); }
.badge-gray { background: var(--bg-hover); color: var(--text-3); }
[data-theme="dark"] .badge-green { color: #4ade80; }
[data-theme="dark"] .badge-amber { color: #fbbf24; }
[data-theme="dark"] .badge-red { color: #f87171; }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.form-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.form-control { resize: vertical; min-height: 90px; line-height: 1.5; font-family: var(--mono); font-size: 13px; }
select.form-control { appearance: auto; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }

/* 开关 */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 42px; height: 24px;
  background: var(--border-strong);
  border-radius: 999px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch .switch-label { font-size: 13.5px; color: var(--text-2); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none !important;
}
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 3px 10px rgba(99, 102, 241, .28); }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card); color: var(--text-2); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary-strong); }
.btn-danger { background: rgba(239, 68, 68, .1); color: #dc2626; border-color: rgba(239, 68, 68, .3); }
.btn-danger:hover { background: #ef4444; color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

/* ---------- 仪表盘图表 ---------- */
.chart-card { margin-bottom: 20px; }
.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 10px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart-bar-wrap { width: 100%; height: 120px; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar {
  width: min(70%, 42px);
  border-radius: 7px 7px 3px 3px;
  background: var(--grad);
  opacity: .85;
  min-height: 3px;
  transition: opacity .15s, filter .15s;
  position: relative;
}
.chart-bar:hover { opacity: 1; filter: brightness(1.1); }
.chart-bar:hover::after {
  content: attr(data-count);
  position: absolute;
  top: -24px; left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg-card);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 5;
}
.chart-col-label { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.chart-col-count { font-size: 11px; font-weight: 700; color: var(--text-2); }
.chart-empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 40px 0; }

/* 双栏 */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

/* 日志行 */
.log-list { list-style: none; max-height: 300px; overflow-y: auto; }
.log-list li {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
  align-items: baseline;
}
.log-list li:last-child { border-bottom: none; }
.log-time { color: var(--text-3); font-family: var(--mono); font-size: 11.5px; flex-shrink: 0; }
.log-msg { color: var(--text-2); word-break: break-all; }
.log-level { flex-shrink: 0; font-size: 11px; font-weight: 700; width: 44px; }
.log-level.info { color: #0ea5e9; }
.log-level.warn { color: #f59e0b; }
.log-level.error { color: #ef4444; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(600px 300px at 20% 10%, rgba(99,102,241,.16), transparent 60%),
    radial-gradient(600px 300px at 80% 90%, rgba(139,92,246,.14), transparent 60%),
    var(--bg);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 34px;
  box-shadow: var(--shadow-lg);
  animation: rise .45s ease both;
}
.login-logo { text-align: center; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 21px; font-weight: 800; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--text-3); font-size: 13px; margin-bottom: 26px; }
.login-error {
  background: rgba(239, 68, 68, .1);
  color: #dc2626;
  font-size: 13px;
  padding: 9px 13px;
  border-radius: 9px;
  margin-bottom: 16px;
}
[data-theme="dark"] .login-error { color: #f87171; }
.login-tip {
  margin-top: 18px;
  padding: 10px 13px;
  background: var(--primary-soft);
  border-radius: 9px;
  font-size: 12.5px;
  color: var(--primary-strong);
  line-height: 1.6;
}
.login-tip code { background: rgba(255,255,255,.4); }
[data-theme="dark"] .login-tip code { background: rgba(0,0,0,.25); }

/* ---------- 进度条 ---------- */
.progress-wrap { display: none; margin-bottom: 16px; }
.progress-track { height: 8px; background: var(--bg-hover); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--grad); border-radius: 999px; transition: width .3s ease; }
.progress-text { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }

/* ---------- 队列状态卡 ---------- */
.queue-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.queue-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-align: center;
}
.queue-item .q-num { font-size: 22px; font-weight: 800; }
.queue-item .q-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.queue-item.pending .q-num { color: #0ea5e9; }
.queue-item.done .q-num { color: #16a34a; }
.queue-item.failed .q-num { color: #ef4444; }
.queue-item.total .q-num { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

@media (max-width: 900px) {
  .admin-sidebar { width: 64px; }
  .admin-brand-text, .admin-nav-item span:not(.nav-icon), .admin-user-info { display: none; }
  .admin-nav-item { justify-content: center; }
  .admin-content, .admin-topbar { padding-left: 18px; padding-right: 18px; }
  .queue-grid { grid-template-columns: repeat(2, 1fr); }
}
