/* ==================== 赛博女友 - 样式 ==================== */

:root {
  --bg: #0a0a1a;
  --bg-card: #12122a;
  --bg-chat: #1a1a35;
  --bg-input: #0d0d25;
  --text: #e0e0f0;
  --text-dim: #8888aa;
  --accent: #ff6b9d;
  --accent2: #ff85b3;
  --accent-glow: rgba(255, 107, 157, 0.3);
  --user-bubble: #2a1a3a;
  --ai-bubble: #1a2a3a;
  --border: #2a2a4a;
  --affection-bar: linear-gradient(90deg, #ff6b9d, #ff85b3, #ffb3d9);
  --neon: 0 0 20px rgba(255, 107, 157, 0.4);
}

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

body {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==================== 粒子背景 ==================== */
#particles {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}

/* ==================== 主容器 ==================== */
#app {
  position: relative; z-index: 1;
  width: 100%; max-width: 900px;
  height: 100vh; max-height: 700px;
  display: flex;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(255, 107, 157, 0.15), 0 0 120px rgba(100, 100, 255, 0.08);
  border: 1px solid var(--border);
}

/* ==================== 左侧 - 角色区域 ==================== */
.character-panel {
  width: 360px;
  min-width: 360px;
  background: linear-gradient(180deg, #0d0d28 0%, #12123a 50%, #1a1a45 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 20px;
  position: relative;
  border-right: 1px solid var(--border);
}

.character-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(255, 107, 157, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

/* 角色名字 */
.char-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent2);
  text-shadow: var(--neon);
  margin-bottom: 4px;
  letter-spacing: 2px;
}

.char-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

/* ==================== CSS 角色 ==================== */
.character {
  position: relative;
  width: 200px; height: 280px;
  animation: float 3s ease-in-out infinite;
  cursor: pointer;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.character:active {
  animation: float 3s ease-in-out infinite, bounce 0.3s ease-out;
}

@keyframes bounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* 光环 */
.char-glow {
  position: absolute;
  top: 50%; left: 50%;
  width: 180px; height: 180px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 107, 157, 0.15) 0%, transparent 70%);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

/* 头部 */
.char-head {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 120px; height: 130px;
}

/* 头发后面 */
.char-hair-back {
  position: absolute;
  top: -5px; left: -10px;
  width: 140px; height: 100px;
  background: linear-gradient(180deg, #2d1b3d 0%, #1a0a2e 100%);
  border-radius: 70px 70px 20px 20px;
}

/* 脸 */
.char-face {
  position: absolute;
  top: 10px; left: 10px;
  width: 100px; height: 100px;
  background: linear-gradient(180deg, #ffe4c9 0%, #fcd5b5 100%);
  border-radius: 50%;
}

/* 头发前面（刘海） */
.char-hair-front {
  position: absolute;
  top: 5px; left: 5px;
  width: 110px; height: 65px;
  background: linear-gradient(180deg, #3d2660 0%, #2d1b3d 100%);
  border-radius: 55px 55px 0 0;
  z-index: 2;
}

/* 侧发 */
.char-hair-left {
  position: absolute;
  top: 20px; left: -2px;
  width: 25px; height: 90px;
  background: #2d1b3d;
  border-radius: 30px 0 0 30px;
  z-index: 2;
}

.char-hair-right {
  position: absolute;
  top: 20px; right: -2px;
  width: 25px; height: 90px;
  background: #2d1b3d;
  border-radius: 0 30px 30px 0;
  z-index: 2;
}

/* 眼睛 */
.char-eyes {
  position: absolute;
  top: 45px; left: 50%;
  transform: translateX(-50%);
  width: 60px; height: 20px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
}

.char-eye {
  width: 20px; height: 24px;
  background: #1a1a2e;
  border-radius: 50%;
  position: relative;
  animation: blink 4s ease-in-out infinite;
}

@keyframes blink {
  0%, 94%, 100% { transform: scaleY(1); }
  97% { transform: scaleY(0.1); }
}

.char-eye::after {
  content: '';
  position: absolute;
  top: 6px; left: 4px;
  width: 8px; height: 8px;
  background: white;
  border-radius: 50%;
}

/* 腮红 */
.char-blush {
  position: absolute;
  top: 60px;
  width: 16px; height: 10px;
  background: rgba(255, 150, 150, 0.5);
  border-radius: 50%;
  z-index: 3;
  filter: blur(3px);
}

.char-blush-left { left: 18px; }
.char-blush-right { right: 18px; }

/* 嘴巴 */
.char-mouth {
  position: absolute;
  top: 72px; left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  transition: all 0.3s ease;
}

/* 默认微笑 */
.mouth-default {
  width: 16px; height: 8px;
  border-bottom: 2.5px solid #d4747a;
  border-radius: 0 0 10px 10px;
}

.mouth-happy {
  width: 20px; height: 12px;
  border-bottom: 3px solid #d4747a;
  border-radius: 0 0 16px 16px;
}

.mouth-shy {
  width: 12px; height: 6px;
  border-bottom: 2px solid #d4747a;
  border-radius: 0 0 6px 6px;
}

.mouth-sad {
  width: 14px; height: 8px;
  border-top: 2.5px solid #d4747a;
  border-radius: 10px 10px 0 0;
}

.mouth-surprised {
  width: 12px; height: 12px;
  background: #d4747a;
  border-radius: 50%;
}

.mouth-talking {
  width: 18px; height: 14px;
  background: #d4747a;
  border-radius: 50%;
  animation: talk 0.3s ease-in-out infinite;
}

@keyframes talk {
  0%, 100% { transform: scaleY(0.4) scaleX(1.1); }
  50% { transform: scaleY(1) scaleX(0.9); }
}

/* 身体 */
.char-body {
  position: absolute;
  top: 125px; left: 50%;
  transform: translateX(-50%);
  width: 90px; height: 80px;
}

.char-body::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 80px; height: 70px;
  background: linear-gradient(180deg, #ff6b9d 0%, #ff85b3 100%);
  border-radius: 15px 15px 5px 5px;
}

/* 领结 */
.char-body::after {
  content: '';
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  width: 20px; height: 14px;
  background: white;
  border-radius: 3px 3px 10px 10px;
  z-index: 1;
}

/* 好感度条 */
.affection-section {
  width: 100%;
  margin-top: 15px;
}

.affection-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.affection-value {
  color: var(--accent);
  font-weight: 600;
}

.affection-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.affection-bar-fill {
  height: 100%;
  background: var(--affection-bar);
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(255, 107, 157, 0.5);
}

.affection-level {
  text-align: center;
  font-size: 11px;
  color: var(--accent2);
  margin-top: 4px;
  text-shadow: 0 0 8px rgba(255, 107, 157, 0.3);
}

/* 统计 */
.char-stats {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-dim);
}

.char-stats span {
  text-align: center;
}

.char-stats strong {
  display: block;
  color: var(--accent2);
  font-size: 14px;
}

/* 按钮组 */
.char-buttons {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.char-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.3s;
}

.char-btn:hover {
  background: rgba(255, 107, 157, 0.15);
  border-color: var(--accent);
  color: var(--accent2);
  box-shadow: 0 0 12px rgba(255, 107, 157, 0.2);
}

/* ==================== 右侧 - 聊天区域 ==================== */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}

/* 顶部栏 */
.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent2);
}

