/* ============================================
   App Styles — 全局应用样式
   基于 design-tokens.css，需在其后加载
   ============================================ */

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-page);
  font-family: var(--font-family);
  font-size: var(--text-base);
  color: var(--text-primary);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

/* === 卡片 === */
.card {
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* === 统计卡片 === */
.stat-card {
  border-radius: var(--radius-md);
  padding: var(--space-5);
  color: var(--text-inverse);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.stat-card h6 {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  opacity: 0.85;
  margin-bottom: var(--space-2);
}
.stat-card h2 {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  margin: 0;
}

.stat-card.orders   { background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); }
.stat-card.warranty { background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%); }
.stat-card.reviews  { background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%); }
.stat-card.contacts { background: linear-gradient(135deg, #059669 0%, #10b981 100%); }

/* === 迷你统计 === */
.mini-stat {
  border-radius: var(--radius-md);
  padding: 14px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  text-align: center;
  transition: box-shadow var(--transition-fast);
}
.mini-stat:hover { box-shadow: var(--shadow-sm); }
.mini-stat .value { font-size: var(--text-3xl); font-weight: var(--font-bold); color: var(--text-primary); }
.mini-stat .label { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 4px; }

/* === 按钮 === */
.btn {
  font-weight: var(--font-medium);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  transition: all var(--transition-base);
}

.btn-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-600) 100%);
  border: none;
  color: #fff;
  font-weight: var(--font-semibold);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-brand);
  transition: all var(--transition-base);
  text-align: center;
}
.btn-brand:hover {
  background: linear-gradient(135deg, var(--brand-600) 0%, var(--brand-700) 100%);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37,99,235,0.35);
}
.btn-brand:active {
  transform: translateY(0);
  box-shadow: var(--shadow-brand);
}

/* === 表单控件 === */
.form-control,
.form-select {
  border-radius: var(--radius-md);
  border-color: var(--border-default);
  padding: 10px 14px;
  font-size: var(--text-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus,
.form-select:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-label {
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

/* === 安全徽章 === */
.security-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--success-50);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
  color: var(--success-600);
  font-size: var(--text-sm);
}
.security-badge svg { width: 16px; height: 16px; flex-shrink: 0; }

/* === 步骤指示器 === */
.step-indicator {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 60px;
  margin-bottom: 36px;
}
.step-indicator::before {
  content: '';
  position: absolute;
  top: 24px;
  left: 15%;
  right: 15%;
  height: 2px;
  background: var(--border-light);
  z-index: 0;
  transition: background var(--transition-slow);
}
.step-indicator::after {
  content: '';
  position: absolute;
  top: 24px;
  left: 15%;
  height: 2px;
  background: var(--brand-500);
  z-index: 0;
  transition: width var(--transition-slow) ease;
  width: 0;
}
.step-indicator[data-progress="1"]::after { width: 0; }
.step-indicator[data-progress="2"]::after { width: 35%; }
.step-indicator[data-progress="3"]::after { width: 70%; }

.step {
  position: relative;
  z-index: 1;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-semibold);
  font-size: 16px;
  color: var(--text-muted);
  transition: all var(--transition-slow);
  box-shadow: var(--shadow-sm);
}
.step.active {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: #fff;
  box-shadow: var(--shadow-brand);
  transform: scale(1.08);
}
.step.completed {
  background: var(--success-500);
  border-color: var(--success-500);
  color: #fff;
  box-shadow: var(--shadow-success);
}

/* === Toast 通知 === */
.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.toast-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  box-shadow: var(--shadow-lg);
  min-width: 320px;
  max-width: 440px;
  animation: toastSlideIn var(--transition-slow) ease;
  border-left: 4px solid transparent;
}
.toast-item.success { border-left-color: var(--success-500); }
.toast-item.error   { border-left-color: var(--danger-500); }
.toast-item.warning { border-left-color: var(--warning-500); }
.toast-item.info    { border-left-color: var(--info-500); }

.toast-item .toast-icon { flex-shrink: 0; width: 20px; height: 20px; }
.toast-item .toast-msg  { flex: 1; font-size: var(--text-sm); color: var(--text-primary); }
.toast-item .toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  padding: 0;
  line-height: 1;
}
.toast-item.removing {
  animation: toastSlideOut var(--transition-base) ease forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

/* === Skeleton 骨架屏 === */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
.skeleton-text  { height: 14px; margin-bottom: var(--space-2); }
.skeleton-title { height: 20px; width: 60%; margin-bottom: var(--space-3); }
.skeleton-avatar { width: 40px; height: 40px; border-radius: var(--radius-full); }
.skeleton-card { height: 80px; border-radius: var(--radius-md); }

@keyframes skeletonShimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* === 空状态 === */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
}
.empty-state svg {
  width: 80px;
  height: 80px;
  color: var(--gray-300);
  margin-bottom: var(--space-4);
}
.empty-state h4 {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}
.empty-state p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 auto;
}

/* === 表格增强 === */
.table-container {
  max-height: 65vh;
  overflow-y: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}
.table-container thead {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--bg-subtle);
}
.table-container thead th {
  background: var(--bg-subtle);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  white-space: nowrap;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border-light);
}

/* === 排序表头 === */
.sortable-header {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sortable-header:hover { color: var(--brand-500); }
.sort-icon {
  margin-left: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

/* === 日期筛选按钮 === */
.date-filter .btn {
  border-radius: var(--radius-full);
  padding: 5px 16px;
  font-size: var(--text-sm);
  margin-right: 4px;
}
.date-filter .btn.active {
  background: var(--brand-500);
  color: #fff;
  border-color: var(--brand-500);
}

/* === 区块标题 === */
.section-title {
  font-size: 15px;
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

/* === 徽章 === */
.badge-up {
  background: var(--success-100);
  color: var(--success-600);
  font-weight: var(--font-medium);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
}
.badge-down {
  background: var(--danger-100);
  color: var(--danger-600);
  font-weight: var(--font-medium);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
}

/* === 状态徽章 === */
.badge-status {
  display: inline-block;
  font-weight: var(--font-medium);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  line-height: 1.2;
}
.badge-status.enabled,
.badge-status.resolved {
  background: var(--success-100);
  color: var(--success-600);
}
.badge-status.disabled {
  background: var(--gray-100);
  color: var(--gray-500);
}
.badge-status.pending {
  background: var(--warning-100);
  color: var(--warning-600);
}
.badge-status.danger {
  background: var(--danger-100);
  color: var(--danger-600);
}

/* === 侧边栏 === */
.sidebar {
  min-height: 100vh;
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  transition: transform var(--transition-slow);
}
.sidebar .nav-link {
  color: rgba(255,255,255,.7);
  padding: 11px 20px;
  border-radius: var(--radius-md);
  margin: 2px 8px;
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.sidebar .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}
.sidebar .nav-link.active {
  color: #fff;
  background: var(--brand-500);
  font-weight: var(--font-medium);
}
.sidebar .nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.sidebar-header .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--brand-500);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-header .logo-icon svg { width: 20px; height: 20px; color: #fff; }
.sidebar-header h5 {
  margin: 0;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-inverse);
}

/* 移动端侧边栏 */
@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: var(--z-modal);
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: calc(var(--z-modal) - 1);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
  }
  .sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
  }
}

/* === 页脚 === */
.app-footer {
  margin-top: var(--space-12);
  margin-bottom: var(--space-8);
  text-align: center;
}
.app-footer a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color var(--transition-fast);
}
.app-footer a:hover { color: var(--brand-500); }
