/**
 * 叉叉 AI 助手 - 统一样式表
 * 定义全局颜色、玻璃态效果、动画等
 */

/* ========================================
   CSS 变量 - 主题色彩系统
   ======================================== */
:root {
  /* 主色调 - 温暖米色系 */
  --color-bg-base: #fdfcf8;
  --color-bg-warm: #f5f0e8;
  --color-bg-accent: #e6ddd0;
  --color-bg-hover: #ede6dc;
  
  /* 文字色彩 */
  --color-text-primary: #5c4d43;
  --color-text-secondary: #8b7b6d;
  --color-text-muted: #a89b8c;
  
  /* 边框色彩 */
  --color-border-light: rgba(230, 221, 208, 0.6);
  --color-border-subtle: rgba(230, 221, 208, 0.4);
  
  /* 强调色 */
  --color-accent-rose: #f43f5e;
  --color-accent-rose-light: #fb7185;
  
  /* 阴影 */
  --shadow-soft: 0 4px 20px rgba(92, 77, 67, 0.08);
  --shadow-medium: 0 8px 32px rgba(92, 77, 67, 0.12);
  --shadow-strong: 0 12px 40px rgba(92, 77, 67, 0.15);
  
  /* 毛玻璃效果 */
  --glass-bg: rgba(245, 240, 232, 0.85);
  --glass-bg-strong: rgba(255, 255, 255, 0.45);
  --glass-blur: 16px;
  --glass-blur-strong: 24px;
  
  /* 圆角 */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-2xl: 1.8rem;
  --radius-3xl: 2.5rem;
  --radius-full: 9999px;
  
  /* 过渡 */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-smooth: 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ========================================
   基础样式
   ======================================== */
body {
  font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--color-bg-base);
  color: var(--color-text-primary);
}

::selection {
  background-color: var(--color-bg-accent);
}

/* ========================================
   毛玻璃效果 (Glassmorphism)
   ======================================== */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-soft);
}

.glass-panel-strong {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(var(--glass-blur-strong));
  -webkit-backdrop-filter: blur(var(--glass-blur-strong));
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: var(--shadow-medium);
}

.glass-icon {
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.glass-icon:hover {
  background: rgba(255, 255, 255, 0.7);
  transform: scale(1.05);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

/* ========================================
   工具栏按钮样式
   ======================================== */
.toolbar-btn {
  background: transparent;
  color: var(--color-text-secondary);
  transition: all var(--transition-normal);
}

.toolbar-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.toolbar-btn.active {
  background: var(--color-bg-accent);
  color: var(--color-text-primary);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* ========================================
   对话框容器样式
   ======================================== */
.chat-container {
  background: rgba(245, 240, 232, 0.15);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-soft);
}

/* ========================================
   动画效果
   ======================================== */

/* 从左滑入 */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}
.animate-slide-in-left {
  animation: slideInLeft var(--transition-smooth) forwards;
}

/* 从右滑入 */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}
.animate-slide-in-right {
  animation: slideInRight var(--transition-smooth) forwards;
}

/* 抖动效果 */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px) rotate(-5deg);
  }
  75% {
    transform: translateX(4px) rotate(5deg);
  }
}
.animate-shake {
  animation: shake 0.4s ease-in-out;
}

/* 呼吸效果 */
@keyframes breathe {
  0%, 100% {
    transform: scale(1) translateY(0);
  }
  50% {
    transform: scale(1.03) translateY(-4px);
  }
}
.animate-breathe {
  animation: breathe 2.5s ease-in-out infinite;
  will-change: transform;
}

/* 慢速浮动 */
@keyframes float-slow {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}
.animate-float-slow {
  animation: float-slow 6s ease-in-out infinite;
  will-change: transform;
}

