/* ===== 基础样式 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f0f2f5;
  color: #333;
}

/* ===== 登录页 ===== */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.login-box h1 {
  font-size: 24px;
  color: #1a1a2e;
  margin-bottom: 8px;
}

.subtitle {
  color: #666;
  margin-bottom: 30px;
}

/* 原样式（可能只有 padding） */
.qrcode-box {
  padding: 20px;
  text-align: center;        /* ← 新增：让内部文字和行内元素居中 */
}

/* 二维码容器（让 canvas 或 img 居中） */
#qrcode {
  display: flex;             /* ← 新增：启用弹性布局 */
  justify-content: center;   /* ← 新增：水平居中子元素 */
  margin-bottom: 16px;       /* 与下方提示文字的间距 */
}

/* 确保二维码内部的 img/canvas 本身不会超出容器 */
#qrcode img,
#qrcode canvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;        /* 可选美化 */
}


.status-box {
  padding: 40px 0;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-top-color: #1a73e8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.user-info-box {
  padding: 20px;
}

.avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-bottom: 12px;
  border: 3px solid #1a73e8;
}

.user-info-box p {
  margin-bottom: 8px;
  color: #666;
}

/* ===== 管理后台布局 ===== */
.admin-container {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: 240px;
  background: #1a1a2e;
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
}

.nav-item {
  display: none; /* 默认隐藏，权限验证后显示 */
  padding: 12px 20px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

/* 权限验证通过后由 JS 添加此类 */
.nav-item.visible {
  display: block;
}

.nav-item:hover, .nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-left-color: #1a73e8;
}

.nav-group {
  margin-bottom: 4px;
}

.nav-group-title {
  padding: 14px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 1px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.avatar-small {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.user-profile small {
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
}

/* 主内容区 */
.main-content {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
}

.topbar {
  background: white;
  padding: 16px 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-size: 20px;
  color: #1a1a2e;
}

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

/* 环境标识徽章 */
.env-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: default;
}
.env-badge.env-dev {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}
.env-badge.env-prod {
  background: #fce4ec;
  color: #c62828;
  border: 1px solid #ef9a9a;
}

.content-panels {
  padding: 24px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

/* ===== 数据概览 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.stat-card h3 {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
}

.stat-card p {
  font-size: 32px;
  font-weight: bold;
  color: #1a73e8;
}

.chart-area {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.rank-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.rank {
  width: 30px;
  font-weight: bold;
  color: #1a73e8;
}

.keyword {
  flex: 1;
}

.count {
  color: #999;
  font-size: 13px;
}

/* ===== 搜索栏 ===== */
.search-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  width: 200px;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

/* ===== 表格 ===== */
.table-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: #f8f9fa;
  padding: 12px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: #555;
  border-bottom: 2px solid #e0e0e0;
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}

.data-table tr:hover {
  background: #f8f9ff;
}

.editable {
  cursor: pointer;
}

.editable:hover {
  background: #fff3cd;
}

.price-cell {
  color: #e74c3c;
  font-weight: 600;
}

.inline-input {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid #1a73e8;
  border-radius: 4px;
  font-size: 13px;
}

/* ===== 按钮 ===== */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #1a73e8;
  color: white;
}

.btn-primary:hover {
  background: #1557b0;
}

.btn-success {
  background: #27ae60;
  color: white;
}

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-secondary {
  background: #95a5a6;
  color: white;
}

.btn-warning {
  background: #f39c12;
  color: white;
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-logout {
  width: 100%;
  background: rgba(231, 76, 60, 0.8);
  color: white;
  margin-top: 8px;
}

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

/* ===== 图片管理 ===== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.gallery-item {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.gallery-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.gallery-info {
  padding: 12px;
}

.gallery-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.gallery-meta {
  font-size: 12px;
  color: #999;
  margin-bottom: 8px;
}

/* ===== 导入区域 ===== */
.import-area {
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.upload-zone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 40px;
  text-align: center;
  margin-bottom: 20px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.upload-zone:hover {
  border-color: #1a73e8;
}

.hint {
  color: #999;
  font-size: 12px;
  margin: 8px 0 16px;
}

.import-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

.progress-bar {
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin: 16px 0;
}

.progress-fill {
  height: 100%;
  background: #1a73e8;
  transition: width 0.3s;
}

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

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #555;
}

.form-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
  max-width: 300px;
}

textarea.form-input {
  max-width: 500px;
  resize: vertical;
  font-family: inherit;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

/* ===== 弹窗 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 520px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  cursor: pointer;
  font-size: 20px;
  color: #999;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid #eee;
}

/* ===== 徽章 ===== */
.badge {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success {
  background: #d4edda;
  color: #155724;
}

.badge-default {
  background: #e0e0e0;
  color: #555;
}

.badge-error {
  background: #f8d7da;
  color: #721c24;
}

.badge-warning {
  background: #fff3cd;
  color: #856404;
}

/* ===== 分页 ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 0 4px;
  font-size: 13px;
  color: #666;
}

.pagination .page-ellipsis {
  padding: 4px 6px;
  color: #999;
  font-size: 12px;
}

/* ===== 响应式（手机端） ===== */
.menu-toggle {
  display: none;
  font-size: 24px;
  cursor: pointer;
  margin-right: 12px;
  line-height: 1;
}

/* 侧边栏遮罩 */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 240px;
  }

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

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

  .main-content {
    margin-left: 0 !important;
  }

  .topbar {
    padding: 12px 16px;
  }

  .topbar h1 {
    font-size: 16px;
  }

  .content-panels {
    padding: 12px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-card p {
    font-size: 24px;
  }

  .search-bar {
    flex-direction: column;
  }

  .search-input {
    width: 100%;
  }

  .data-table {
    font-size: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 8px 6px;
    white-space: nowrap;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  .gallery-img {
    height: 120px;
  }

  .modal-content {
    width: 95vw;
    max-height: 90vh;
    border-radius: 8px;
  }

  .modal-header {
    padding: 12px 16px;
  }

  .modal-body {
    padding: 14px 16px;
  }

  .modal-footer {
    padding: 12px 16px;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .form-input {
    max-width: 100%;
  }

  .vip-detail-cards {
    grid-template-columns: 1fr;
  }

  .pagination {
    flex-wrap: wrap;
    gap: 6px;
  }

  .btn {
    padding: 6px 12px;
    font-size: 13px;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .import-actions {
    flex-direction: column;
    gap: 12px;
  }
}

.category-select {
  padding: 4px;
  border-radius: 4px;
  border: 1px solid #ddd;
}

/* ===== 会员详情 ===== */
.vip-detail-section {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.vip-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.vip-detail-header h3 {
  margin: 0;
  font-size: 18px;
}

.vip-detail-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.vip-info-card {
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  overflow: hidden;
}

.vip-card-title {
  background: #f8f9fa;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  color: #555;
  border-bottom: 1px solid #e8e8e8;
}

.vip-card-body {
  padding: 16px;
}

.vip-card-body p {
  margin-bottom: 8px;
  font-size: 14px;
  color: #333;
}

.vip-card-body p:last-child {
  margin-bottom: 0;
}

.vip-card-body .label {
  color: #999;
  margin-right: 8px;
}

.vip-card-body .highlight {
  color: #e74c3c;
  font-weight: 600;
  font-size: 18px;
}

.vip-card-body .vip-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 12px;
}

/* 会员列表行高亮 */
.vip-row.row-selected,
.data-table tr.row-selected {
  background: #e8f0fe !important;
  outline: 2px solid #1a73e8;
  outline-offset: -2px;
}