/* ============================================
   售后系统 - 公共样式表 v2.0
   色彩规范:
   主色(浅绿色): #10B981 (Emerald-500)
   主色浅: #D1FAE5 (Emerald-100)
   主色深: #059669 (Emerald-600)
   主色极深: #065F46 (Emerald-800)
   辅助色: #3B82F6 (Blue-500)
   中性色: #F9FAFB, #F3F4F6, #E5E7EB, #6B7280, #374151, #111827
   功能色-成功: #22C55E
   功能色-警告: #F59E0B
   功能色-错误: #EF4444
   功能色-信息: #3B82F6
   ============================================ */

/* 全局基础 */
*, *::before, *::after { 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: #F0FDF4;
  color: #374151;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ========== 侧边栏 ========== */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #064E3B 0%, #065F46 40%, #047857 100%);
  min-height: 100vh;
  position: fixed;
  left: 0; top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo-icon {
  width: 42px; height: 42px;
  background: rgba(255,255,255,0.12);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.sidebar-logo h1 { color: #fff; font-size: 17px; font-weight: 700; line-height: 1.3; }
.sidebar-logo p { color: rgba(255,255,255,0.5); font-size: 11px; margin-top: 2px; }

/* 侧边栏关闭按钮 - 仅移动端显示 */
.sidebar-close {
  display: none;
  position: absolute;
  top: 16px; right: 16px;
  background: rgba(255,255,255,0.1);
  border: none; border-radius: 8px;
  color: #fff; cursor: pointer;
  width: 32px; height: 32px;
  align-items: center; justify-content: center;
  transition: background 0.2s;
}
.sidebar-close:hover { background: rgba(255,255,255,0.2); }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.nav-group-title {
  color: rgba(255,255,255,0.4);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 12px 20px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 11px 20px;
  margin: 2px 10px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  border-radius: 10px;
  transition: all 0.2s;
  cursor: pointer;
  gap: 10px;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }

.nav-item.active {
  background: rgba(16,185,129,0.25);
  color: #fff;
  font-weight: 500;
  box-shadow: inset 0 0 0 1px rgba(52,211,153,0.3);
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item.active svg { opacity: 1; }

/* ========== 遮罩层 ========== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 45;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.35s;
}
.sidebar-overlay.active { display: block; opacity: 1; }

/* ========== 主内容区 ========== */
.main-content {
  margin-left: 260px;
  min-height: 100vh;
  transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== 顶部栏 ========== */
.topbar {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid rgba(229,231,235,0.6);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.menu-toggle {
  display: none;
  background: none; border: none;
  cursor: pointer; padding: 6px;
  color: #374151; border-radius: 8px;
  transition: background 0.2s;
}
.menu-toggle:hover { background: #F3F4F6; }

.breadcrumb {
  display: flex; align-items: center;
  gap: 8px; font-size: 14px; color: #6B7280;
}
.breadcrumb a { color: #10B981; text-decoration: none; font-weight: 500; }
.breadcrumb a:hover { text-decoration: underline; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-btn {
  position: relative;
  background: none; border: none;
  cursor: pointer; color: #6B7280;
  padding: 8px; border-radius: 10px;
  transition: all 0.2s;
}
.topbar-btn:hover { background: #F3F4F6; color: #374151; }

.badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: #EF4444; color: #fff;
  font-size: 10px; font-weight: 600;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}

.user-info { display: flex; align-items: center; gap: 8px; cursor: pointer; }

.avatar {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #10B981, #059669);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 600;
}

.user-name { font-size: 14px; color: #374151; font-weight: 500; }

/* ========== 页面内容区 ========== */
.page-content { padding: 28px; max-width: 1400px; }

.page-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap; gap: 12px;
}

.page-title { font-size: 24px; font-weight: 700; color: #111827; letter-spacing: -0.3px; }
.page-subtitle { font-size: 14px; color: #6B7280; margin-top: 4px; }

/* ========== 统计卡片 ========== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid rgba(229,231,235,0.7);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.stat-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  transform: translateY(-3px);
  border-color: rgba(16,185,129,0.3);
}

.stat-card-header {
  display: flex; align-items: center;
  justify-content: space-between;
}

.stat-card-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}

.stat-card-value { font-size: 30px; font-weight: 800; color: #111827; letter-spacing: -1px; }
.stat-card-label { font-size: 13px; color: #6B7280; margin-top: 4px; font-weight: 500; }

/* ========== 表格 ========== */
.table-container {
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(229,231,235,0.7);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.table-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid #E5E7EB;
  flex-wrap: wrap; gap: 12px;
}

.table-title { font-size: 16px; font-weight: 600; color: #111827; }

.table-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  background: #F9FAFB;
  padding: 12px 16px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid #E5E7EB;
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid #F3F4F6;
  color: #374151;
}

tbody tr { transition: background 0.15s; }
tbody tr:hover { background: #F0FDF4; }
tbody tr:last-child td { border-bottom: none; }

/* ========== 按钮 ========== */
.btn {
  display: inline-flex; align-items: center;
  gap: 6px; padding: 9px 18px;
  border-radius: 10px; font-size: 14px;
  font-weight: 500; cursor: pointer;
  border: none; transition: all 0.2s;
  text-decoration: none; white-space: nowrap;
  line-height: 1.4;
}

.btn-primary { background: linear-gradient(135deg, #10B981, #059669); color: #fff; box-shadow: 0 2px 8px rgba(16,185,129,0.3); }
.btn-primary:hover { background: linear-gradient(135deg, #059669, #047857); box-shadow: 0 4px 12px rgba(16,185,129,0.4); transform: translateY(-1px); }

.btn-secondary { background: #fff; color: #374151; border: 1px solid #D1D5DB; }
.btn-secondary:hover { background: #F9FAFB; border-color: #9CA3AF; }

.btn-danger { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }
.btn-danger:hover { background: #FEE2E2; }

.btn-warning { background: #FFFBEB; color: #D97706; border: 1px solid #FDE68A; }
.btn-warning:hover { background: #FEF3C7; }

.btn-info { background: #EFF6FF; color: #2563EB; border: 1px solid #BFDBFE; }
.btn-info:hover { background: #DBEAFE; }

.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* ========== 状态标签 ========== */
.status-tag {
  display: inline-flex; align-items: center;
  padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.2px;
}

.status-pending { background: #FEF3C7; color: #B45309; }
.status-processing { background: #DBEAFE; color: #1D4ED8; }
.status-completed { background: #D1FAE5; color: #047857; }
.status-rejected { background: #FEE2E2; color: #B91C1C; }
.status-recycling { background: #E0E7FF; color: #3730A3; }
.status-repairing { background: #FEF3C7; color: #B45309; }
.status-renew { background: #D1FAE5; color: #047857; }
.status-downgrade { background: #FEF3C7; color: #92400E; }
.status-return { background: #FEE2E2; color: #B91C1C; }
.status-returning { background: #E0E7FF; color: #3730A3; }
.status-closed { background: #F3F4F6; color: #6B7280; }

/* ========== 搜索框 ========== */
.search-box {
  display: flex; align-items: center;
  background: #F9FAFB; border-radius: 10px;
  padding: 0 12px;
  border: 1.5px solid #E5E7EB;
  transition: all 0.2s;
}

.search-box:focus-within {
  background: #fff;
  border-color: #10B981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

.search-box input {
  background: none; border: none; outline: none;
  padding: 9px 8px; font-size: 14px;
  width: 200px; color: #374151;
}

.search-box svg { color: #9CA3AF; width: 16px; height: 16px; flex-shrink: 0; }

/* ========== 表单 ========== */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block; font-size: 13px;
  font-weight: 600; color: #374151;
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid #D1D5DB;
  border-radius: 10px; font-size: 14px;
  color: #374151; background: #fff;
  transition: all 0.2s; outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #10B981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

.form-textarea { resize: vertical; min-height: 80px; }

/* ========== 模态框 ========== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 60; padding: 16px;
  opacity: 0; visibility: hidden;
  transition: all 0.3s;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: #fff; border-radius: 20px;
  width: 100%; max-width: 560px;
  max-height: 85vh; overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-overlay.active .modal { transform: translateY(0) scale(1); }

.modal-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #E5E7EB;
  position: sticky; top: 0;
  background: #fff; border-radius: 20px 20px 0 0;
  z-index: 1;
}

.modal-title { font-size: 17px; font-weight: 600; color: #111827; }

.modal-close {
  background: #F3F4F6; border: none;
  cursor: pointer; color: #6B7280;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.modal-close:hover { background: #E5E7EB; color: #374151; }

.modal-body { padding: 24px; }

.modal-footer {
  display: flex; justify-content: flex-end;
  gap: 8px; padding: 16px 24px;
  border-top: 1px solid #E5E7EB;
  position: sticky; bottom: 0;
  background: #fff; border-radius: 0 0 20px 20px;
  flex-wrap: wrap;
}

/* ========== 分页 ========== */
.pagination {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-top: 1px solid #E5E7EB;
  flex-wrap: wrap; gap: 12px;
}
.pagination-info { font-size: 13px; color: #6B7280; }

/* ========== Toast ========== */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #fff; border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  display: flex; align-items: center; gap: 10px;
  min-width: 280px; max-width: 380px;
  animation: toastIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 4px solid;
  font-size: 14px;
}

.toast-success { border-left-color: #22C55E; }
.toast-error { border-left-color: #EF4444; }
.toast-warning { border-left-color: #F59E0B; }
.toast-info { border-left-color: #3B82F6; }

@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========== 工作流步骤 ========== */
.workflow-steps {
  display: flex; align-items: center;
  margin-bottom: 24px;
  overflow-x: auto; padding-bottom: 4px;
  gap: 0;
  -webkit-overflow-scrolling: touch;
}

.workflow-step {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: #fff;
  border: 2px solid #E5E7EB;
  border-radius: 10px;
  font-size: 12px; font-weight: 600;
  color: #6B7280;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.workflow-step.active {
  border-color: #10B981;
  background: linear-gradient(135deg, #ECFDF5, #D1FAE5);
  color: #059669;
  box-shadow: 0 2px 8px rgba(16,185,129,0.15);
}

.workflow-step.done {
  border-color: #22C55E;
  background: #22C55E;
  color: #fff;
}

.workflow-step svg { width: 14px; height: 14px; flex-shrink: 0; }

.workflow-arrow {
  color: #D1D5DB; font-size: 18px;
  padding: 0 4px; flex-shrink: 0;
  line-height: 1;
}

/* ========== 选项卡 ========== */
.tabs {
  display: flex; gap: 4px;
  background: #F3F4F6;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-item {
  padding: 9px 18px;
  font-size: 13px; font-weight: 600;
  color: #6B7280; cursor: pointer;
  border-radius: 8px;
  white-space: nowrap;
  transition: all 0.2s;
  background: none; border: none;
}

.tab-item:hover { color: #374151; }

.tab-item.active {
  background: #fff;
  color: #10B981;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #9CA3AF;
  grid-column: 1 / -1;
}
.empty-state svg { width: 56px; height: 56px; margin-bottom: 12px; color: #D1D5DB; }
.empty-state p { font-size: 14px; margin-bottom: 12px; }

/* ========== 卡片网格 ========== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.order-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(229,231,235,0.7);
  padding: 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.order-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  transform: translateY(-2px);
  border-color: rgba(16,185,129,0.3);
}

.order-card-head {
  display: flex; justify-content: space-between;
  align-items: start; margin-bottom: 14px;
}

.order-card-id { font-weight: 700; color: #10B981; font-size: 15px; }
.order-card-date { font-size: 12px; color: #9CA3AF; margin-top: 2px; }

.order-card-row {
  font-size: 14px; margin-bottom: 6px;
  display: flex; gap: 4px;
}
.order-card-row .label { color: #9CA3AF; flex-shrink: 0; }
.order-card-row .value { color: #374151; }

.order-card-note {
  font-size: 12px; padding: 8px 10px;
  border-radius: 8px; margin-top: 8px;
  line-height: 1.5;
}

.order-card-actions {
  display: flex; gap: 8px;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid #F3F4F6;
  flex-wrap: wrap;
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

/* ========== 响应式 - 平板 ========== */
@media (max-width: 1024px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

/* ========== 响应式 - 手机端抽屉式导航 ========== */
@media (max-width: 768px) {
  /* 侧边栏变为抽屉 */
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 30px rgba(0,0,0,0.25);
  }
  .sidebar-close { display: flex; }

  /* 主内容全宽 */
  .main-content { margin-left: 0; }

  /* 显示汉堡菜单 */
  .menu-toggle { display: flex; }

  /* 顶部栏 */
  .topbar { padding: 0 16px; height: 56px; }
  .user-name { display: none; }

  /* 页面内容 */
  .page-content { padding: 16px; }
  .page-title { font-size: 20px; }
  .page-header { flex-direction: column; align-items: stretch; }

  /* 统计卡片 2列 */
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; border-radius: 12px; }
  .stat-card-value { font-size: 24px; }
  .stat-card-icon { width: 36px; height: 36px; }

  /* 表格横向滚动 */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-scroll table { min-width: 640px; }
  .table-header { padding: 14px 16px; }

  /* 卡片单列 */
  .card-grid { grid-template-columns: 1fr; }

  /* 搜索框 */
  .search-box { width: 100%; }
  .search-box input { width: 100%; }
  .table-actions { width: 100%; }
  .table-actions > * { flex: 1; min-width: 0; }

  /* 工作流步骤缩小 */
  .workflow-step { padding: 6px 10px; font-size: 11px; }
  .workflow-arrow { font-size: 14px; padding: 0 2px; }

  /* 选项卡 */
  .tabs { border-radius: 10px; }
  .tab-item { padding: 8px 14px; font-size: 12px; }

  /* 模态框全屏化 */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%; max-height: 92vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }
  .modal-overlay.active .modal { transform: translateY(0); }
  .modal-header { border-radius: 20px 20px 0 0; padding: 16px 20px; }
  .modal-body { padding: 20px; }
  .modal-footer { padding: 14px 20px; }

  /* 按钮 */
  .btn-lg { padding: 11px 20px; font-size: 14px; width: 100%; justify-content: center; }

  /* Toast */
  .toast-container { left: 16px; right: 16px; top: auto; bottom: 16px; }
  .toast { min-width: auto; width: 100%; }
}

/* ========== 响应式 - 小手机 ========== */
@media (max-width: 400px) {
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-card-value { font-size: 20px; }
  .stat-card-label { font-size: 11px; }
  .page-content { padding: 12px; }
  .page-title { font-size: 18px; }
  .workflow-steps { display: none; }
}
