/* ============================================================
 * 澳妆 AI 智能体 - 共用设计系统 (v12 马卡龙改版)
 * 所有页面 <link> 此文件 + 每页 body[data-theme="..."] 切主题
 * 主题: index=樱花粉 / skincare=薄荷绿 / live=鹅黄 / member=淡紫 / admin=蜜桃橙
 * ============================================================ */

:root {
  /* ---- 基底共用色 (所有页面统一) ---- */
  --bg: #fff9f5;            /* 暖白基底 */
  --surface: #ffffff;        /* 主卡片底 */
  --surface-2: #fff5f0;      /* 次级卡片/分区 */
  --surface-3: #fff0ea;      /* 三级背景 (块容器) */
  --border: #f0e0d8;         /* 暖灰边 */
  --border-strong: #e0c8bc;  /* 强调边 */
  --text: #2c1f25;           /* 主文字 (深棕黑, WCAG AA 4.5:1+) */
  --text-muted: #7a6872;     /* 次要文字 */
  --text-light: #a89594;     /* 极弱文字 */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 3px rgba(212, 92, 138, 0.04);
  --shadow: 0 4px 12px rgba(212, 92, 138, 0.06);
  --shadow-lg: 0 8px 24px rgba(212, 92, 138, 0.12);

  /* ---- 功能色 ---- */
  --success: #4caf92;
  --warn: #d4a72c;
  --danger: #e76f51;
  --info: #5b9bd5;

  /* ---- 默认主题 (index 樱花粉) ---- */
  --accent: #e91e63;
  --accent-soft: #f8bbd0;
  --accent-bg: #fff0f5;
  --accent-rgb: 233, 30, 99;

  /* ---- 各主题色板 (跨页按钮引用, 不随 body[data-theme] 变) ---- */
  --index-accent: #e91e63;
  --skincare-accent: #2e9e6e;
  --live-accent: #d4a72c;
  --member-accent: #8e6bb8;
  --admin-accent: #e76f51;
  --info-accent: #5b9bd5;
  --crm-accent: #e74c3c;
  --reference-accent: #9b59b6;
}

/* ---- 5 套主题 override ---- */
body[data-theme="index"] {
  --accent: #e91e63;
  --accent-soft: #f8bbd0;
  --accent-bg: #fff0f5;
  --accent-rgb: 233, 30, 99;
}
body[data-theme="skincare"] {
  --accent: #2e9e6e;
  --accent-soft: #b8e0d2;
  --accent-bg: #eaf6ee;
  --accent-rgb: 46, 158, 110;
}
body[data-theme="live"] {
  --accent: #d4a72c;
  --accent-soft: #fce4a4;
  --accent-bg: #fff8e6;
  --accent-rgb: 212, 167, 44;
}
body[data-theme="member"] {
  --accent: #8e6bb8;
  --accent-soft: #d4c5e2;
  --accent-bg: #f5edf8;
  --accent-rgb: 142, 107, 184;
}
body[data-theme="admin"] {
  --accent: #e76f51;
  --accent-soft: #fbc4ab;
  --accent-bg: #fff0ea;
  --accent-rgb: 231, 111, 81;
}

/* ============================================================
 * Reset + 基础排版
 * ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
*::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { opacity: .85; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ============================================================
 * 抬头导航 (.app-header + .header-btns)
 * 统一 6 按钮: 🏠首页/🌿芳疗/🎬直播/📋会员/📚资料/🔗CRM
 * ============================================================ */
.app-header {
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--accent-bg) 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.header-row1 { flex: none; }
.header-row1 h1 {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  margin: 0;
}
.header-row2 { flex: none; }
.header-row2 .subtitle {
  font-size: 11px;
  margin: 0;
  color: var(--text-muted);
  line-height: 1.4;
  word-break: break-word;
}
.header-row3 { flex: none; display: block; }

