/* ===================================================
   代采平台 全平台自适应样式（Bootstrap 5 增强版）
   支持：桌面 / 平板 / 手机 全端响应式
   =================================================== */

/* ========== 全局基础 ========== */
body {
  background: #f5f6fa;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}

/* ========== 前台浅色 navbar（用户端） ========== */
.app-navbar {
  background: #fff;
  border-bottom: 1px solid #eaecef;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.app-navbar .navbar-brand { font-weight: 700; letter-spacing: 1px; color: #2b3678f; }
.app-navbar .nav-link { color: #495057; padding: .5rem 1rem; border-radius: 6px; }
.app-navbar .nav-link:hover { background: #f1f3f6; }
.app-navbar .nav-link.active { background: #e7f1ff; color: #0d6efd; }

.card { border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.card-header { background: #fff; border-bottom: 1px solid #eef0f3; font-weight: 600; }
.table-hover tbody tr:hover { background: #f8f9fc; }

/* 状态徽章 */
.badge-status-pending    { background:#ffc107; color:#212529; }
.badge-status-auditing   { background:#0dcaf0; }
.badge-status-processing { background:#0d6efd; }
.badge-status-completed  { background:#198754; }
.badge-status-failed     { background:#dc3545; }
.badge-status-cancelled  { background:#6c757d; }
.badge-status-returned   { background:#fd7e14; }
.badge-settled {
  background: linear-gradient(135deg, #28a745, #20c997) !important;
  color: #fff !important; font-weight: 600; padding: 6px 12px;
  border-radius: 20px; font-size: 13px;
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}
.badge-pay-paid   { background:#198754; }
.badge-pay-unpaid { background:#6c757d; }
.text-money       { color: #dc3545; font-weight: 600; }
.bg-soft-primary  { background:#e7f1ff; }
.empty-tip        { text-align:center; padding:40px 0; color:#999; }

/* ========== 后台管理 深色侧边栏风格 ========== */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

/* ===== 侧边栏 ===== */
.admin-sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: linear-gradient(180deg, #1f2940 0%, #1a2236 100%);
  color: #cfd6e4;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1050;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 侧边栏品牌区 */
.admin-sidebar .brand {
  padding: 16px 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  white-space: nowrap;
  overflow: hidden;
}
.admin-sidebar .brand .logo {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 6px;
  background: linear-gradient(135deg,#0d6efd,#6610f2);
  display: inline-flex; align-items: center; justify-content: center;
  color:#fff; font-size:14px; font-weight:700;
}
.admin-sidebar .brand .brand-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis;
  transition: opacity 0.3s;
}

/* 移动端关闭按钮 */
.sidebar-close-btn {
  background: none; border: none; color: rgba(255,255,255,.6);
  font-size: 16px; cursor: pointer; padding: 2px 6px;
  border-radius: 4px; flex-shrink: 0; margin-left: auto;
  transition: color 0.2s;
}
.sidebar-close-btn:hover { color: #fff; }

/* 导航项 */
.admin-sidebar .nav-section-title {
  padding: 14px 20px 6px;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 1px; color: #6b7592;
  white-space: nowrap;
}
.admin-sidebar .nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: #cfd6e4; text-decoration: none;
  font-size: 14px; border-left: 3px solid transparent;
  white-space: nowrap; overflow: hidden;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.admin-sidebar .nav-item:hover {
  background: rgba(255,255,255,.04); color: #fff;
}
.admin-sidebar .nav-item.active {
  background: rgba(13,110,253,.18); color: #fff;
  border-left-color: #0d6efd;
}
.admin-sidebar .nav-item .icon {
  width: 18px; text-align: center;
  flex-shrink: 0; opacity: 0.85;
}
.admin-sidebar .nav-item .label {
  overflow: hidden; text-overflow: ellipsis;
  transition: opacity 0.3s;
}

/* ===== 主内容区 ===== */
.admin-main {
  flex: 1;
  background: #f3f4f9;
  min-width: 0;
  display: flex; flex-direction: column;
}

/* 顶部栏 */
.admin-topbar {
  background: #fff; height: 60px; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #e6e8ef;
  position: sticky; top: 0; z-index: 1040;
  gap: 12px;
}
.admin-topbar .page-title {
  font-size: 17px; font-weight: 600; color: #222b45;
  margin: 0; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-topbar .user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 30px; background: #f3f4f9;
  white-space: nowrap;
}
.admin-topbar .user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg,#0d6efd,#6610f2);
  color: #fff; display: inline-flex; align-items: center;
  justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0;
}

/* 移动端汉堡菜单按钮 */
.sidebar-toggle-btn {
  display: flex; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: 6px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: #f0f0f5; }
.sidebar-toggle-btn span {
  display: block; width: 22px; height: 2px;
  background: #495057; border-radius: 2px;
  transition: background 0.2s;
}

/* 遮罩层 */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1045;
  backdrop-filter: blur(2px);
}

/* 内容区 */
.admin-content {
  padding: 20px;
  flex: 1;
}

/* 卡片 */
.admin-card {
  background: #fff; border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  padding: 18px; margin-bottom: 18px;
  overflow: hidden;
}
.admin-card .card-title {
  font-size: 15px; font-weight: 600; margin: 0 0 14px; color: #222b45;
}

/* ===== 表格（桌面端） ===== */
.admin-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: #fff; border-radius: 8px; overflow: hidden;
}
.admin-table thead th {
  background: #1f2940; color: #cfd6e4; font-weight: 500;
  font-size: 13px; padding: 12px 14px; text-align: left;
  border-bottom: 1px solid #2b3550;
  white-space: nowrap;
}
.admin-table thead th .sort { color: #6b7592; margin-left: 4px; cursor: pointer; }
.admin-table tbody td {
  padding: 12px 14px; border-bottom: 1px solid #f1f3f6;
  font-size: 14px; color: #222b45;
}
.admin-table tbody tr:hover td { background: #f8f9fc; }
.admin-table tbody tr:last-child td { border-bottom: none; }

/* 操作列图标按钮 */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; border-radius: 6px;
  border: none; cursor: pointer; font-size: 14px; margin-right: 4px;
  vertical-align: middle;
}
.btn-icon:last-child { margin-right: 0; }
.btn-icon.btn-edit    { background:#e7f1ff; color:#0d6efd; }
.btn-icon.btn-edit:hover    { background:#cfe2ff; }
.btn-icon.btn-del     { background:#fde2e2; color:#dc3545; }
.btn-icon.btn-del:hover     { background:#f7c8c8; }
.btn-icon.btn-view    { background:#e6f4ea; color:#198754; }
.btn-icon.btn-view:hover    { background:#cee9d4; }
.btn-icon.btn-toggle  { background:#fff3cd; color:#b58500; }
.btn-icon.btn-toggle:hover  { background:#ffe69c; }

/* ===== 分页 ===== */
.admin-pager {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px; background: #fff; border-radius: 8px;
  margin-top: 14px; font-size: 13px; color: #6c757d;
  flex-wrap: wrap; gap: 10px;
}
.admin-pager .pages {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.admin-pager .pages a,
.admin-pager .pages span {
  min-width: 32px; height: 32px; padding: 0 10px;
  border-radius: 6px; background: #f3f4f9; color: #495057;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; transition: background 0.15s, color 0.15s;
}
.admin-pager .pages a:hover { background: #e7f1ff; color: #0d6efd; }
.admin-pager .pages .active { background: #0d6efd; color: #fff; }

/* ===== 统计卡片（桌面） ===== */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.admin-stat {
  padding: 18px; border-radius: 10px; color: #fff;
  position: relative; overflow: hidden;
}
.admin-stat::before {
  content: ''; position: absolute; right: -10px; bottom: -10px;
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.admin-stat.s1 { background: linear-gradient(135deg,#0d6efd,#0a58ca); }
.admin-stat.s2 { background: linear-gradient(135deg,#6610f2,#520dc2); }
.admin-stat.s3 { background: linear-gradient(135deg,#198754,#146c43); }
.admin-stat.s4 { background: linear-gradient(135deg,#fd7e14,#ca6510); }
.admin-stat.s5 { background: linear-gradient(135deg,#17a2b8,#117a8b); }
.admin-stat.s6 { background: linear-gradient(135deg,#1e3a5f,#0f2027); }
.admin-stat.s7 { background: linear-gradient(135deg,#28a745,#20c997); }
.admin-stat.s8 { background: linear-gradient(135deg,#6c757d,#495057); }
.admin-stat .label { font-size: 13px; opacity: .88; }
.admin-stat .num { font-size: 26px; font-weight: 700; margin-top: 6px; }

/* 已结算徽章 */
.badge-settled {
  background: linear-gradient(135deg, #28a745, #20c997) !important;
  color: #fff !important; font-weight: 600; padding: 5px 12px;
  border-radius: 20px; font-size: 12px;
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
  display: inline-block;
}

/* 上传框 */
.upload-box {
  border: 2px dashed #ced4da; padding: 20px; text-align: center;
  border-radius: 8px; cursor: pointer; transition: border-color 0.2s, background 0.2s;
}
.upload-box:hover { border-color: #0d6efd; background: #f8fbff; }

/* ========== 表单样式增强 ========== */
.form-label { font-weight: 500; color: #495057; font-size: 14px; }

/* ========== QR码缩略图 ========== */
.qr-thumb {
  width: 48px; height: 48px; object-fit: contain;
  border: 1px solid #ddd; border-radius: 4px;
  cursor: pointer; background: #fff; padding: 2px;
  transition: border-color 0.2s;
}
.qr-thumb:hover { border-color: #0d6efd; }
.qr-empty {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; color: #aaa;
  border: 1px dashed #ddd; border-radius: 4px;
  font-size: 11px;
}

/* ========== 移动端卡片列表（替代表格） ========== */
.mobile-card-list {
  display: none;
}
.mobile-card-item {
  background: #fff; border-radius: 10px; padding: 14px;
  margin-bottom: 12px; box-shadow: 0 2px 6px rgba(0,0,0,.04);
  border-left: 3px solid transparent;
}
.mobile-card-item.status-active { border-left-color: #0d6efd; }
.mobile-card-item .mc-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.mobile-card-item .mc-title {
  font-size: 14px; font-weight: 600; color: #222b45;
}
.mobile-card-item .mc-body {
  font-size: 13px; color: #6c757d; line-height: 1.6;
}
.mobile-card-item .mc-row {
  display: flex; justify-content: space-between;
  padding: 3px 0; border-bottom: 1px solid #f1f3f6;
}
.mobile-card-item .mc-row:last-child { border-bottom: none; }
.mobile-card-item .mc-label { color: #999; }
.mobile-card-item .mc-value { font-weight: 500; color: #222b45; }
.mobile-card-item .mc-actions {
  margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap;
}

/* ========== ========================================
   响应式断点规则（移动优先）
   ======================================== */

/* ---- 平板（≤ 991px） ---- */
@media (max-width: 991.98px) {
  .admin-stats {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }
  .admin-stat .num { font-size: 22px; }

  .admin-content { padding: 14px; }
  .admin-card { padding: 14px; }

  .admin-topbar { padding: 0 14px; }
}

/* ---- 手机（≤ 767.98px） ---- */
@media (max-width: 767.98px) {
  /* 侧边栏默认隐藏（滑入） */
  .admin-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    z-index: 1051;
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  .admin-sidebar.sidebar-open {
    transform: translateX(0);
  }

  /* 遮罩显示 */
  .sidebar-overlay.overlay-active { display: block; }

  /* 主内容区填满 */
  .admin-main { width: 100%; }

  /* 顶部栏 */
  .admin-topbar { height: 54px; padding: 0 14px; }
  .admin-topbar .page-title { font-size: 15px; }
  .admin-topbar .btn-outline-secondary {
    padding: 4px 10px; font-size: 12px;
  }
  .admin-topbar .user-chip { padding: 4px 8px; }
  .admin-topbar .user-chip .avatar { width: 26px; height: 26px; font-size: 12px; }

  /* 内容区内边距 */
  .admin-content { padding: 12px; }

  /* 隐藏 PC 表格，显示手机卡片 */
  .admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-table { min-width: 700px; }
  .mobile-card-list { display: block; }
  .mobile-card-list.hidden-cards { display: none; }

  /* 统计卡片 */
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .admin-stat { padding: 14px 12px; }
  .admin-stat .label { font-size: 12px; }
  .admin-stat .num { font-size: 20px; }

  /* 卡片 */
  .admin-card { padding: 12px; border-radius: 8px; margin-bottom: 12px; }
  .admin-card .card-title { font-size: 14px; }

  /* 搜索表单 */
  .admin-card form.d-flex {
    flex-direction: column; gap: 8px;
  }
  .admin-card form.d-flex > * {
    max-width: 100% !important; width: 100%;
  }
  .admin-card form.d-flex .ms-auto {
    margin-left: 0 !important;
    text-align: center;
    padding-top: 6px;
  }

  /* 分页 */
  .admin-pager { flex-direction: column; align-items: flex-start; gap: 8px; }
  .admin-pager .pages { width: 100%; justify-content: flex-start; }

  /* 操作按钮行 */
  .admin-table tbody td:last-child,
  .admin-table thead th:last-child {
    white-space: normal;
    min-width: 120px;
  }

  /* 徽章紧凑 */
  .badge { font-size: 11px; padding: 3px 7px; }
  .badge-settled { font-size: 11px; padding: 4px 10px; }

  /* 手机端 QR 码放大 */
  .qr-thumb { width: 40px; height: 40px; }
  .qr-empty { width: 40px; height: 40px; font-size: 10px; }
}

/* ---- 超小屏（≤ 374px） ---- */
@media (max-width: 374.98px) {
  .admin-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .admin-stat .num { font-size: 18px; }
  .admin-stat .label { font-size: 11px; }
  .admin-content { padding: 10px; }
}

/* ---- 滚动条美化（webkit） ---- */
.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

/* ---- 防止表格横向撑破布局 ---- */
.admin-table { table-layout: fixed; }

/* ---- 打印样式 ---- */
@media print {
  .admin-sidebar, .admin-topbar, .admin-pager { display: none !important; }
  .admin-main { width: 100% !important; }
  .admin-content { padding: 0 !important; }
}
