/* LUMIÈRE Admin - 明亮高级风格 */

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

:root {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #86868b;
  --border: #e8e8ed;
  --border-light: #f0f0f5;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-light: rgba(0,113,227,0.06);
  --success: #30d158;
  --warning: #ff9f0a;
  --danger: #ff3b30;
  --purple: #bf5af2;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --sidebar-w: 240px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== 侧边栏 ===== */
.admin-sidebar {
  width: var(--sidebar-w); background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}

.sidebar-brand {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.brand-icon { font-size: 22px; }
.brand-text { font-size: 17px; font-weight: 700; letter-spacing: 0.5px; }

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 24px; color: var(--text-secondary);
  text-decoration: none; font-size: 14px; font-weight: 500;
  transition: all 0.2s; border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  color: var(--accent); background: var(--accent-light);
  border-left-color: var(--accent);
}
.nav-icon { font-size: 17px; }

.sidebar-footer {
  padding: 12px 0; border-top: 1px solid var(--border);
}

/* ===== 主区域 ===== */
.admin-main {
  margin-left: var(--sidebar-w); flex: 1; min-height: 100vh;
}

.admin-topbar {
  padding: 16px 32px; background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 50;
}
.admin-topbar h1 { font-size: 20px; font-weight: 700; }
.topbar-right { color: var(--text-muted); font-size: 14px; }

.admin-page { display: none; padding: 24px 32px; }
.admin-page.active { display: block; }

/* ===== 统计卡片 ===== */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 20px; display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow); transition: all 0.3s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon-wrap {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.stat-info { flex: 1; }
.stat-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 2px; }
.stat-value { display: block; font-size: 24px; font-weight: 700; }
.stat-trend { font-size: 12px; font-weight: 600; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ===== 图表 ===== */
.charts-row {
  display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 24px;
}
.chart-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.chart-card h3 { font-size: 15px; color: var(--text-secondary); margin-bottom: 16px; font-weight: 600; }
.chart-container { height: 200px; display: flex; align-items: flex-end; }

/* 柱状图 */
.bar-chart { flex: 1; display: flex; align-items: flex-end; gap: 12px; height: 100%; }
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bar {
  width: 100%; max-width: 48px; border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--accent), rgba(0,113,227,0.3));
  transition: height 0.8s ease;
}
.bar:hover { background: linear-gradient(180deg, var(--accent), rgba(0,113,227,0.6)); }
.bar-label { font-size: 11px; color: var(--text-muted); }
.bar-value { font-size: 11px; color: var(--text-secondary); }

/* 环形图 */
.donut-chart { display: flex; align-items: center; justify-content: center; gap: 20px; height: 100%; }
.donut-svg { width: 140px; height: 140px; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ===== 卡片 ===== */
.card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.card-link { font-size: 13px; color: var(--accent); text-decoration: none; }
.card-link:hover { text-decoration: underline; }

/* ===== 表格 ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 10px 12px; font-size: 12px;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px; border-bottom: 1px solid var(--border-light); font-size: 14px;
}
.data-table tr:hover td { background: var(--accent-light); }

/* ===== 状态标签 ===== */
.status {
  display: inline-block; padding: 3px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 600;
}
.status-completed, .status-active { background: rgba(48,209,88,0.1); color: var(--success); }
.status-shipped { background: rgba(0,113,227,0.1); color: var(--accent); }
.status-pending { background: rgba(255,149,10,0.1); color: var(--warning); }
.status-inactive { background: rgba(134,134,139,0.1); color: var(--text-muted); }
.status-lowstock { background: rgba(255,59,48,0.1); color: var(--danger); }

/* ===== 工具栏 ===== */
.page-toolbar {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.toolbar-actions { display: flex; gap: 10px; align-items: center; }

.search-box input {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text); padding: 8px 16px; border-radius: 8px;
  font-size: 14px; width: 240px; outline: none; transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

select {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text); padding: 8px 12px; border-radius: 8px;
  font-size: 14px; outline: none;
}

/* ===== 按钮 ===== */
.btn {
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 500; transition: all 0.2s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: rgba(255,59,48,0.06); }
.btn-success { color: var(--success); border-color: var(--success); }
.btn-success:hover { background: rgba(48,209,88,0.06); }

/* ===== 筛选 ===== */
.filter-group { display: flex; gap: 8px; }
.filter-btn {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-card); color: var(--text-secondary); cursor: pointer;
  font-size: 13px; transition: all 0.2s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== 客户卡片 ===== */
.customers-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.customer-card {
  background: var(--bg-card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); transition: all 0.3s;
}
.customer-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.customer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.customer-name { font-weight: 600; }
.customer-level {
  padding: 2px 10px; border-radius: 8px; font-size: 11px; font-weight: 600;
}
.level-普通 { background: rgba(134,134,139,0.1); color: var(--text-muted); }
.level-银卡 { background: rgba(142,142,147,0.1); color: #8e8e93; }
.level-金卡 { background: rgba(255,149,10,0.1); color: var(--warning); }
.level-钻石 { background: rgba(191,90,242,0.1); color: var(--purple); }
.customer-stats { display: flex; gap: 16px; margin-top: 8px; font-size: 13px; color: var(--text-secondary); }
.customer-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-light); }

