/* ═══════ 星辰客服系统 ═══════ */
:root {
  --primary: #4E6EF2;
  --primary-light: #6B8AFF;
  --primary-dark: #3A56D4;
  --accent: #6B5CE7;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7b8d;
  --border: #e8ecf0;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif; }

body {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

/* ═══════ 主容器 ═══════ */
.app {
  width: 100%;
  max-width: 420px;
  height: 92vh;
  max-height: 700px;
  background: #0f0c29;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ═══════ 顶部品牌栏 ═══════ */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.brand-sub {
  font-size: 11px;
  opacity: 0.8;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.9;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffd700;
  animation: pulse 2s infinite;
}

.status-dot.online { background: #4ade80; }
.status-dot.offline { background: #f87171; animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ═══════ 业务选择面板 ═══════ */
.biz-select-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 24px 28px;
  background: linear-gradient(135deg, #0f0c29 0%, #1a1145 40%, #24243e 100%);
  overflow: hidden;
  position: relative;
}

/* 动态星空粒子 */
.particles {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 6px rgba(99, 102, 241, 0.8), 0 0 12px rgba(139, 92, 246, 0.4);
  animation: particleFloat linear infinite;
}

.particle:nth-child(odd) {
  width: 2px;
  height: 2px;
  background: rgba(167, 139, 250, 0.7);
  box-shadow: 0 0 4px rgba(167, 139, 250, 0.6);
}

@keyframes particleFloat {
  0% {
    transform: translateY(100%) translateX(0) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
    transform: translateY(80%) translateX(10px) scale(1);
  }
  90% {
    opacity: 0.8;
    transform: translateY(-80%) translateX(-10px) scale(0.8);
  }
  100% {
    opacity: 0;
    transform: translateY(-100%) translateX(5px) scale(0);
  }
}

/* 动态背景光晕 */
.biz-select-panel::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 40%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(139, 92, 246, 0.12) 0%, transparent 50%),
              radial-gradient(circle at 50% 80%, rgba(59, 130, 246, 0.1) 0%, transparent 40%);
  animation: bgFloat 8s ease-in-out infinite;
}

/* 浮动光球装饰 */
.biz-select-panel::after {
  content: '';
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.3), transparent 70%);
  top: 15%;
  right: -20px;
  animation: orbFloat 6s ease-in-out infinite;
  filter: blur(20px);
}

@keyframes bgFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(2%, -1%) rotate(1deg); }
  66% { transform: translate(-1%, 1%) rotate(-0.5deg); }
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.6; }
  50% { transform: translate(-15px, 20px) scale(1.2); opacity: 0.9; }
}

.biz-select-header {
  text-align: center;
  margin-bottom: 28px;
  position: relative;
  z-index: 1;
  animation: fadeInDown 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.biz-select-title {
  font-size: 21px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
  text-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.biz-select-subtitle {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 400;
}

.biz-select-list {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.biz-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 15px 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.95);
  font-family: inherit;
  position: relative;
  letter-spacing: 0.3px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  /* 交错入场动画 */
  opacity: 0;
  animation: cardSlideIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.biz-item:nth-child(1) { animation-delay: 0.1s; }
.biz-item:nth-child(2) { animation-delay: 0.18s; }
.biz-item:nth-child(3) { animation-delay: 0.26s; }
.biz-item:nth-child(4) { animation-delay: 0.34s; }
.biz-item:nth-child(5) { animation-delay: 0.42s; }
.biz-item:nth-child(6) { animation-delay: 0.5s; }

/* 左侧发光指示条 */
.biz-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #6366f1, #a78bfa);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.6);
  opacity: 0;
  transition: opacity 0.3s ease, height 0.3s ease;
}

/* 右侧箭头 */
.biz-item::after {
  content: '';
  position: absolute;
  right: 18px;
  width: 7px;
  height: 7px;
  border-top: 2px solid rgba(255, 255, 255, 0.4);
  border-right: 2px solid rgba(255, 255, 255, 0.4);
  transform: rotate(45deg);
  transition: all 0.3s ease;
}

/* Hover 效果 */
.biz-item:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateX(4px);
}

.biz-item:hover::before {
  opacity: 1;
}

.biz-item:hover::after {
  border-color: rgba(255, 255, 255, 0.9);
  transform: rotate(45deg) translate(2px, -2px);
}

.biz-item:active {
  transform: translateX(2px) scale(0.98);
  background: rgba(99, 102, 241, 0.18);
}

/* 微妙呼吸动画 - 每个卡片微微浮动 */
.biz-item:nth-child(odd) {
  animation: cardSlideIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards,
             breathe 4s ease-in-out 1.5s infinite;
}
.biz-item:nth-child(even) {
  animation: cardSlideIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards,
             breathe 4s ease-in-out 2.5s infinite;
}

@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px) translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0) translateX(0);
  }
}

@keyframes breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 投诉反馈按钮 */
.biz-select-footer {
  margin-top: 20px;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 320px;
  animation: fadeInDown 1s cubic-bezier(0.16, 1, 0.3, 1) 0.6s both;
}

.biz-select-footer .biz-item {
  animation-delay: 0.5s;
}

/* ═══════ 排队面板 ═══════ */
.queue-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  background: linear-gradient(135deg, #0f0c29 0%, #1a1145 40%, #24243e 100%);
  color: #ffffff;
}

