/* 全局样式 */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* 导航栏 */
.navbar {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  padding: 0;
}
.navbar .navbar-brand { color: #fff; font-weight: 700; font-size: 1.3rem; }
.navbar .nav-link { color: rgba(255,255,255,0.85) !important; padding: 0.8rem 1rem; }
.navbar .nav-link:hover, .navbar .nav-link.active { color: #fff !important; background: rgba(255,255,255,0.1); }

/* 卡片 */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  border-radius: 12px 12px 0 0 !important;
  font-weight: 600;
  padding: 1rem 1.25rem;
}
.card-body { padding: 1.25rem; }

/* 按钮 */
.btn { border-radius: 8px; padding: 0.5rem 1.2rem; font-weight: 500; border: none; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); }
.btn-warning { background: var(--warning); }
.btn-danger { background: var(--danger); }
.btn-outline-primary { border: 1px solid var(--primary); color: var(--primary); background: transparent; }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

/* 表格 */
.table { margin-bottom: 0; }
.table thead th {
  background: #f9fafb;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-light);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.table td { vertical-align: middle; }

/* 徽章 */
.badge { padding: 0.4em 0.8em; border-radius: 6px; font-weight: 500; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #e5e7eb; color: #374151; }

/* 统计卡片 */
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.stat-card .stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: #fff;
  margin-bottom: 1rem;
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-card .stat-label { color: var(--text-light); font-size: 0.9rem; }

/* 商品卡片 */
.goods-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: all 0.2s;
  height: 100%;
}
.goods-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.12); }
.goods-card .goods-img {
  height: 140px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 2.5rem;
}
.goods-card .goods-body { padding: 1rem; }
.goods-card .goods-name {
  font-weight: 600; font-size: 1rem;
  margin-bottom: 0.5rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}
.goods-card .goods-price { color: var(--danger); font-size: 1.3rem; font-weight: 700; }
.goods-card .goods-meta { color: var(--text-light); font-size: 0.8rem; margin-top: 0.5rem; }

/* 后台布局 */
.admin-layout, .merchant-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: #1f2937;
  color: #fff;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}
.sidebar .sidebar-header {
  padding: 1.2rem;
  font-size: 1.2rem;
  font-weight: 700;
  border-bottom: 1px solid #374151;
  text-align: center;
}
.sidebar .nav-item { padding: 0; }
.sidebar .nav-link {
  color: #d1d5db;
  padding: 0.75rem 1.2rem;
  display: flex; align-items: center; gap: 0.75rem;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}
.sidebar .nav-link:hover, .sidebar .nav-link.active {
  color: #fff;
  background: #374151;
  border-left-color: var(--primary);
}
.sidebar .nav-section {
  padding: 0.75rem 1.2rem 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #6b7280;
  letter-spacing: 1px;
}
.main-content {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
}
.topbar {
  background: #fff;
  padding: 0.8rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 50;
}
.topbar .page-title { font-size: 1.2rem; font-weight: 600; }
.content-area { padding: 1.5rem; }

/* 登录页 */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-box h2 { text-align: center; margin-bottom: 1.5rem; color: var(--text); }
.login-box .form-control { padding: 0.75rem; border-radius: 8px; }

/* 表单 */
.form-control, .form-select {
  border-radius: 8px;
  border: 1px solid var(--border);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-label { font-weight: 500; margin-bottom: 0.4rem; }

/* 分页 */
.pagination .page-link {
  border: none;
  color: var(--text);
  margin: 0 2px;
  border-radius: 6px;
}
.pagination .page-item.active .page-link {
  background: var(--primary);
  color: #fff;
}

/* 消息提示 */
.alert { border-radius: 8px; border: none; }

/* 聊天/消息样式 */
.message-list { max-height: 400px; overflow-y: auto; padding: 1rem; }
.message-item { margin-bottom: 1rem; display: flex; }
.message-item .msg-bubble {
  max-width: 70%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
}
.message-item.buyer .msg-bubble { background: #e0e7ff; color: #3730a3; }
.message-item.merchant .msg-bubble { background: #d1fae5; color: #065f46; }
.message-item.admin .msg-bubble { background: #fef3c7; color: #92400e; }
.message-item .msg-meta { font-size: 0.75rem; color: var(--text-light); margin-top: 0.25rem; }

/* 页脚 */
.footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-light);
  font-size: 0.85rem;
}

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
}