/* 抬头 6 按钮导航 */
.header-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 8px 0 4px;
  flex-basis: 100%;
}
.header-btns a {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
  transition: opacity .2s, transform .2s;
  color: #fff;
}
.header-btns a:hover {
  opacity: .85;
  transform: translateY(-1px);
}
.header-btns .btn-home {
  background: var(--index-accent);
  color: #fff;
}
/* v12.1: 加强 current 状态 - 深色粗 outline + 双层阴影 + 加粗, 让当前页明显突出 */
.header-btns .btn-home.current {
  outline: 2px solid var(--text);
  outline-offset: -2px;
  box-shadow: 0 0 0 1px var(--surface), 0 4px 12px rgba(0,0,0,.25);
  font-weight: 800;
  opacity: 1;
}
.header-btns .btn-chat.current {
  outline: 2px solid var(--text);
  outline-offset: -2px;
  box-shadow: 0 0 0 1px var(--surface), 0 4px 12px rgba(0,0,0,.25);
  font-weight: 800;
  opacity: 1;
}
/* v12.1: 非 current 按钮半透明, 让 current 突出 */
.header-btns .btn-chat:not(.current),
.header-btns .btn-home:not(.current) {
  opacity: .65;
}
.header-btns .btn-chat:not(.current):hover,
.header-btns .btn-home:not(.current):hover {
  opacity: 1;
}
.header-btns .btn-skincare { background: var(--skincare-accent); color: #fff; }
.header-btns .btn-live { background: var(--live-accent); color: #fff; }
.header-btns .btn-member { background: var(--member-accent); color: #fff; }
.header-btns .btn-info { background: var(--info-accent); color: #fff; }
.header-btns .btn-crm { background: var(--crm-accent); color: #fff; }
.header-btns .btn-reference { background: var(--reference-accent); color: #fff; }
.header-btns .btn-card { background: var(--info-accent); color: #fff; box-shadow: var(--shadow-sm); }

@media (max-width: 520px) {
  .header-btns { flex-wrap: wrap; }
  .header-btns a {
    font-size: 10px;
    padding: 5px 4px;
    flex: 0 0 auto;
    min-width: 0;
    text-align: center;
    white-space: nowrap;
  }
}

/* ============================================================
 * 登录区 (.login-card / .login-row / .login-mode-tabs)
 * ============================================================ */
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 22px;
  max-width: 380px;
  width: 100%;
  margin: 0 auto;
  box-shadow: var(--shadow);
}
.login-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
  text-align: center;
}
.login-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.login-row input, .login-input {
  flex: 1;
  min-width: 80px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.login-row input:focus, .login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.15);
}
.login-row button, .login-btn {
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .2s;
}
.login-row button:disabled, .login-btn:disabled {
  background: var(--text-light);
  cursor: not-allowed;
  opacity: .6;
}
.login-mode-tabs {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-bottom: 8px;
}
.login-mode-btn {
  padding: 4px 12px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all .2s;
}
.login-mode-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.login-mode-btn:hover { opacity: .85; }

.login-msg {
  font-size: 12px;
  text-align: center;
  padding: 4px;
  min-height: 18px;
  color: var(--text-muted);
}
.login-msg.ok { color: var(--success); background: rgba(76, 175, 146, .1); padding: 6px 8px; border-radius: var(--radius-xs); border: 1px solid rgba(76, 175, 146, .3); font-weight: 600; }
.login-msg.err { color: var(--danger); background: rgba(231, 111, 81, .1); padding: 6px 8px; border-radius: var(--radius-xs); border: 1px solid rgba(231, 111, 81, .3); font-weight: 600; animation: shake .4s ease-in-out; }
.login-msg.loading { color: var(--accent); background: var(--accent-bg); padding: 6px 8px; border-radius: var(--radius-xs); border: 1px solid var(--accent-soft); animation: pulse-bg 1.5s ease-in-out infinite; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
@keyframes pulse-bg {
  0%, 100% { background: var(--accent-bg); }
  50% { background: var(--accent-soft); }
}

/* ============================================================
 * Tab 切换 (.nav-tabs / .nav-tab)
 * member/admin 用 7/4 tab; live 改 .tabs button→.nav-tab
 * ============================================================ */
.nav-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: sticky;
  top: 52px;
  z-index: 99;
}
.nav-tab {
  flex: 1;
  min-width: 80px;
  text-align: center;
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  white-space: nowrap;
  transition: all .2s;
}
.nav-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(var(--accent-rgb), .06);
}
.nav-tab:hover {
  color: var(--text);
  background: rgba(var(--accent-rgb), .03);
}

/* ============================================================
 * 卡片 (.card / .card.section)
 * ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px;
  box-shadow: var(--shadow-sm);
}
.card.section {
  /* 用于 tab 内分区卡片 */
  margin: 10px 12px;
  padding: 14px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ============================================================
 * 按钮组 (.btn)
 * ============================================================ */
.btn {
  display: inline-block;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
}
.btn:hover { opacity: .85; transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 12px; }

/* loading 动画 */
.btn-loading {
  position: relative;
  opacity: .7;
  cursor: wait !important;
}
.btn-loading::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin .8s linear infinite;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
 * 弹窗 (.modal-overlay / .modal)
 * ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 31, 37, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
}
.modal-close {
  float: right;
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--danger); }

/* ============================================================
 * Toast 浮层提示
 * ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 300;
  max-width: 90%;
  text-align: center;
}
.toast.info { border-color: var(--info); color: var(--info); }
.toast.ok { border-color: var(--success); color: var(--success); }
.toast.err { border-color: var(--danger); color: var(--danger); }

/* ============================================================
 * 表单 (.input / .textarea)
 * ============================================================ */
.input, .textarea, input[type="text"], input[type="tel"], input[type="password"], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus, .textarea:focus, input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .15);
}
.textarea { resize: vertical; min-height: 60px; max-height: 200px; }
.input-error {
  border-color: var(--danger) !important;
  background: rgba(231, 111, 81, .05) !important;
  animation: shake .4s ease-in-out;
}