.chat-header-status {
  font-size: 12px;
  color: #4ade80;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-header-status::before {
  content: '';
  width: 8px; height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

/* 消息区域 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* 欢迎消息 */
.welcome-msg {
  text-align: center;
  padding: 40px 20px;
}

.welcome-emoji {
  font-size: 48px;
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
}

.welcome-text {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.8;
}

/* 消息气泡 */
.message {
  display: flex;
  gap: 10px;
  animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.message.ai .msg-avatar {
  background: linear-gradient(135deg, #ff6b9d, #ff85b3);
}

.message.user .msg-avatar {
  background: linear-gradient(135deg, #6366f1, #818cf8);
}

.msg-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.7;
  position: relative;
}

.message.ai .msg-bubble {
  background: var(--ai-bubble);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.message.user .msg-bubble {
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.msg-time {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  padding: 0 4px;
}

/* 打字指示器 */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-items: center;
}

.typing-dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: typing 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* 输入区域 */
.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 18px;
  color: var(--text);
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 100px;
  transition: border-color 0.3s;
}

.chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.chat-input::placeholder {
  color: var(--text-dim);
}

.send-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff3d7f);
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(255, 107, 157, 0.4);
}

.send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(255, 107, 157, 0.6);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* 快捷操作 */
.quick-actions {
  display: flex;
  gap: 6px;
  padding: 0 20px 8px;
  flex-wrap: wrap;
}

.quick-action {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 11px;
  color: var(--text-dim);
  background: transparent;
  cursor: pointer;
  transition: all 0.3s;
}

.quick-action:hover {
  background: rgba(255, 107, 157, 0.1);
  border-color: var(--accent);
  color: var(--accent2);
}

/* ==================== 设置面板 ==================== */
.settings-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.settings-overlay.active { display: flex; }

.settings-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.settings-panel h3 {
  font-size: 18px;
  color: var(--accent2);
  margin-bottom: 20px;
  text-align: center;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.form-group select {
  cursor: pointer;
}

.settings-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn-primary {
  flex: 1;
  padding: 10px;
  background: linear-gradient(135deg, var(--accent), #ff3d7f);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
}

.btn-primary:hover {
  box-shadow: 0 4px 15px rgba(255, 107, 157, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 12px;
  color: var(--accent2);
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* 响应式 */
@media (max-width: 768px) {
  #app {
    flex-direction: column;
    max-height: 100vh;
    border-radius: 0;
  }
  .character-panel {
    width: 100%;
    min-width: 100%;
    max-height: 320px;
    padding: 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .character { width: 140px; height: 200px; }
  .char-head { width: 90px; height: 100px; }
  .char-face { width: 76px; height: 76px; top: 8px; left: 7px; }
  .char-hair-back { width: 106px; height: 76px; top: -4px; left: -8px; }
  .char-hair-front { width: 84px; height: 50px; top: 4px; left: 3px; }
  .char-hair-left, .char-hair-right { width: 18px; height: 68px; }
  .char-eyes { top: 35px; width: 46px; }
  .char-eye { width: 15px; height: 18px; }
  .char-eye::after { width: 6px; height: 6px; top: 4px; left: 3px; }
  .char-blush { top: 46px; width: 12px; height: 7px; }
  .char-blush-left { left: 14px; }
  .char-blush-right { right: 14px; }
  .char-mouth { top: 55px; }
  .char-body { top: 96px; width: 68px; height: 60px; }
  .char-body::before { width: 60px; height: 52px; }
  .char-body::after { width: 15px; height: 10px; top: 9px; }
  .chat-panel { height: 0; flex: 1; }

  /* 3D responsive */
  .character-3d { min-height: 250px; }
  .mode-3d .character-panel { max-height: 380px; }
  .mode-3d .chat-panel { height: 0; flex: 1; }
}

/* ==================== 3D 模式 ==================== */

/* 模式切换按钮 */
.mode-toggle {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
  padding: 4px;
  background: var(--bg-input);
  border-radius: 20px;
}

.mode-btn {
  flex: 1;
  padding: 6px 16px;
  border: none;
  border-radius: 16px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  transition: all 0.3s;
  font-family: inherit;
}

.mode-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(255, 107, 157, 0.4);
}

.mode-btn:hover:not(.active) {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

/* 3D 容器 */
.character-3d {
  width: 100%;
  flex: 1;
  min-height: 320px;
  position: relative;
  cursor: grab;
  overflow: hidden;
  border-radius: 16px;
  background: radial-gradient(ellipse at center, #1a1a3e 0%, #0a0a1a 70%);
}

.character-3d:active {
  cursor: grabbing;
}

.character-3d canvas {
  display: block;
}

/* 3D 模式下的 UI 调整 */
.mode-3d .character {
  display: none;
}

.mode-3d .character-3d {
  display: block !important;
}

/* 3D 爱心粒子 */
.heart-particle-3d {
  pointer-events: none;
}

@keyframes float-up {
  0% {
    transform: translateY(0) scale(0.5) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-200px) scale(1.2) rotate(20deg);
    opacity: 0;
  }
}

/* 3D 加载提示 */
.character-3d::before {
  content: '✨ 加载 3D 模型...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-dim);
  font-size: 13px;
  z-index: 1;
}

.character-3d.ready::before {
  content: none;
}

/* 3D 模式点击反馈 */
.character-3d .click-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-dim);
  font-size: 11px;
  pointer-events: none;
  opacity: 0.6;
}

.mode-3d .click-hint::after {
  content: '👆 点击女友互动 | 拖动旋转视角';
}

@media (hover: none) {
  .mode-3d .click-hint::after {
    content: '👆 触碰女友互动';
  }
}