/* 向上淡入 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.animate-fade-in-up {
  animation: fadeInUp 0.3s ease-out forwards;
}

/* 淡入动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.animate-fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}

/* 向上飘动 */
@keyframes floatUp {
  from {
    opacity: 0;
    transform: translateY(0) scale(0.8);
  }
  15% {
    opacity: 1;
    transform: translateY(-15px) scale(1);
  }
  85% {
    opacity: 1;
    transform: translateY(-80px) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-120px) scale(0.9);
  }
}
.animate-float-up {
  animation: floatUp 3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* 动画延迟 */
.animation-delay-100 {
  animation-delay: 100ms;
}
.animation-delay-200 {
  animation-delay: 200ms;
}
.animation-delay-300 {
  animation-delay: 300ms;
}

/* ========================================
   滚动条隐藏
   ======================================== */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* ========================================
   自定义滚动条样式
   ======================================== */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* ========================================
   工具栏图标标签
   ======================================== */
.toolbar-label {
  font-size: 11px;
  margin-top: 4px;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: color var(--transition-fast);
}

.toolbar-label.active {
  color: var(--color-text-primary);
}

/* ========================================
   手机端适配
   ======================================== */

/* 安全区域内边距（针对有刘海/底部条的设备） */
.safe-area-pb {
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.safe-area-pt {
  padding-top: max(8px, env(safe-area-inset-top));
}

/* 手机端面板上滑动画 */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.animate-slide-up {
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* 手机端面板下滑关闭动画 */
@keyframes slideDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(100%);
  }
}
.animate-slide-down {
  animation: slideDown 0.25s ease-out forwards;
}

/* ========================================
   响应式调整
   ======================================== */

/* 手机端工具栏图标大小 */
@media (max-width: 640px) {
  .toolbar-btn {
    width: 40px;
    height: 40px;
  }
  
  .toolbar-label {
    font-size: 10px;
    margin-top: 2px;
  }
  
  /* 优化触摸目标大小 */
  button {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* 手机端对话框样式 */
  .chat-container {
    border-radius: 1.25rem;
  }
}

/* 大屏幕优化 */
@media (min-width: 1280px) {
  .glass-panel-strong {
    box-shadow: var(--shadow-strong);
  }
}

/* 超大屏幕优化 */
@media (min-width: 1536px) {
  :root {
    --glass-blur-strong: 28px;
  }
}

/* ========================================
   滚动条隐藏工具类
   ======================================== */
.scrollbar-hide {
  /* Firefox */
  scrollbar-width: none;
  /* Safari and Chrome */
  -ms-overflow-style: none;
  /* 平滑滚动 */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* ========================================
   移动端键盘处理
   ======================================== */

/* 防止键盘弹出时整体布局跳动 */
html, body {
  height: 100%;
  overflow: hidden;
}

#root {
  height: 100%;
  overflow: hidden;
}

/* 使用 dvh 动态视口高度（如果支持） */
@supports (height: 100dvh) {
  html, body, #root {
    height: 100dvh;
  }
}

/* 键盘弹出时固定底部元素 */
.keyboard-avoid {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  transition: transform 0.25s ease-out;
}

/* 移动端输入框聚焦时的样式 */
@media (max-width: 640px) {
  input:focus, textarea:focus {
    font-size: 16px; /* 防止 iOS 自动缩放 */
  }
}

/* ========================================
   移动端工具栏优化
   ======================================== */
.mobile-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.mobile-toolbar::-webkit-scrollbar {
  display: none;
}

.mobile-toolbar-item {
  flex: 0 0 auto;
  scroll-snap-align: center;
  min-width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.mobile-toolbar-item.active {
  background: var(--color-bg-accent);
  color: var(--color-text-primary);
}

/* ========================================
   扁平化设计 - 移动端面板
   ======================================== */
.mobile-panel {
  background: var(--color-bg-warm);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
}

.mobile-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border-subtle);
}

.mobile-panel-content {
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 扁平化按钮 */
.flat-btn {
  background: var(--color-bg-accent);
  color: var(--color-text-primary);
  border: none;
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.flat-btn:active {
  background: var(--color-bg-hover);
  transform: scale(0.98);
}

.flat-btn-primary {
  background: var(--color-text-primary);
  color: white;
}

.flat-btn-primary:active {
  background: var(--color-text-secondary);
}

/* 扁平化输入框 */
.flat-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--color-bg-base);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  font-size: 16px;
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
}

.flat-input:focus {
  outline: none;
  border-color: var(--color-bg-accent);
  background: white;
}

.flat-input::placeholder {
  color: var(--color-text-muted);
}

/* 扁平化标签按钮 */
.flat-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--color-bg-base);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.flat-tag.active {
  background: var(--color-bg-accent);
  border-color: var(--color-bg-accent);
  color: var(--color-text-primary);
}

.flat-tag:active {
  transform: scale(0.96);
}
