/* ==================================================
   admin.css — 后台管理页面样式
   复用 toolbox.css 的配色和风格
   ================================================== */

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

:root {
  --primary:        #4e9af1;
  --primary-light:  rgba(78,154,241,0.15);
  --sidebar-bg:     #1a2b4a;
  --sidebar-bg2:    #1b3462;
  --sidebar-active: #2a4a80;
  --sidebar-hover:  rgba(255,255,255,0.07);
  --sidebar-border: rgba(255,255,255,0.08);
  --sidebar-text:   rgba(255,255,255,0.75);
  --sidebar-text-a: #ffffff;
  --sidebar-label:  rgba(255,255,255,0.35);
  --text1:          #1a2540;
  --text2:          #4a5578;
  --text3:          #8e99b5;
  --bg:             #eef1f8;
  --white:          #ffffff;
  --danger:         #e84d4d;
  --success:        #22c55e;
  --warning:        #f59e0b;
  --info:           #3b82f6;
  --border:         1px solid #dde3ef;
  --radius:          8px;
  --shadow:         0 2px 12px rgba(0,0,0,0.10);
  --sidebar-w:      220px;
  --header-h:       60px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--text1);
  background: var(--bg);
  min-height: 100vh;
}

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

/* ===== 侧边栏 ===== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: width 0.25s;
  overflow: hidden;
}
.sidebar.collapsed { width: 60px; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99; }
.sidebar-overlay.open { display: block; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: 64px;
}
.logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; flex-shrink: 0;
}
.sidebar-title { flex: 1; overflow: hidden; }
.logo-name { color: var(--sidebar-text-a); font-size: 15px; font-weight: 700; white-space: nowrap; }
.logo-sub { color: var(--sidebar-label); font-size: 11px; margin-top: 2px; white-space: nowrap; }
.sidebar-toggle {
  background: none; border: none; color: var(--sidebar-text);
  font-size: 16px; cursor: pointer; padding: 4px;
}
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .logo-sub,
.sidebar.collapsed .nav-text { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 18px 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .sidebar-foot-link { justify-content: center; padding: 10px 0; }

.nav-scroll { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-scroll::-webkit-scrollbar { width: 4px; }
.nav-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.nav-section { padding: 0 8px; margin-bottom: 4px; }
.nav-label {
  font-size: 13px; font-weight: 700; color: var(--sidebar-label);
  letter-spacing: 1px; padding: 0 10px; margin-bottom: 6px; margin-top: 12px;
  cursor: pointer; display: flex; align-items: center; justify-content: space-between;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin: 2px 0;
  border-radius: 6px; cursor: pointer;
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
  transition: all 0.15s; white-space: nowrap;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-a); }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-a); }
.nav-item i.fas { width: 20px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-text { overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 8px;
}
.sidebar-foot-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  color: var(--sidebar-text);
  font-size: 13.5px; font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
}
.sidebar-foot-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-a); }
.sidebar-foot-link i.fas { width: 20px; text-align: center; font-size: 15px; }

/* ===== 主内容 ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s;
}
.sidebar.collapsed ~ .main-content { margin-left: 60px; }

/* ===== 顶部栏 ===== */
.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.menu-toggle {
  display: none;
  background: none; border: none;
  font-size: 18px; color: var(--text2); cursor: pointer;
}
.breadcrumb { display: flex; align-items: center; gap: 8px; flex: 1; }
.bread-icon { color: var(--primary); font-size: 16px; }
.bread-main { font-size: 15px; font-weight: 700; color: var(--text1); }

/* topbar 右侧按钮组 */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s;
}
.topbar-btn--primary {
  background: var(--primary);
  color: #fff;
}
.topbar-btn--primary:hover { background: #2d7dd2; color: #fff; }
.topbar-btn--home {
  background: #f0f0f0;
  color: var(--text2);
}
.topbar-btn--home:hover { background: #e2e8f0; color: var(--text1); }
.topbar-btn--icon {
  background: #f8fafc;
  color: var(--text2);
  border: 1px solid #cbd5e1;
}
.topbar-btn--icon:hover { background: #f1f5f9; color: var(--primary); border-color: var(--primary); }
.bread-sub { font-size: 12px; color: var(--text3); }

/* ===== 页面容器 ===== */
.page-wrap { padding: 24px; flex: 1; }

/* 两个页面的 page-header 统一：筛选条 + 搜索框强制一行 */
#page-dashboard .page-header,
#page-tools .page-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 24px; flex-wrap: nowrap;
}

/* ===== 搜索框 ===== */
.search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--white); border: var(--border); border-radius: 6px;
  padding: 0 12px; width: 200px; flex-shrink: 0;
  margin-left: auto;
}
.search-wrap i { color: var(--text3); font-size: 13px; flex-shrink: 0; }
.search-wrap input {
  border: none; outline: none; padding: 9px 8px;
  font-size: 13px; width: 100%; background: transparent; color: var(--text1);
}

