/* ============================================
   电商小程序管理后台 - 样式文件
   ============================================ */

/* ---------- 全局重置与基础样式 ---------- */
* {
  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: #f5f6fa;
  color: #333;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

/* ---------- 整体布局 ---------- */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: #1a1a2e;
  color: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-logo {
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  letter-spacing: 1px;
}

.sidebar-logo span {
  color: #ff6b6b;
}

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

.nav-item {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.7);
  border-left: 3px solid transparent;
  user-select: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-item.active {
  background: rgba(255, 107, 107, 0.15);
  color: #ff6b6b;
  border-left-color: #ff6b6b;
}

.nav-item .nav-icon {
  margin-right: 10px;
  font-size: 18px;
  width: 24px;
  text-align: center;
}

/* ---------- 右侧主内容区 ---------- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 顶部导航栏 ---------- */
.top-header {
  height: 60px;
  min-height: 60px;
  background: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  z-index: 10;
}

.top-header .page-title {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a2e;
}

/* ---------- 内容区域 ---------- */
.content-area {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ---------- 页面模块 ---------- */
.page-section {
  display: none;
}

.page-section.active {
  display: block;
}

/* ---------- 顶部操作栏 ---------- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- 搜索框 ---------- */
.search-input {
  padding: 8px 14px;
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  font-size: 14px;
  width: 240px;
  outline: none;
  transition: border-color 0.3s;
}

.search-input:focus {
  border-color: #ff6b6b;
  box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.15);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  white-space: nowrap;
  gap: 4px;
}

.btn-primary {
  background: #ff6b6b;
  color: #fff;
}

.btn-primary:hover {
  background: #e55a5a;
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4);
}

.btn-secondary {
  background: #f0f0f0;
  color: #666;
}

.btn-secondary:hover {
  background: #e4e4e4;
}

.btn-danger {
  background: #ff4757;
  color: #fff;
}

.btn-danger:hover {
  background: #e84142;
  box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
}

.btn-success {
  background: #2ed573;
  color: #fff;
}

.btn-success:hover {
  background: #26bf65;
}

.btn-warning {
  background: #ffa502;
  color: #fff;
}

.btn-warning:hover {
  background: #e69500;
}

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

.btn-link {
  background: none;
  color: #ff6b6b;
  padding: 5px 8px;
}

.btn-link:hover {
  background: rgba(255, 107, 107, 0.1);
}

/* ---------- 表格容器 ---------- */
.table-container {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.table-wrapper {
  overflow-x: auto;
  flex: 1;
}

/* ---------- 表格样式 ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

thead th {
  background: #fafbfc;
  color: #606266;
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 2px solid #ebeef5;
  white-space: nowrap;
  font-size: 13px;
}

tbody tr {
  transition: background 0.2s;
}

tbody tr:nth-child(even) {
  background: #fafbfc;
}

tbody tr:hover {
  background: #f0f5ff;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #ebeef5;
  vertical-align: middle;
  font-size: 13px;
}

/* ---------- 商品图片缩略图 ---------- */
.product-thumb {
  width: 50px;
  height: 50px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid #eee;
}

/* ---------- 状态标签 ---------- */
.status-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-pending {
  background: #fff3e0;
  color: #e65100;
}

.status-paid {
  background: #e3f2fd;
  color: #1565c0;
}

.status-shipped {
  background: #f3e5f5;
  color: #7b1fa2;
}

.status-completed {
  background: #e8f5e9;
  color: #2e7d32;
}

.status-cancelled {
  background: #f5f5f5;
  color: #9e9e9e;
}

.status-on {
  background: #e8f5e9;
  color: #2e7d32;
}

.status-off {
  background: #f5f5f5;
  color: #9e9e9e;
}

/* ---------- 订单商品信息 ---------- */
.order-item-info {
  font-size: 13px;
  line-height: 1.6;
}

.order-item-info .item-name {
  color: #333;
}

.order-item-info .item-meta {
  color: #999;
  font-size: 12px;
}

/* ---------- 操作列 ---------- */
.action-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: #fff;
  border-top: 1px solid #ebeef5;
  flex-wrap: wrap;
  gap: 10px;
}

