/* ========== 游戏配置后台 - 管理端主题 ========== */
:root {
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-soft: #3b82f6;
  --success: #22c55e;
  --danger: #ef4444;
  --text-main: #111827;
  --text-muted: #6b7280;
  --bg-body: #f3f4f6;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --card-radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  font-size: 14px;
}

a { text-decoration: none; }

/* ========== 布局：侧边栏 + 内容区 ========== */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background-color: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

/* Logo 区 */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  color: #ffffff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo .logo-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand-soft), var(--brand));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

/* 侧边栏菜单 */
.sidebar-menu {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-section-label {
  font-size: 11px;
  color: rgba(148, 163, 184, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 8px 10px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  transition: background-color 0.15s, color 0.15s;
}

.sidebar-link .side-icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.sidebar-link:hover {
  color: #e2e8f0;
  background-color: rgba(255, 255, 255, 0.06);
}

.sidebar-link.active {
  background-color: var(--brand);
  color: #ffffff;
  font-weight: 500;
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ========== 内容区 ========== */
.main {
  flex: 1;
  padding: 28px 32px;
  background-color: var(--bg-body);
  min-width: 0;
}

/* 面包屑 */
.breadcrumb-nav {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb-nav a { color: var(--text-muted); }
.breadcrumb-nav a:hover { color: var(--brand); }
.breadcrumb-nav .sep { color: #d1d5db; }
.breadcrumb-nav .current { color: var(--text-main); }

/* 页面大标题 */
.page-header {
  margin-bottom: 22px;
}

.page-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
}

.page-header .page-sub {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 13px;
}

.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}

/* ========== 卡片容器 ========== */
.admin-card {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  padding: 8px;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  color: var(--text-main);
  background: transparent;
}

.btn-primary {
  background-color: var(--brand);
  color: #fff;
}
.btn-primary:hover { background-color: var(--brand-strong); }

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

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

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

.btn-secondary {
  background-color: #e5e7eb;
  color: var(--text-main);
}
.btn-secondary:hover { background-color: #d1d5db; }

.btn-outline-secondary {
  border-color: #9ca3af;
  color: #4b5563;
}
.btn-outline-secondary:hover { background-color: #f3f4f6; color: var(--text-main); }
.btn-outline-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline-success {
  border-color: #16a34a;
  color: #15803d;
}
.btn-outline-success:hover { background-color: #16a34a; color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn .btn-icon { font-size: 15px; }

/* ========== 表格 ========== */
.admin-table-wrap { padding: 8px; }

.table {
  width: 100%;
  border-collapse: collapse;
  background-color: #fff;
}

.table thead th {
  background-color: #f9fafb;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: none;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #f3f4f6;
  color: var(--text-main);
  vertical-align: middle;
}

.table tbody tr {
  transition: background-color 0.12s;
}
.table tbody tr:hover { background-color: #f9fafb; }
.table tbody tr:last-child td { border-bottom: none; }

.table .empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 28px 14px;
}

.table code, .code {
  background-color: #f1f5f9;
  color: #334155;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ========== 徽章 ========== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}
.badge-success { background-color: #dcfce7; color: #15803d; }
.badge-danger  { background-color: #fecaca; color: #b91c1c; }
.badge-info    { background-color: #dbeafe; color: #1d4ed8; }
.badge-secondary { background-color: #e5e7eb; color: #374151; }
.badge-primary { background-color: #dbeafe; color: #1d4ed8; }

/* ========== 表单 ========== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
}
.form-label .hint { color: var(--text-muted); font-weight: 400; font-size: 12px; }

.form-control, .form-input, .form-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  background-color: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.form-control::placeholder { color: #9ca3af; }
.form-select { padding-right: 12px; }
.form-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ========== 弹窗 (modal) ========== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1050;
  overflow-y: auto;
  background-color: rgba(15, 23, 42, 0.5);
}
.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop { display: none; }
.modal-dialog {
  position: relative;
  width: 480px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.modal-close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-close:hover { color: var(--text-main); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-dialog.modal-wide { width: 720px; max-width: calc(100vw - 48px); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

/* ========== 提示框 alert ========== */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-danger { background-color: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background-color: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-info { background-color: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ========== 登录页 ========== */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #2563eb 140%);
}
.login-card {
  width: 400px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  padding: 36px 36px 32px;
}
.login-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-soft), var(--brand));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
}
.login-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}
.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 26px;
}
.login-btn {
  width: 100%;
  justify-content: center;
  padding: 11px;
  font-size: 15px;
  font-weight: 600;
}

/* ========== 其他工具类 ========== */
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-5 { margin-bottom: 40px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-0 { margin-bottom: 0; }
.ms-2 { margin-left: 8px; }
.me-auto { margin-right: auto; }
.d-inline { display: inline; }
.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.small { font-size: 12px; }
.fw-semibold { font-weight: 600; }

/* 卡片分组 (SDK 详情 / 版本参数) */
.group-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  margin-bottom: 18px;
  overflow: hidden;
}
.group-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}
.group-card-head .group-name { font-weight: 600; }
.group-card-body { padding: 0; }

.actions-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}
.back-link:hover { color: var(--brand); }
/* ========== 可展开分区（SDK 详情 / 版本参数）========== */
.sdk-section {
  margin-bottom: 18px;
}

.sdk-section details {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  overflow: hidden;
}

.sdk-section details[open] > .sdk-summary {
  border-bottom: 1px solid #e5e7eb;
}

.sdk-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  user-select: none;
}

.sdk-summary::-webkit-details-marker { display: none; }

.sdk-summary::before {
  content: "▶";
  font-size: 11px;
  color: var(--brand);
  transition: transform 0.15s;
  display: inline-block;
}

.sdk-section details[open] .sdk-summary::before { transform: rotate(90deg); }

.sdk-summary .summary-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: #f1f5f9;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 2px 10px;
}

.sdk-section details > :not(.sdk-summary) { margin: 14px 18px; }

.section-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.section-empty { padding: 10px 4px; }

.sub-block { margin-bottom: 16px; }

.sub-block-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-strong);
  margin-bottom: 8px;
  padding-left: 2px;
}

.sub-block-title .hint { color: var(--text-muted); font-weight: 400; font-size: 12px; }

/* 版本参数控件网格 */
.param-grid {
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.param-item {
  flex: 1 1 340px;
  min-width: 280px;
}

.checkbox-row { padding: 2px 0; }

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.checkbox-input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
}
/* ========== 移动端适配（≤768px） ========== */
@media (max-width: 768px) {
  .admin-layout { flex-direction: column; }

  /* 侧边栏改为顶部导航：Logo + 退出 + 横向滚动菜单 */
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 1020;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    overflow: visible;
    box-shadow: 0 1px 6px rgba(15, 23, 42, 0.25);
  }
  .sidebar-logo {
    order: 1;
    flex: 1 1 auto;
    padding: 10px 12px;
    font-size: 15px;
    border-bottom: none;
  }
  .sidebar-logo .logo-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 14px;
  }
  .sidebar-footer {
    order: 2;
    padding: 4px 8px;
    border-top: none;
  }
  .sidebar-footer .sidebar-link {
    padding: 7px 10px;
    font-size: 13px;
    white-space: nowrap;
  }
  .sidebar-menu {
    order: 3;
    flex: 1 1 100%;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 6px 8px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-menu > div:not(.sidebar-section-label) {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
  }
  .sidebar-section-label { display: none; }
  .sidebar-link {
    padding: 7px 10px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .sidebar-link .side-icon { font-size: 14px; }

  /* 内容区 */
  .main { padding: 12px; }
  .breadcrumb-nav {
    font-size: 12px;
    margin-bottom: 6px;
    flex-wrap: wrap;
  }
  .page-header-row {
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
  }
  .page-header { margin-bottom: 14px; }
  .page-header h1 { font-size: 20px; line-height: 1.35; }
  .page-header .page-sub { font-size: 12px; }
  .admin-card { padding: 6px; }

  /* 表格：手机上转为卡片式布局（每行一张卡片，字段名在左、值在右） */
  .admin-table-wrap > .table { min-width: 0; }
  .admin-table-wrap > .table thead { display: none; }
  .admin-table-wrap > .table,
  .admin-table-wrap > .table tbody,
  .admin-table-wrap > .table tr,
  .admin-table-wrap > .table td { display: block; width: 100%; }
  .admin-table-wrap > .table tr {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 2px 10px;
    margin-bottom: 10px;
    background: #fff;
  }
  .admin-table-wrap > .table td {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px 10px;
    padding: 6px 0;
    border: none;
    text-align: right;
    font-size: 13px;
  }
  .admin-table-wrap > .table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    min-width: 76px;
    white-space: nowrap;
    color: #6b7280;
    font-size: 12px;
    text-align: left;
    padding-top: 1px;
  }
  /* 卡片内输入框/下拉框自适应宽度 */
  .admin-table-wrap > .table td .form-control,
  .admin-table-wrap > .table td .form-select {
    width: auto !important;
    max-width: 100%;
    flex: 1 1 auto;
    min-width: 0;
  }
  .admin-table-wrap > .table td[data-label=""]::before { display: none; }
  .admin-table-wrap > .table td > code {
    white-space: normal;
    word-break: break-all;
    text-align: right;
  }
  /* 卡片内操作按钮横向排列 */
  .admin-table-wrap > .table td .actions-cell {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    width: auto;
    gap: 6px;
  }
  .admin-table-wrap > .table td .actions-cell .btn { width: auto; }
  .admin-table-wrap > .table .empty-row {
    border: none;
    padding: 0;
    text-align: center;
    color: #9ca3af;
  }
  /* 分组内参数表保持表格形式，卡片内横向滚动 */
  .group-card-body .table { min-width: 640px; }
  .group-card-body .table code { white-space: nowrap; }
  .group-card-body .table .empty-row td { text-align: left; }
  .group-card-body::before {
    content: "左右滑动查看更多 →";
    display: block;
    padding: 4px 10px;
    font-size: 11px;
    color: #9ca3af;
    text-align: right;
  }

  /* 按钮与操作区 */
  .btn { padding: 6px 10px; font-size: 12px; }
  .btn-sm { padding: 5px 8px; font-size: 12px; }
  .actions-cell { gap: 6px; }

  /* 分组卡片 */
  .group-card { margin-bottom: 12px; }
  .group-card-head {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .group-card-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .group-card-body .table { min-width: 700px; }

  /* 可折叠分区与参数网格 */
  .sdk-summary { padding: 12px 14px; font-size: 14px; }
  .sdk-section details > :not(.sdk-summary) { margin: 10px 12px; }
  .section-toolbar { flex-wrap: wrap; gap: 8px; }
  .param-grid { padding: 12px; gap: 12px; }
  .param-item { flex: 1 1 100%; min-width: 0; }
  .sub-block-title { font-size: 12px; }

  /* 表单：16px 避免 iOS 聚焦自动放大；工具栏内固定宽度控件自适应 */
  .form-control, .form-select, .form-input { font-size: 16px; }
  .form-control-sm, .form-select-sm { font-size: 14px; }
  .form-group { margin-bottom: 12px; }
  .admin-card [style*="width:180px"],
  .admin-card [style*="width:260px"],
  .admin-card [style*="max-width:220px"],
  .admin-card [style*="max-width:200px"] { max-width: 100% !important; }

  /* 弹窗铺满可用宽度 */
  .modal.show { padding: 8px; }
  .modal-dialog,
  .modal-dialog.modal-wide {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 16px);
  }
  .modal-header { padding: 12px 14px; }
  .modal-body { padding: 14px; }
  .modal-footer { padding: 10px 14px; }

  /* 工具栏、操作表单允许换行 */
  .d-flex { flex-wrap: wrap; }
  .d-inline-flex { flex-wrap: wrap; }
  .admin-card form.d-flex { row-gap: 8px; }
}