/* ===== 筛选选项卡 ===== */
.filter-bar {
  display: flex; align-items: center; gap: 5px;
  flex-wrap: nowrap; min-width: 0; overflow-x: auto;
  flex: 1; padding-bottom: 4px;
}
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; background: var(--white); color: var(--text2);
  border: 1px solid #dde3ef; transition: all 0.15s;
  white-space: nowrap; user-select: none; flex-shrink: 0;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.filter-chip .dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
}

/* ===== 统计卡片网格 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

/* 数据看板主容器：取消 grid，让内部各自布局正常工作 */
#stats-grid {
  display: block;
}

/* 第一行大卡片 */
.stats-row-top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 32px;
}
.stats-row-top > .stat-card-lg {
  flex: 2 1 220px;
  min-width: 200px;
}
.stats-row-top > .stat-card:not(.stat-card-lg) {
  flex: 1 1 150px;
  min-width: 140px;
}
.stat-card-lg {
  padding: 24px 28px;
}
.stat-card-lg .stat-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  font-size: 24px;
}
.stat-card-lg .stat-num {
  font-size: 32px;
}

/* 分类统计标题 */
.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text1);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.15s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--stat-color, var(--primary)) 10%, transparent);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--stat-color, var(--primary));
  flex-shrink: 0;
}
.stat-info { display: flex; flex-direction: column; gap: 2px; }
.stat-num {
  font-size: 26px; font-weight: 800;
  color: var(--text1);
  line-height: 1.2;
}
.stat-label { font-size: 13px; color: var(--text3); }

