/* ========================================
   太白云庐 · 智能客服 — 高端售楼处主题
   ======================================== */

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

:root {
  --gold:         #C9A96E;
  --gold-light:   #D4B87A;
  --gold-dark:    #B8943A;
  --gold-pale:    rgba(201,169,110,0.12);
  --gold-faint:   rgba(201,169,110,0.06);

  --bg-deep:      #080C12;
  --bg-surface:   #0F1722;
  --bg-card:      #162032;
  --bg-input:     #1B2735;
  --bg-bubble-bot:#15202F;

  --text-primary: #E8E0D5;
  --text-secondary:#9A9488;
  --text-muted:   #6B6560;

  --border:       #1E2D3D;
  --border-gold:  rgba(201,169,110,0.25);

  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --radius-xl:    20px;

  --shadow-sm:    0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.5);
  --shadow-gold:  0 0 20px rgba(201,169,110,0.08);

  --safe-bottom:  env(safe-area-inset-bottom, 12px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-deep);
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  color: var(--text-primary);
}

/* ========== Background Texture ========== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(201,169,110,0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(201,169,110,0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ========== Container ========== */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-deep);
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-lg);
}

/* ========== Header ========== */
.chat-header {
  background: linear-gradient(180deg, #0F1926 0%, #0C141F 100%);
  padding: 10px 16px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--border);
}

/* Gold accent line at header bottom */
.chat-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 16px; right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
  opacity: 0.5;
}

.header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1A2740 0%, #0F1926 100%);
  border: 1.5px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: var(--shadow-gold);
}

.header-info { flex: 1; min-width: 0; }

.header-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.header-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.3px;
}

.header-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #0A0E14;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.5px;
}

/* ========== Messages Area ========== */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(circle at 50% 20%, rgba(201,169,110,0.02) 0%, transparent 50%);
}
.messages-area::-webkit-scrollbar { width: 3px; }
.messages-area::-webkit-scrollbar-thumb { background: rgba(201,169,110,0.15); border-radius: 2px; }

/* ========== Time Divider ========== */
.time-divider {
  text-align: center;
  padding: 10px 0;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ========== System Message ========== */
.sys-msg {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 14px;
  background: var(--bg-surface);
  border-radius: 4px;
  align-self: center;
  max-width: 80%;
  border: 1px solid rgba(255,255,255,0.03);
}

/* ========== Message Rows ========== */
.msg-row {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: msgIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.msg-row.bot { align-self: flex-start; }
.msg-row.user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.msg-row.bot .msg-avatar {
  background: linear-gradient(135deg, #1A2740, #0F1926);
  border: 1px solid var(--border-gold);
}
.msg-row.user .msg-avatar {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #0A0E14;
  font-weight: 700;
  font-size: 13px;
}

/* ========== Message Bubbles ========== */
.msg-bubble {
  padding: 11px 15px;
  border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
  position: relative;
}
.msg-row.bot .msg-bubble {
  background: var(--bg-bubble-bot);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: var(--shadow-sm);
}
.msg-row.user .msg-bubble {
  background: linear-gradient(135deg, #B08A3C, #C9A96E);
  color: #0A0E14;
  border-radius: var(--radius-md) 4px var(--radius-md) var(--radius-md);
  box-shadow: 0 2px 12px rgba(201,169,110,0.2);
  font-weight: 450;
}

.msg-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
  letter-spacing: 0.3px;
}
.msg-row.user .msg-time { text-align: right; }

/* ========== Price Highlight ========== */
.price-highlight {
  color: var(--gold-light);
  font-weight: 700;
  font-size: 16px;
}

/* ========== Quick Replies ========== */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0 2px;
}
.quick-btn {
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 12.5px;
  border: 1px solid var(--border-gold);
  color: var(--gold-light);
  background: var(--gold-faint);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  font-family: inherit;
  backdrop-filter: blur(4px);
}
.quick-btn:active {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #0A0E14;
  transform: scale(0.96);
  border-color: transparent;
  box-shadow: 0 0 16px rgba(201,169,110,0.25);
}

/* ========== Card Messages ========== */
.card-msg {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  width: 100%;
  border: 1px solid rgba(255,255,255,0.04);
}
.card-img {
  width: 100%;
  height: 150px;
  background: linear-gradient(135deg, #1A2740 0%, #0F1926 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: rgba(201,169,110,0.3);
  position: relative;
  overflow: hidden;
}
.card-img::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(to top, var(--bg-card), transparent);
}
.card-body { padding: 14px 16px; }
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}
.card-title .gold-line {
  display: inline-block;
  width: 3px; height: 14px;
  background: var(--gold);
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: middle;
  margin-top: -2px;
}
.card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.card-tag {
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--gold-pale);
  color: var(--gold-light);
  font-weight: 500;
  border: 1px solid rgba(201,169,110,0.15);
}
.card-actions { display: flex; border-top: 1px solid var(--border); }
.card-action {
  flex: 1;
  text-align: center;
  padding: 11px;
  font-size: 13px;
  color: var(--gold-light);
  cursor: pointer;
  border: none;
  background: none;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: background 0.15s;
  font-family: inherit;
}
.card-action:active { background: var(--gold-faint); }
.card-action + .card-action { border-left: 1px solid var(--border); }

