/* ===== 盛世工具箱后台管理系统样式 ===== */
:root {
  --primary: #7B68EE;
  --primary-dark: #6955d4;
  --primary-light: #9d8ff5;
  --gradient: linear-gradient(135deg, #7B68EE 0%, #FF6B9D 100%);
  --bg: #F5F6FA;
  --card: #FFFFFF;
  --text: #333333;
  --text-secondary: #666666;
  --text-light: #999999;
  --border: #E8E8E8;
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --info: #1890ff;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --sidebar-w: 220px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ===== 登录页 ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  top: -200px; right: -200px;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  bottom: -150px; left: -100px;
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  position: relative;
  z-index: 1;
}
.login-logo {
  text-align: center;
  margin-bottom: 30px;
}
.login-logo .icon {
  font-size: 48px;
  display: block;
  margin-bottom: 10px;
}
.login-logo h1 {
  font-size: 22px;
  color: var(--text);
}
.login-logo p {
  color: var(--text-light);
  font-size: 13px;
  margin-top: 5px;
}
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 13px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

/* API 调试键值对行 */
.kv-row {
  display: flex;
  gap: 8px;
}
.kv-row input {
  flex: 1;
  min-width: 0;
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  text-decoration: none;
  text-align: center;
}
.btn-primary {
  background: var(--gradient);
  color: #fff;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-secondary {
  background: #f0f0f0;
  color: var(--text);
}
.btn-secondary:hover { background: #e0e0e0; }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { opacity: 0.9; }
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}
.btn-block {
  width: 100%;
  display: block;
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 15px;
  text-align: center;
  min-height: 20px;
}

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

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}
.sidebar-header {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.sidebar-header .logo {
  font-size: 28px;
  display: block;
  margin-bottom: 5px;
}
.sidebar-header h2 {
  font-size: 16px;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-header p {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 3px;
}
.sidebar-nav {
  flex: 1;
  padding: 15px 0;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  font-size: 14px;
}
.nav-item:hover {
  background: var(--bg);
  color: var(--primary);
}
.nav-item.active {
  background: rgba(123,104,238,0.08);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}
.nav-item .nav-icon {
  font-size: 18px;
  margin-right: 10px;
  width: 20px;
  text-align: center;
}
.sidebar-footer {
  padding: 15px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-light);
}

/* 主内容区 */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.main {
  flex: 1;
  padding: 24px;
  min-width: 0;
}

/* 移动端顶部导航栏 */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 90;
}
.mobile-header .mobile-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  text-align: center;
  padding: 0 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-header .mobile-user {
  font-size: 12px;
  color: var(--text-light);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.menu-btn:hover { background: #f5f5f5; }
.menu-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

/* 侧边栏遮罩 */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.page-header h1 {
  font-size: 22px;
  color: var(--text);
}
.page-header .actions {
  display: flex;
  gap: 10px;
}

/* 卡片 */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 统计卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
}
.stat-card .stat-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  flex-shrink: 0;
}
.stat-card .stat-info h3 {
  font-size: 26px;
  color: var(--text);
  line-height: 1.2;
}
.stat-card .stat-info p {
  font-size: 13px;
  color: var(--text-light);
}

/* 表格 */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
table th,
table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
table th {
  background: #fafafa;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
table tr:hover {
  background: #fafafa;
}
.tool-icon-cell {
  font-size: 20px;
}
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-success { background: #f6ffed; color: var(--success); border: 1px solid #b7eb8f; }
.badge-danger { background: #fff2f0; color: var(--danger); border: 1px solid #ffccc7; }
.badge-info { background: #e6f7ff; color: var(--info); border: 1px solid #91d5ff; }
.badge-warning { background: #fffbe6; color: var(--warning); border: 1px solid #ffe58f; }

/* 搜索栏 */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar input,
.toolbar select {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
.toolbar input:focus,
.toolbar select:focus {
  border-color: var(--primary);
}
.toolbar .spacer { flex: 1; }

/* 弹窗 */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 17px; }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}
.modal-body {
  padding: 24px;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 图表 */
.chart-container {
  position: relative;
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 0;
}
.chart-bar {
  flex: 1;
  background: var(--gradient);
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  position: relative;
  transition: height 0.3s;
  cursor: pointer;
}
.chart-bar:hover { opacity: 0.85; }
.chart-bar .bar-value {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-secondary);
}
.chart-labels {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.chart-labels span {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
}

/* 分页 */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}
.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.pagination button:hover { border-color: var(--primary); color: var(--primary); }
.pagination button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* 内容项 */
.content-item {
  background: #fafafa;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.content-item .item-body {
  flex: 1;
  word-break: break-all;
}
.content-item .item-body .item-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.content-item .item-body .item-content {
  color: var(--text-secondary);
  font-size: 13px;
}
.content-item .item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* 空状态 */
.empty {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}
.empty .empty-icon { font-size: 48px; margin-bottom: 10px; }

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 24px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  z-index: 2000;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* 两列布局 */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* 日志列表 */
.log-item {
  padding: 8px 0;
  border-bottom: 1px solid #f5f5f5;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.log-item:last-child { border-bottom: none; }
.log-time { color: var(--text-light); font-size: 12px; min-width: 140px; }
.log-action { font-weight: 500; color: var(--primary); min-width: 80px; }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-wrapper { margin-left: 0; }
  .main { padding: 16px; }
  .mobile-header { display: flex; }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header .actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .page-header .actions .btn {
    flex: 1;
    min-width: 120px;
  }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-icon { width: 42px; height: 42px; font-size: 20px; }
  .stat-card .stat-info h3 { font-size: 20px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 16px; }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .toolbar input,
  .toolbar select {
    width: 100%;
    min-height: 40px;
  }
  .toolbar .spacer { display: none; }

  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  table th, table td { padding: 10px 12px; font-size: 12px; }
  .tool-icon-cell { font-size: 16px; }

  .modal { margin: 16px; max-height: calc(100vh - 32px); }
  .modal-header, .modal-body, .modal-footer { padding: 16px; }
  .modal-footer {
    flex-direction: column-reverse;
    gap: 8px;
  }
  .modal-footer .btn { width: 100%; }

  .btn { padding: 12px 16px; font-size: 14px; }
  .btn-sm { padding: 8px 12px; }

  .form-group input,
  .form-group select,
  .form-group textarea {
    min-height: 44px;
    font-size: 16px;
  }

  .content-item {
    flex-direction: column;
    gap: 10px;
  }
  .content-item .item-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .chart-container { height: 160px; gap: 6px; }
  .chart-bar .bar-value { font-size: 10px; top: -16px; }
  .chart-labels span { font-size: 10px; }

  .login-card { width: calc(100% - 32px); max-width: 380px; padding: 28px; }

  .toast { left: 16px; right: 16px; top: auto; bottom: 20px; text-align: center; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 18px; }
  .card { padding: 16px; }
  .card-title { font-size: 15px; }
}