/* ============================================================
 * 对话气泡 (index 首页 + 其他页可能复用)
 * ============================================================ */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(180deg, var(--accent-bg) 0%, var(--bg) 100%);
}
.msg {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  align-items: flex-start;
}
.msg.bot { margin-bottom: 24px; justify-content: flex-start; }
.msg.user { flex-direction: row-reverse; justify-content: flex-start; }
.msg .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.bot-avatar {
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--accent) 100%);
  box-shadow: 0 2px 4px rgba(var(--accent-rgb), .2);
}
.msg.user .avatar {
  background: linear-gradient(135deg, var(--text-muted) 0%, var(--text) 100%);
}
.bubble-wrap {
  position: relative;
  max-width: 86%;
}
.msg.bot .bubble-wrap { flex: 1; min-width: 0; }
.bubble {
  max-width: 86%;
  padding: 8px 12px;
  border-radius: 4px 14px 14px 14px;
  word-wrap: break-word;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 2px 6px rgba(var(--accent-rgb), .08);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.msg.user .bubble {
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--accent) 100%);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 14px 4px 14px 14px;
}
.bubble pre.code {
  background: #2d3138;
  color: #e5e7eb;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  overflow-x: auto;
  font-size: 12px;
  margin: 6px 0;
}
.bubble code.inline {
  background: rgba(0,0,0,.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 13px;
}
.bubble ul { margin: 4px 0 4px 18px; }
.bubble strong { font-weight: 600; }
.bubble .typing { color: var(--text-muted); }
.bubble .err { color: var(--danger); }

/* 复制按钮 (AI 气泡右下角) */
.copy-btn {
  position: absolute;
  right: 4px;
  bottom: -18px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  opacity: .55;
  transition: opacity .2s, color .2s, border-color .2s;
}
.copy-btn:hover { opacity: 1; color: var(--accent); border-color: var(--accent); }
.copy-btn.copied { opacity: 1; color: var(--success); border-color: var(--success); }

/* 快捷问题按钮组 (首页) */
.quick-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 10px;
  flex-shrink: 0;
}
.quick-btn {
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s, color .2s;
}
.quick-btn:active { background: var(--accent); color: #fff; }

/* 输入栏 */
.input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.input-bar textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  max-height: 120px;
  min-height: 36px;
}
.input-bar button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.input-bar button:disabled { opacity: .5; }

/* ============================================================
 * 通用工具类
 * ============================================================ */
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.hidden { display: none; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
.rounded { border-radius: var(--radius-sm); }

/* 错误状态 (输入框抖动) */
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: .7; }
}