/* ========== Typing Indicator ========== */
.typing-dots {
  display: flex; gap: 5px; padding: 13px 16px; align-items: center;
}
.typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold-dark);
  opacity: 0.5;
  animation: typing 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ========== Input Area ========== */
.input-area {
  padding: 10px 14px;
  padding-bottom: max(10px, var(--safe-bottom));
  background: var(--bg-surface);
  display: flex;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}
.input-area::before {
  content: '';
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201,169,110,0.1), transparent);
}
.input-area input {
  flex: 1;
  padding: 11px 16px;
  border-radius: 22px;
  border: 1px solid var(--border);
  font-size: 14px;
  outline: none;
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.input-area input::placeholder { color: var(--text-muted); }
.input-area input:focus {
  border-color: var(--gold-dark);
  box-shadow: 0 0 0 3px rgba(201,169,110,0.08);
}
.send-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #0A0E14;
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(201,169,110,0.2);
}
.send-btn:active {
  transform: scale(0.9);
  box-shadow: 0 0 20px rgba(201,169,110,0.35);
}
.send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  box-shadow: none;
}

/* ========== Call Button (inline) ========== */
.call-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #0A0E14;
  border-radius: 22px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  font-family: inherit;
  letter-spacing: 0.3px;
}
.call-btn:active { opacity: 0.85; transform: scale(0.97); }

/* ========== Lead Form Overlay ========== */
.form-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.25s;
}
.form-panel {
  background: var(--bg-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 28px 22px 36px;
  width: 100%;
  max-width: 480px;
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  border-top: 1px solid var(--border-gold);
  position: relative;
}
.form-panel::before {
  content: '';
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.form-panel h3 {
  font-size: 18px;
  margin-bottom: 4px;
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.form-panel p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 22px;
}
.form-panel label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}
.form-panel input {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  margin-bottom: 14px;
  outline: none;
  font-family: inherit;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.25s, box-shadow 0.25s;
}
.form-panel input::placeholder { color: var(--text-muted); }
.form-panel input:focus {
  border-color: var(--gold-dark);
  box-shadow: 0 0 0 3px rgba(201,169,110,0.08);
}
.form-submit {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #0A0E14;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 1px;
  box-shadow: 0 4px 14px rgba(201,169,110,0.25);
  transition: all 0.2s ease;
}
.form-submit:active {
  transform: scale(0.98);
  box-shadow: 0 0 24px rgba(201,169,110,0.35);
}
.form-close {
  position: absolute;
  top: 18px; right: 18px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s;
  z-index: 2;
}
.form-close:active { background: rgba(201,169,110,0.1); color: var(--gold-light); }

/* ========== Toast ========== */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 10px 22px;
  border-radius: 22px;
  font-size: 13px;
  z-index: 200;
  animation: fadeIn 0.3s;
  border: 1px solid var(--border-gold);
  box-shadow: var(--shadow-md);
  letter-spacing: 0.3px;
}

/* ========== Welcome Message ========== */
.welcome-card {
  background: linear-gradient(135deg, #0F1926 0%, #162032 100%);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  text-align: center;
  animation: msgIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.welcome-card .welcome-logo {
  font-size: 36px;
  margin-bottom: 8px;
}
.welcome-card h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: 1px;
}
.welcome-card .welcome-line {
  width: 40px; height: 2px;
  background: var(--gold);
  margin: 8px auto;
  border-radius: 1px;
}
.welcome-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ========== Animations ========== */
@keyframes msgIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-6px); opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes pulseGold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,169,110,0.2); }
  50%      { box-shadow: 0 0 0 6px rgba(201,169,110,0); }
}
