/* ============================================================ */
/* Play4Fun — Figma Design Styles                               */
/* ============================================================ */

/* 全局字体: 中文用 Noto Sans SC, 英文用 DM Sans */
body {
  font-family: 'Noto Sans SC', 'DM Sans', sans-serif;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* 隐藏滚动条 */
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }

/* ── 搜索栏 (Dynamic Island) ──────────────────── */
.search-wrapper { width: min(320px, 55vw); }

.search-bar {
  background: rgba(0,0,0,0.82);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.13);
  box-shadow: 0 4px 24px rgba(0,0,0,0.35);
  height: 42px;
  transition: all 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

.search-bar.focused {
  width: min(560px, 80vw) !important;
  height: 48px;
  border-color: rgba(192,132,252,0.55);
  box-shadow: 0 0 0 4px rgba(192,132,252,0.14), 0 8px 32px rgba(0,0,0,0.45);
}

/* ── 手机端搜索栏 ──────────────────────────────── */
.search-bar-mobile {
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  height: 40px;
  border-radius: 9999px;
  transition: all 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

.search-bar-mobile:focus-within {
  border-color: rgba(192,132,252,0.5);
  box-shadow: 0 0 0 3px rgba(192,132,252,0.12), 0 6px 24px rgba(0,0,0,0.4);
}

/* ── 语言切换 ──────────────────────────────────── */
.lang-toggle {
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.12);
}

.lang-btn {
  color: rgba(255,255,255,0.4);
  background: transparent;
  box-shadow: none;
}

.lang-btn.active {
  background: rgba(255,255,255,0.92) !important;
  color: #000 !important;
  box-shadow: 0 1px 6px rgba(0,0,0,0.3) !important;
}

/* ── 幽灵按钮 ──────────────────────────────────── */
.ghost-btn { background: rgba(255,255,255,0.08); }

/* ── 输入框聚焦 ────────────────────────────────── */
input:focus { outline: none; }

/* ── 登录面板过渡 ─────────────────────────────── */
#panel-login-form, #panel-register-form, #panel-logged-in {
  transition: opacity 0.3s ease;
}

/* ── 移动端触摸优化 ────────────────────────────── */
input, button {
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

/* 手机端输入框增大触摸区域 */
@media (max-width: 767px) {
  input {
    font-size: 16px !important; /* 防止 iOS 缩放 */
  }
}

/* 手机端底部登录面板 — 安全区域适配 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #login-panel > .relative {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
}

/* ── AI 终端弹窗 ─────────────────────────────── */
#ai-terminal {
  animation: ai-terminal-fadein 0.2s ease;
}

@keyframes ai-terminal-fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}

#ai-terminal-window {
  animation: ai-terminal-scalein 0.25s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
  overflow: visible;
  min-width: 360px;
  min-height: 280px;
}
/* 右下角拖拽手柄 */
#ai-terminal-window::after {
  content: '';
  position: absolute;
  right: 0; bottom: 0;
  width: 16px; height: 16px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.15) 50%);
  border-radius: 0 0 8px 0;
}

@keyframes ai-terminal-scalein {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── AI 终端：标题栏拖拽手柄 ───────────────── */
#ai-terminal-window .flex.items-center.justify-between {
  cursor: grab;
  user-select: none;
}
#ai-terminal-window .flex.items-center.justify-between:active {
  cursor: grabbing;
}

/* 终端内容滚动条 */
#ai-terminal-body::-webkit-scrollbar {
  display: block;
  width: 4px;
}
#ai-terminal-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

/* 打字光标动画 */
.ai-terminal-cursor::after {
  content: '█';
  animation: ai-cursor-blink 1s step-end infinite;
  color: #a78bfa;
}

@keyframes ai-cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* AI 消息淡入 */
.ai-message {
  animation: ai-message-in 0.3s ease;
}

@keyframes ai-message-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── 模型选择器 ───────────────────────────────── */
#model-selector:hover {
  border-color: rgba(192,132,252,0.5) !important;
}

/* 移动端搜索栏：窄宽度时隐藏模型选择器标签文字 */
@media (max-width: 480px) {
  #model-selector #model-name { display: none; }
}

/* ── 移动端全局适配 ─────────────────────────── */
@media (max-width: 767px) {
  /* 主页欢迎语：下移到搜索栏下方 */
  #homepage .top-20 { top: 7rem !important; }
  #homepage .md\:top-24 { top: 7rem !important; }
  #homepage .left-6 { left: 1rem !important; right: 1rem !important; }
  #homepage .left-12 { left: 1rem !important; right: 1rem !important; }
  #homepage h1 { font-size: 1.15rem !important; line-height: 1.5 !important; }
  #homepage .md\:text-5xl { font-size: 1.15rem !important; }
  #homepage p { font-size: 0.75rem !important; margin-top: 0.5rem !important; }
  /* 登出按钮 */
  #btn-home-signout { bottom: 1.5rem !important; left: 1rem !important; font-size: 0.75rem !important; padding: 0.5rem 1rem !important; }

  /* Hero 图片手机端下移 */
  #hero-section img { max-width: 180px !important; }
  #hero-section .md\:pl-8 { padding: 0 !important; }

  /* AI 终端：卡片式，顶部留搜索栏空间 */
  #ai-terminal { padding: 12px !important; padding-top: 72px !important; }
  #ai-terminal-window {
    border-radius: 14px !important;
    max-height: calc(100vh - 96px) !important;
  }
  #ai-terminal-input { font-size: 16px !important; }
  #ai-terminal-body { font-size: 13px !important; }

  /* 登录面板 */
  #login-panel > .relative { padding: 1rem 1rem 1.5rem 1rem !important; }
  #panel-login-form, #panel-register-form, #panel-forgot-form, #panel-logged-in {
    max-width: 100% !important;
  }

  /* 注册表单间距 */
  .px-6 { padding-left: 1rem !important; padding-right: 1rem !important; }
  .py-6 { padding-top: 1rem !important; padding-bottom: 1rem !important; }

  /* Hero 图片缩小 */
  #hero-section img { max-width: 200px !important; }
}