.queue-icon {
  color: #a78bfa;
  margin-bottom: 16px;
  animation: spin 8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.queue-title {
  font-size: 18px;
  color: #ffffff;
  margin-bottom: 8px;
}

.queue-info {
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  margin-bottom: 6px;
}

.queue-info strong {
  color: #a78bfa;
  font-size: 18px;
}

.queue-hint {
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  margin-bottom: 20px;
}

.dot-pulse {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.dot-pulse::before,
.dot-pulse::after,
.dot-pulse {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a78bfa;
  animation: dotBounce 1.4s infinite ease-in-out both;
}

.dot-pulse::before { animation-delay: -0.32s; }
.dot-pulse::after { animation-delay: 0.32s; }

@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0.4); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ═══════ VIP免排队入口 ═══════ */
.vip-entry {
  margin-top: 16px;
  width: 100%;
  max-width: 280px;
}

.vip-entry-divider {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.vip-entry-divider::before,
.vip-entry-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
}

.vip-entry-divider span {
  padding: 0 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.vip-entry-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 10px;
}

.vip-entry-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.vip-btn-main {
  padding: 10px 24px;
  border: none;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  color: white;
  transition: all 0.2s;
  width: 100%;
}

.vip-btn-main:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
}

.vip-btn-main:disabled {
  opacity: 0.8;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.vip-btn-main.vip-applied {
  background: linear-gradient(135deg, #34d399, #10b981);
}

.vip-select-panel {
  margin-top: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.vip-select-title {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 10px;
}

.vip-select-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 18px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  margin: 0 4px;
  transition: all 0.2s;
}

.vip-select-btn.yearly {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #7c2d12;
}

.vip-select-btn.lifetime {
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  color: white;
}

/* ═══════ 聊天面板 ═══════ */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* 消息气泡 */
.message {
  display: flex;
  max-width: 80%;
}

.message.user {
  align-self: flex-end;
}

.message.agent {
  align-self: flex-start;
}

.message.system {
  align-self: center;
  max-width: 90%;
}

.message-content {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.message.user .message-content {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.agent .message-content {
  background: #f0f2f5;
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.message.system .message-content {
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 6px 12px;
}

/* 消息时间 */
.message-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.message.user .message-time { text-align: right; }

/* ═══════ 输入区域 ═══════ */
.input-area {
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border);
  background: white;
  flex-shrink: 0;
}

.input-toolbar {
  display: flex;
  gap: 4px;
  padding: 0 4px 6px;
}

.toolbar-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.toolbar-btn:hover {
  background: #f0f2f5;
  color: var(--primary);
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: #f5f7fa;
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(78, 110, 242, 0.1);
}

#inputMsg {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text);
  padding: 8px 0;
}

#inputMsg::placeholder { color: #adb5bd; }

.btn-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  flex-shrink: 0;
}

.btn-send:hover { transform: scale(1.05); }
.btn-send:active { transform: scale(0.95); }

/* ═══════ Emoji面板 ═══════ */
.emoji-panel {
  border-top: 1px solid var(--border);
  background: white;
  padding: 8px;
  max-height: 200px;
  display: flex;
  flex-direction: column;
}

.emoji-tabs {
  display: flex;
  gap: 2px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  overflow-x: auto;
}

.emoji-tab {
  border: none;
  background: transparent;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.15s;
}

.emoji-tab:hover { background: #f0f2f5; }
.emoji-tab.active { background: #e8ecff; }

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  overflow-y: auto;
  flex: 1;
}

.emoji-item {
  font-size: 20px;
  padding: 4px;
  text-align: center;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.1s;
  line-height: 1.4;
}

.emoji-item:hover { background: #f0f2f5; }

/* ═══════ 图片消息 ═══════ */
.msg-image {
  max-width: 200px;
  max-height: 200px;
  border-radius: 12px;
  cursor: pointer;
  object-fit: cover;
}

.uploading {
  color: var(--text-muted);
  font-style: italic;
  font-size: 12px;
}

.upload-failed {
  color: #ef4444;
  font-size: 12px;
}

/* ═══════ 拖拽覆盖层 ═══════ */
.drop-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(78, 110, 242, 0.15);
  border: 3px dashed var(--primary);
  border-radius: var(--radius);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
}

.drop-overlay.active { display: flex; }

.drop-hint {
  background: var(--primary);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}

/* ═══════ 图片灯箱 ═══════ */
.lightbox {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  cursor: pointer;
}

.lightbox-img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  font-size: 32px;
  cursor: pointer;
}

/* ═══════ 结束面板 ═══════ */
.ended-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  background: linear-gradient(135deg, #0f0c29 0%, #1a1145 40%, #24243e 100%);
}

.ended-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #4ade80, #22c55e);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  margin-bottom: 16px;
}

.ended-panel h2 {
  color: #ffffff;
  margin-bottom: 8px;
}

.ended-panel p {
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  margin-bottom: 24px;
}

.btn-restart {
  padding: 10px 28px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s;
}

.btn-restart:hover { transform: scale(1.03); }

/* ═══════ 页面内弹框提醒 ═══════ */
.in-page-alert {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  padding: 12px 20px;
  z-index: 10000;
  min-width: 220px;
  max-width: 320px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border-left: 4px solid var(--primary);
}

.in-page-alert.show {
  transform: translateX(-50%) translateY(0);
}

.in-page-alert-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.in-page-alert-body {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════ 响应式 ═══════ */
@media (max-width: 480px) {
  body { padding: 0; }
  .app {
    max-width: 100%;
    height: 100vh;
    max-height: none;
    border-radius: 0;
  }
  .biz-select-panel {
    padding: 28px 18px 20px;
  }
  .biz-select-list {
    max-width: 100%;
    gap: 9px;
  }
  .biz-item {
    padding: 14px 18px;
    font-size: 14px;
  }
  .biz-select-footer {
    max-width: 100%;
  }
}