.pagination-info {
  color: #909399;
  font-size: 13px;
}

.pagination-btns {
  display: flex;
  gap: 4px;
}

.pagination-btns button {
  padding: 6px 12px;
  border: 1px solid #dcdfe6;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: #606266;
  transition: all 0.2s;
}

.pagination-btns button:hover:not(:disabled) {
  border-color: #ff6b6b;
  color: #ff6b6b;
}

.pagination-btns button.active {
  background: #ff6b6b;
  border-color: #ff6b6b;
  color: #fff;
}

.pagination-btns button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- 筛选Tabs ---------- */
.filter-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  flex-wrap: wrap;
}

.filter-tab {
  padding: 8px 20px;
  cursor: pointer;
  font-size: 14px;
  color: #606266;
  border-radius: 6px;
  transition: all 0.3s;
  user-select: none;
  border: none;
  background: none;
  font-weight: 500;
}

.filter-tab:hover {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.06);
}

.filter-tab.active {
  color: #fff;
  background: #ff6b6b;
  box-shadow: 0 2px 6px rgba(255, 107, 107, 0.3);
}

/* ---------- 统计卡片 ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 22px 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.3s, box-shadow 0.3s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.stat-icon.red {
  background: #fff0f0;
  color: #ff6b6b;
}

.stat-icon.blue {
  background: #eef6ff;
  color: #4a90d9;
}

.stat-icon.green {
  background: #e8f8f0;
  color: #2ed573;
}

.stat-icon.orange {
  background: #fff5e6;
  color: #ffa502;
}

.stat-icon.purple {
  background: #f3e8ff;
  color: #7c3aed;
}

.stat-info {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: 13px;
  color: #909399;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.2;
}

.stat-value .unit {
  font-size: 14px;
  font-weight: 400;
  color: #909399;
  margin-left: 2px;
}

/* ---------- 图表卡片 ---------- */
.chart-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.chart-card h3 {
  font-size: 16px;
  color: #1a1a2e;
  margin-bottom: 16px;
  font-weight: 600;
}

/* ---------- 简单柱状图 ---------- */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 200px;
  padding: 0 10px;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.bar-value {
  font-size: 12px;
  color: #606266;
  margin-bottom: 4px;
  font-weight: 500;
}

.bar {
  width: 100%;
  max-width: 48px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(to top, #ff6b6b, #ff8e8e);
  transition: height 0.6s ease;
  min-height: 4px;
}

.bar-label {
  font-size: 12px;
  color: #909399;
  margin-top: 6px;
  white-space: nowrap;
}

/* ---------- 弹窗遮罩 ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---------- 弹窗 ---------- */
.modal {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.25s ease;
}

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

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
  color: #1a1a2e;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: #909399;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

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

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

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

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

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 6px;
}

.form-label .required {
  color: #ff4757;
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  font-family: inherit;
  background: #fff;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: #ff6b6b;
  box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.15);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---------- 设置表单 ---------- */
.settings-section {
  background: #fff;
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.settings-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ebeef5;
}

/* ---------- 滚动条美化 ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c1c7cd;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8aeb4;
}

/* ---------- 空状态提示 ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #909399;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ---------- 提示消息 ---------- */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 2000;
  font-size: 14px;
  display: none;
  align-items: center;
  gap: 8px;
  animation: slideDown 0.3s ease;
  max-width: 90%;
}

.toast.show {
  display: flex;
}

.toast.success {
  border-left: 4px solid #2ed573;
}

.toast.error {
  border-left: 4px solid #ff4757;
}

.toast.info {
  border-left: 4px solid #4a90d9;
}

@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    min-width: 60px;
  }

  .sidebar-logo {
    font-size: 14px;
    padding: 0 10px;
    justify-content: center;
  }

  .sidebar-logo span {
    display: none;
  }

  .nav-item {
    padding: 14px 10px;
    justify-content: center;
  }

  .nav-item .nav-icon {
    margin-right: 0;
  }

  .nav-item .nav-text {
    display: none;
  }

  .content-area {
    padding: 16px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .search-input {
    width: 180px;
  }

  .modal {
    width: 95%;
    max-width: 95%;
  }
}