/* ============================================================
   Admin Dashboard Stylesheet
   ------------------------------------------------------------
   现代后台管理样式：布局 / 登录页 / 卡片 / 表格 / 表单 / 按钮
   / 徽章 / toast / 响应式
   ============================================================ */

:root {
  /* 色彩变量 */
  --sidebar-bg: #1e293b;
  --sidebar-text: #e2e8f0;
  --sidebar-text-dim: #94a3b8;
  --sidebar-hover: #334155;
  --sidebar-active: #0f766e;
  --topbar-bg: #ffffff;
  --body-bg: #f1f5f9;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;

  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;

  /* 布局变量 */
  --sidebar-width: 220px;
  --topbar-height: 56px;
  --radius: 12px;

  /* 字体 */
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New",
    monospace;
}

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

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-main);
  background: var(--body-bg);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
}

/* ============================================================
   布局：侧边栏
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  list-style: none;
}

.sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: var(--sidebar-text-dim);
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-menu li a:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.sidebar-menu li a.active {
  background: var(--sidebar-active);
  color: #ffffff;
  border-left-color: #ffffff;
}

.sidebar-footer {
  padding: 14px 20px;
  font-size: 12px;
  color: var(--sidebar-text-dim);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ============================================================
   布局：顶栏
   ============================================================ */
.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--sidebar-width);
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 99;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  font-size: 14px;
}

.topbar-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

/* 菜单切换按钮（移动端显示） */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-main);
  line-height: 1;
}

/* ============================================================
   布局：主内容区
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  padding: calc(var(--topbar-height) + 24px) 24px 24px;
  min-height: 100vh;
}

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

.login-card {
  background: #fff;
  width: 100%;
  max-width: 380px;
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.login-card .login-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
}

.login-card .login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
}

.login-card .form-group {
  margin-bottom: 16px;
}

.login-card .btn-primary {
  width: 100%;
  margin-top: 8px;
}

/* ============================================================
   卡片组件
   ============================================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ============================================================
   表格
   ============================================================ */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.table th,
.table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

.table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.table tbody tr:hover {
  background: #f1f5f9;
}

/* 等宽字体用于订单号、金额等机器数据 */
.table td.mono,
.table .mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.table-actions {
  white-space: nowrap;
}

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

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

.form-group .form-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-main);
  color: var(--text-main);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
  margin-right: 6px;
  vertical-align: middle;
}

/* 行内搜索 /筛选条 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.filter-bar input,
.filter-bar select {
  width: auto;
  min-width: 160px;
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease,
    opacity 0.15s ease;
  line-height: 1.4;
  text-decoration: none;
  vertical-align: middle;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

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

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
  background: #15803d;
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.btn-outline:hover:not(:disabled) {
  background: #f1f5f9;
}

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

/* ============================================================
   徽章（状态色）
   ============================================================ */
.badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-success {
  background: #dcfce7;
  color: #15803d;
}

.badge-paying,
.badge-pay {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-created {
  background: #f1f5f9;
  color: #475569;
}

.badge-failed {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-closed {
  background: #ffedd5;
  color: #c2410c;
}

/* ============================================================
   Toast 提示
   ============================================================ */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  min-width: 220px;
  max-width: 340px;
  padding: 11px 16px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

/* toast 颜色由 JS 内联 style 覆盖，此处提供默认/兜底色 */
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--primary); }

/* ============================================================
   分页工具条
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: #fff;
  color: var(--text-main);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.pagination a:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.pagination .current {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pagination .disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ============================================================
   响应式：<900px 侧边栏收起为顶部菜单
   ============================================================ */
@media (max-width: 899px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topbar {
    left: 0;
    padding: 0 16px;
  }

  .menu-toggle {
    display: inline-block;
  }

  .main-content {
    margin-left: 0;
    padding: calc(var(--topbar-height) + 16px) 16px 16px;
  }

  /* 遮罩层，点开侧边栏时铺满 */
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
    display: none;
  }

  .sidebar-backdrop.show {
    display: block;
  }

  .filter-bar input,
  .filter-bar select {
    flex: 1;
    min-width: 120px;
  }
}