/* ===== AI 页面 ===== */
.ai-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; height: calc(100vh - 140px); }
.ai-tools-panel { display: flex; flex-direction: column; gap: 10px; }
.ai-tools-panel h3 { font-size: 14px; color: var(--text-secondary); font-weight: 600; }
.tool-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px; cursor: pointer; transition: all 0.2s; box-shadow: var(--shadow);
}
.tool-card:hover { border-color: var(--accent); background: var(--accent-light); }
.tool-icon { font-size: 20px; }
.tool-name { font-weight: 600; display: block; margin-bottom: 4px; }
.tool-card p { font-size: 12px; color: var(--text-muted); margin: 0; }

.ai-chat-panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow);
}
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.chat-msg { display: flex; gap: 10px; max-width: 80%; }
.chat-msg.ai { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 32px; height: 32px; display: flex; align-items: center;
  justify-content: center; font-size: 16px; flex-shrink: 0;
}
.msg-content {
  padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.6;
}
.chat-msg.ai .msg-content { background: var(--bg); border: 1px solid var(--border); }
.chat-msg.user .msg-content { background: var(--accent-light); border: 1px solid rgba(0,113,227,0.2); }
.chat-input-area {
  padding: 14px; border-top: 1px solid var(--border); display: flex; gap: 10px;
}
.chat-input-area input {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 10px 14px; border-radius: 10px;
  font-size: 14px; outline: none;
}
.chat-input-area input:focus { border-color: var(--accent); }

/* ===== 模态框 ===== */
.modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.3); backdrop-filter: blur(4px);
  z-index: 1000; align-items: center; justify-content: center;
}
.modal.active { display: flex; }
.modal-content {
  background: var(--bg-card); border-radius: var(--radius);
  width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 22px; cursor: pointer;
}
.modal-close:hover { color: var(--text); }

.modal-form { padding: 20px 24px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); font-weight: 500; margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 8px 12px; border-radius: 8px;
  font-size: 14px; outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.input-with-ai { display: flex; gap: 8px; align-items: flex-start; }
.input-with-ai textarea { flex: 1; }
.ai-btn {
  padding: 8px 14px; background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff; border: none; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 600; white-space: nowrap; transition: all 0.2s;
}
.ai-btn:hover { box-shadow: 0 4px 12px rgba(0,113,227,0.3); transform: translateY(-1px); }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(80px);
  padding: 12px 24px; border-radius: 980px; font-size: 14px;
  opacity: 0; transition: all 0.3s; z-index: 2000;
  background: var(--text); color: #fff;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .ai-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-main { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr; }
}