/* ===== 分类折叠区 ===== */
.category-sections { display: flex; flex-direction: column; gap: 12px; }
.cat-section {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--text1);
  border-bottom: 1px solid #f0f0f0;
  user-select: none;
}
.cat-header:hover { background: #f8fafc; }
.cat-toggle { font-size: 12px; color: var(--text3); transition: transform 0.2s; }
.cat-header.collapsed .cat-toggle { transform: rotate(-90deg); }
.cat-body { padding: 8px 12px; }
.cat-body.collapsed { display: none; }
.cat-count { font-size: 12px; color: var(--text3); font-weight: 400; }

.cat-tool-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  transition: background 0.1s;
}
.cat-tool-item:hover { background: #f8fafc; }
.cat-tool-icon {
  width: 32px; height: 32px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.cat-tool-name { font-size: 13.5px; font-weight: 600; color: var(--text1); flex: 1; }
.cat-tool-visits { font-size: 12px; color: #25c55a; font-weight: 600; white-space: nowrap; }
.cat-tool-weight { font-size: 12px; color: var(--primary); font-weight: 600; white-space: nowrap; }
.cat-tool-url { font-size: 12px; color: var(--text3); font-family: monospace; }

/* ===== 工具标签 ===== */
.cat-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

/* ===== Badge ===== */
.tool-badge { font-size: 11px; padding: 1px 6px; border-radius: 3px; margin-left: 6px; font-weight: 600; }
.badge-free { background: #dcfce7; color: #16a34a; }
.badge-new  { background: #dbeafe; color: #2563eb; }
.badge-hot  { background: #fee2e2; color: #dc2626; }
.badge-beta { background: #fef3c7; color: #d97706; }

/* ===== 表格 ===== */
.table-wrap {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  background: #f8fafc;
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--text2);
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}
.admin-table td {
  padding: 10px 16px;
  border-bottom: 1px solid #f0f0f0;
  color: var(--text1);
  vertical-align: middle;
}
.admin-table tr:hover td { background: #f8fafc; }
.admin-table a { color: var(--primary); text-decoration: none; font-size: 12px; }
.admin-table a:hover { text-decoration: underline; }
/* 操作列：确保按钮并排不换行 */
.admin-table th:last-child,
.admin-table td:last-child {
  white-space: nowrap;
  min-width: 140px;
  text-align: center;
}
.color-dot {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 6px;
}

/* ===== 英文标注 ===== */
.cell-en {
  font-size: 11px;
  color: var(--text3);
  font-family: 'SF Mono', 'Consolas', monospace;
  margin-left: 3px;
  font-weight: 500;
}

/* ===== 操作按钮 ===== */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  margin-right: 6px;
  line-height: 1.4;
}
.btn-action:last-child { margin-right: 0; }
.btn-action i { font-size: 11px; }
.btn-preview {
  background: #e0f2fe;
  color: #0284c7;
}
.btn-preview:hover { background: #0284c7; color: #fff; }
.btn-edit {
  background: #fef3c7;
  color: #d97706;
}
.btn-edit:hover { background: #f59e0b; color: #fff; }
.btn-delete {
  background: #fee2e2;
  color: #dc2626;
}
.btn-delete:hover { background: #e84d4d; color: #fff; }

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 10px;
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  animation: modalIn 0.2s;
}
@keyframes modalIn { from { opacity:0; transform: translateY(-16px); } to { opacity:1; transform:none; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}
.modal-header h2 { font-size: 16px; font-weight: 700; color: var(--text1); }
.modal-header h2 i { color: var(--primary); margin-right: 8px; }
.modal-close {
  background: none; border: none;
  font-size: 22px; color: var(--text3);
  cursor: pointer; line-height: 1; padding: 0 4px;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px; }
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 12.5px; font-weight: 600;
  color: var(--text2);
  margin-bottom: 5px;
}
.form-row input[type="text"],
.form-row select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dde3ef;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text1);
  background: #f8fafc;
  outline: none;
  transition: border-color 0.15s;
}
.form-row input:focus,
.form-row select:focus { border-color: var(--primary); background: #fff; }
.form-row select { cursor: pointer; }

/* 颜色、图标等需并排的输入组 */
.form-row .input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-row .input-group input[type="text"] {
  width: auto;
  flex: 1;
}
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
}
.btn-modal {
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-cancel { background: #f0f0f0; color: var(--text2); }
.btn-cancel:hover { background: #e2e8f0; }
.btn-save { background: var(--primary); color: #fff; }
.btn-save:hover { background: #2d7dd2; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #2d7dd2; }

/* ===== 导出悬浮按钮 ===== */
.export-fab {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 16px rgba(78,154,241,0.4);
  cursor: pointer;
  z-index: 999;
  transition: transform 0.15s, box-shadow 0.15s;
}
.export-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(78,154,241,0.5); }

/* ===== Toast 提示 ===== */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 20px;
  border-radius: 8px;
  background: #1a2b4a;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: toastIn 0.25s ease-out;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  min-width: 240px;
  max-width: 400px;
  border-left: 4px solid var(--success, #22c55e);
}
.toast.out {
  animation: toastOut 0.3s ease-in forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(60px); }
}

/* ===== 图标选择器 ===== */
.icon-picker-btn {
  width: 32px; height: 32px;
  border: 1px solid #dde3ef;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
}
.icon-picker-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.icon-picker-panel {
  margin-top: 8px;
  border: 1px solid #dde3ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  max-height: 220px;
  overflow-y: auto;
  display: none;
}
.icon-picker-panel.active { display: block; }

.icon-picker-search {
  padding: 8px 10px;
  border-bottom: 1px solid #f0f0f0;
  display: flex; align-items: center; gap: 6px;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.icon-picker-search i { color: var(--text3); font-size: 12px; }
.icon-picker-search input {
  border: none; outline: none; font-size: 12px; flex: 1; background: transparent;
  color: var(--text1);
}

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 4px;
  padding: 8px;
}
.icon-picker-item {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text2);
  transition: all 0.1s;
  border: 1px solid transparent;
}
.icon-picker-item:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.icon-picker-item.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== 参数管理页面 ===== */
.params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 24px;
}
.params-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.params-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
}
.params-card-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text1);
  display: flex;
  align-items: center;
  gap: 8px;
}
.params-card-header h3 i { color: var(--primary); font-size: 16px; }

.params-list { padding: 8px; }
.params-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  transition: background 0.1s;
}
.params-item:hover { background: #f8fafc; }
.params-color {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}
.params-item > i.fas {
  font-size: 14px;
  color: var(--text2);
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.params-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text1);
  flex: 1;
}
.params-key {
  font-size: 12px;
  color: var(--text3);
  font-family: 'SF Mono', 'Consolas', monospace;
}
.params-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}
.params-item:hover .params-actions { opacity: 1; }
.params-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

/* 表单提示 */
.form-hint {
  display: block;
  font-size: 11.5px;
  color: var(--text3);
  margin-top: 4px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { transform: translateX(-100%); }
  .sidebar.collapsed.open { transform: translateX(0); width: var(--sidebar-w); }
  .main-content { margin-left: 0 !important; }
  .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .stats-row-top { flex-direction: column; }
}
