/*
 * 小宝科技站 - 公共样式文件
 * 包含通用工具组件样式
 * 
 * 使用指南:
 * - 必须保留以下UI结构: #navbar, .home-btn, .navbar-title
 * - 必须引用公共样式: ../common/assets/css/tool-ui.css
 * - 必须使用主页链接格式: <a href="../index.html" class="home-btn">🏠</a>
 * - 工具独有逻辑只写在工具目录内，不要影响其他工具
 * - 采用玻璃态效果
 */

/* CSS 变量定义 - 科技风格主题 */
:root {
  /* 科技蓝紫色彩系统 */
  --primary-color: #3b82f6;
  /* 科技蓝 - 现代科技感 */
  --secondary-color: #8b5cf6;
  /* 紫色 - 创新未来感 */
  --accent-color: #06b6d4;
  /* 青色 - 清新活力 */
  --tertiary-color: #10b981;
  /* 绿色 - 生机勃勃 */
  --quaternary-color: #f59e0b;
  /* 橙色 - 温暖提示 */

  /* 背景色彩系统 */
  --bg-base: #f8fafc;
  /* 浅灰白 - 清爽科技感 */
  --bg-darker: #e2e8f0;
  /* 稍深的背景色 */
  --bg-lighter: #ffffff;
  /* 纯白色 */
  --bg-overlay: rgba(248, 250, 252, 0.9);
  /* 半透明覆盖层 */
  --mystic-glow: rgba(59, 130, 246, .25);
  /* 对应主色光晕 */
  --mystic-glow-strong: rgba(139, 92, 246, .35);

  /* 真实玻璃效果 - 多层次设计 */
  --glass-bg: rgba(255, 255, 255, 0.3);
  /* 主玻璃背景 */
  --glass-bg-hover: rgba(255, 255, 255, 0.4);
  --glass-border: rgba(59, 130, 246, 0.2);
  /* 玻璃边框 - 科技蓝 */
  --glass-border-hover: rgba(139, 92, 246, 0.35);
  --glass-highlight: rgba(255, 255, 255, 0.85);
  /* 玻璃高光 */
  --glass-shadow: rgba(59, 130, 246, 0.15);
  /* 玻璃阴影 - 科技蓝 */

  /* 背景模糊 - 优化的模糊值 */
  --background-blur: blur(16px) saturate(180%);
  --element-blur: blur(10px) saturate(150%);
  --edge-blur: blur(4px);

  /* 文本颜色 */
  --text-primary: #1e293b;
  /* 深蓝灰文字，清晰易读 */
  --text-secondary: #475569;
  /* 次要文字 */
  --text-muted: #94a3b8;
  /* 弱化文字 */
  --text-accent: #f59e0b;
  /* 强调色文字 */

  /* 真实玻璃阴影效果 */
  --shadow-soft: 0 8px 32px rgba(59, 130, 246, 0.15);
  --shadow-medium: 0 15px 35px rgba(59, 130, 246, 0.2);
  --shadow-strong: 0 20px 40px rgba(59, 130, 246, 0.25);
  --mystic-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
  --mystic-shadow-strong: 0 0 40px rgba(139, 92, 246, 0.35);

  /* 动画曲线 */
  --ease-liquid: cubic-bezier(.4, 0, .2, 1);
  --ease-bounce: cubic-bezier(.68, -.55, .265, 1.55);

  /* 噪点纹理 SVG */
  --noise-texture: url("data:image/svg+xml,%3Csvg viewBox='0 0 250 250' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* 暗色模式 - 自动适配系统夜间模式 */
@media (prefers-color-scheme: dark) {
  :root {
    /* 背景色彩系统 - 暗色版 */
    --bg-base: #000000;
    /* 纯黑色 - 深邃夜空 */
    --bg-darker: #000000;
    /* 更深的背景 */
    --bg-lighter: #111111;
    /* 微微亮一点的黑 */
    --bg-overlay: rgba(10, 10, 10, 0.85);
    --mystic-glow: rgba(59, 130, 246, .35);
    /* 增强光晕 */
    --mystic-glow-strong: rgba(139, 92, 246, .45);

    /* 真实玻璃效果 - 暗色版 */
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-bg-hover: rgba(255, 255, 255, 0.12);
    --glass-border: rgba(59, 130, 246, 0.25);
    --glass-border-hover: rgba(139, 92, 246, 0.35);
    --glass-highlight: rgba(255, 255, 255, 0.35);
    --glass-shadow: rgba(0, 0, 0, 0.5);

    /* 文本颜色 - 暗色版 */
    --text-primary: #f0f0f0;
    /* 浅色文字 */
    --text-secondary: #d0d0d0;
    /* 次要文字 */
    --text-muted: #a0a0a0;
    /* 弱化文字 */

    /* 阴影效果 - 暗色版 */
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-medium: 0 15px 35px rgba(0, 0, 0, 0.6);
    --shadow-strong: 0 20px 40px rgba(0, 0, 0, 0.7);
    --mystic-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
    --mystic-shadow-strong: 0 0 40px rgba(139, 92, 246, 0.5);
  }
}

/* Liquid Glass 全局样式 - 使用天空背景系统 */
body {
  margin: 0;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'Microsoft YaHei', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  position: relative;
  /* 后备背景 - 日间模式 (白色渐变) */
  background: radial-gradient(ellipse at bottom, #ffffff 0%, #F0F8FF 100%);
}

/* 暗色模式下的后备背景 - 夜间模式 (深色渐变) */
@media (prefers-color-scheme: dark) {
  body {
    background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
  }
}

/* 移除原有的背景渐变和光晕效果 */
body::before {
  content: none;
}



/* 真实玻璃效果工具容器 */
.tool-container {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: var(--background-blur);
  -webkit-backdrop-filter: var(--background-blur);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: var(--shadow-medium);
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  padding: 32px;
  transition: all .3s var(--ease-liquid);
  overflow: auto;
}

/* 玻璃容器的高光效果 */
.tool-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--glass-highlight);
  border-radius: 24px 24px 0 0;
  pointer-events: none;
}

/* 玻璃容器的纹理效果 */
.tool-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--noise-texture);
  opacity: 0.03;
  border-radius: 24px;
  pointer-events: none;
  mix-blend-mode: overlay;
}

/* 真实玻璃效果结果卡片 */
.result-card {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: var(--element-blur);
  -webkit-backdrop-filter: var(--element-blur);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px;
  margin: 16px 0;
  box-shadow: var(--shadow-soft);
  transition: all .3s var(--ease-liquid);
}

.result-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--glass-highlight);
  border-radius: 16px 16px 0 0;
  pointer-events: none;
}

.result-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--noise-texture);
  opacity: 0.02;
  border-radius: 16px;
  pointer-events: none;
  mix-blend-mode: overlay;
}

.result-card:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
  box-shadow: var(--shadow-medium);
  transform: translateY(-2px);
}



/* 真实玻璃效果导航栏 - 滚动收缩效果 */
#navbar {
  position: fixed;
  top: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--glass-bg);
  backdrop-filter: var(--element-blur);
  -webkit-backdrop-filter: var(--element-blur);
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  padding: 10px 20px;
  box-shadow: var(--shadow-soft);
  transition: all .4s var(--ease-liquid);
  z-index: 1000;
  min-width: 130px;
}

/* 导航栏玻璃高光效果 */
#navbar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, var(--glass-highlight) 0%, transparent 100%);
  border-radius: 50px 50px 25px 25px;
  pointer-events: none;
  opacity: 0.6;
}

/* 导航栏纹理效果 */
#navbar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--noise-texture);
  opacity: 0.02;
  border-radius: 50px;
  pointer-events: none;
  mix-blend-mode: overlay;
}

#navbar.scrolled {
  padding: 8px 10px;
  min-width: 48px;
  gap: 0
}

#navbar .home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 24px;
  color: var(--primary-color);
  text-decoration: none;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0 4px;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: transform 0.2s var(--ease-liquid), color 0.2s ease;
  pointer-events: auto;
  flex-shrink: 0;
}

#navbar .home-btn:hover {
  transform: scale(1.15);
  color: var(--secondary-color);
}

#navbar .home-btn:active {
  transform: scale(0.95);
}

/* 主页图标已在HTML中直接定义 */

#navbar .navbar-title {
  display: flex;
  align-items: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-color);
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity .3s var(--ease-liquid), width .3s var(--ease-liquid), margin .3s var(--ease-liquid), padding .3s var(--ease-liquid);
  overflow: hidden
}

#navbar.scrolled .navbar-title {
  opacity: 0;
  width: 0;
  margin: 0;
  padding: 0;
}

/* 以下为工具通用样式 */
.tool-instructions {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 16px 0;
  line-height: 1.6;
  font-weight: 400
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center
}





/* 真实玻璃效果聊天界面 */
.chat-shell {
  position: relative;
  width: min(1100px, calc(100vw - 40px));
  height: min(760px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: 20px;
  background: var(--glass-bg);
  backdrop-filter: var(--background-blur);
  -webkit-backdrop-filter: var(--background-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-medium);
}

.chat-shell::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--glass-highlight);
  border-radius: 20px 20px 0 0;
  pointer-events: none;
}

.chat-shell::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--noise-texture);
  opacity: 0.03;
  border-radius: 20px;
  pointer-events: none;
  mix-blend-mode: overlay;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--glass-border);
}

.chat-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
}

.msg {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
  padding: 12px 12px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--edge-blur);
  -webkit-backdrop-filter: var(--edge-blur);
}

.msg::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--glass-highlight);
  border-radius: 20px 20px 0 0;
  pointer-events: none;
  opacity: 0.5;
}

.msg .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.msg .who {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.msg .time {
  font-size: 11px;
  color: var(--text-muted);
}

.msg .content {
  word-break: break-word;
  line-height: 1.6;
  color: var(--text-secondary);
  font-size: 14px;
}

.msg .content p {
  margin: 0.5em 0;
}

.msg .content p:first-child {
  margin-top: 0;
}

.msg .content p:last-child {
  margin-bottom: 0;
}

.msg .content code {
  background: var(--glass-bg);
  padding: 2px 6px;
  border-radius: 40px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  color: var(--text-primary);
}

.msg .content pre {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 40px;
  padding: 12px;
  overflow-x: auto;
  margin: 0.8em 0;
}

.msg .content pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 0.85em;
  line-height: 1.5;
  display: block;
}

.msg .content h1,
.msg .content h2,
.msg .content h3,
.msg .content h4 {
  margin: 0.8em 0 0.4em 0;
  color: var(--text-primary);
  font-weight: 600;
}

.msg .content h1 {
  font-size: 1.5em;
}

.msg .content h2 {
  font-size: 1.3em;
}

.msg .content h3 {
  font-size: 1.15em;
}

.msg .content h4 {
  font-size: 1.05em;
}

.msg .content ul,
.msg .content ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.msg .content li {
  margin: 0.3em 0;
}

.msg .content blockquote {
  border-left: 3px solid var(--primary-color);
  padding-left: 12px;
  margin: 0.8em 0;
  color: var(--text-secondary);
  font-style: italic;
}

.msg .content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.8em 0;
}

.msg .content table th,
.msg .content table td {
  border: 1px solid var(--glass-border);
  padding: 8px 12px;
  text-align: left;
}

.msg .content table th {
  background: var(--glass-bg-hover);
  font-weight: 600;
}

.msg .content a {
  color: var(--primary-color);
  text-decoration: none;
}

.msg .content a:hover {
  text-decoration: underline;
}

.msg.user .content {
  white-space: pre-wrap;
}

.msg.user .who {
  color: var(--accent-color);
}

.msg.ai .who {
  color: var(--secondary-color);
}

.msg.system .who {
  color: var(--quaternary-color);
}

.composer {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.composer textarea {
  flex: 1;
  height: 90px;
  resize: none;
  border-radius: 20px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.45;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
}

.composer .right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: space-between;
  width: 80px;
}

.composer .right button {
  margin-top: 0;
  padding: 5px 5px;
  border-radius: 40px;
  font-size: 15px;
  flex: 1;
  background: var(--primary-color);
  border: none;
  color: var(--bg-base);
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 700;
}

.composer .right button:hover {
  transform: scale(1.05);
  box-shadow: var(--mystic-shadow);
}

.composer .right button:active {
  transform: scale(1.0);
}

.composer .right button.secondary {
  background: var(--glass-bg);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.composer .right button.secondary:hover {
  background: var(--glass-bg-hover);
  transform: scale(1.04);
}

.composer .right button.danger {
  background: var(--glass-bg);
  color: var(--quaternary-color);
  border: 1px solid var(--glass-border);
}

.composer .right button.danger:hover {
  background: var(--glass-bg-hover);
  transform: scale(1.04);
}

/* 动态省略号动画 */
.typing-indicator {
  display: inline-block;
}

.typing-indicator span {
  opacity: 0;
  animation: typing 1.4s infinite;
  animation-fill-mode: both;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {

  0%,
  60%,
  100% {
    opacity: 0;
  }

  30% {
    opacity: 1;
  }
}



/* 响应式设计 */
@media (min-width: 1024px) {
  .tool-container {
    padding: 48px;
    max-width: 900px;
  }
}

@media (max-width: 768px) {
  .tool-container {
    max-width: 95%;
    width: 95%;
    padding: 24px;
    border-radius: 16px;
    margin: 80px 16px 16px 16px;
    /* 顶部留出导航栏空间 */
    max-height: calc(100vh - 96px);
    /* 调整最大高度，考虑顶部边距 */
  }

  .chat-shell {
    width: calc(100vw - 32px);
    height: calc(100vh - 80px);
    /* 为导航栏预留空间 */
    margin-top: 64px;
  }

  #navbar {
    top: 16px;
    left: 16px;
    padding: 12px 16px;
    font-size: 14px
  }

  #navbar .home-btn {
    width: 32px;
    height: 32px;
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  #navbar {
    top: 12px;
    left: 12px;
    padding: 10px 14px
  }

  .tool-container {
    max-width: 100%;
    width: 100%;
    padding: 20px;
    border-radius: 12px;
    margin: 76px 12px 12px 12px;
    /* 顶部留出导航栏空间 */
    max-height: calc(100vh - 100px);
    /* 调整最大高度，考虑顶部边距 */
  }

  .chat-shell {
    width: calc(100vw - 24px);
    height: calc(100vh - 80px);
    /* 为导航栏预留空间 */
    margin-top: 60px;
  }

  #navbar .home-btn {
    width: 28px;
    height: 28px;
    font-size: 18px;
  }
}

/* ==================== 天空背景系统 ==================== */
/* 日间模式天空背景 - 仅设置在 html 上，避免 body 背景遮挡 z-index:-1 的元素 */
html.day-theme {
  background: radial-gradient(ellipse at bottom, #ffffff 0%, #F0F8FF 100%);
  transition: background 2s ease-in-out;
}

/* 夜间模式天空背景 - 仅设置在 html 上 */
html.night-theme {
  background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
  transition: background 2s ease-in-out;
}

/* 确保 body 背景透明 */
html.day-theme body,
html.night-theme body,
body.day-theme,
body.night-theme {
  background: transparent;
}

/* 星空容器 */
.stars-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

/* 星星样式 */
.star {
  position: absolute;
  background: #ffffff;
  border-radius: 50%;
  animation: breathe 3s ease-in-out infinite;
  opacity: 0;
  z-index: 1;
}

/* 飞鸟样式 */
.bird {
  position: absolute;
  color: #000000;
  font-size: 16px;
  font-family: monospace;
  opacity: 0;
  animation: fly 15s ease-in-out infinite;
  transform: rotate(-15deg);
  z-index: 1;
}

/* 根据主题类设置飞鸟颜色，而非系统偏好，防止白底白鸟 */
html.night-theme .bird {
  color: #ffffff;
}

html.day-theme .bird {
  color: #000000;
}

/* 呼吸动画 */
@keyframes breathe {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1.2);
  }

  100% {
    opacity: 0;
    transform: scale(0.8);
  }
}

/* 飞行动画 */
@keyframes fly {
  0% {
    opacity: 0;
  }

  10% {
    opacity: 0.8;
  }

  90% {
    opacity: 0.8;
  }

  100% {
    opacity: 0;
  }
}

/* ==================== 顶部日期显示 ==================== */
#navbar-date {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  backdrop-filter: var(--element-blur);
  -webkit-backdrop-filter: var(--element-blur);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 8px 24px;
  box-shadow: var(--shadow-soft);
  z-index: 900;
  /* 略低于导航栏，避免遮挡交互 */
  transition: all 0.4s var(--ease-liquid);
  user-select: none;
  pointer-events: none;
  /* 让鼠标事件穿透，不阻挡下方点击 */
}

/* 玻璃高光 */
#navbar-date::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, var(--glass-highlight) 0%, transparent 100%);
  border-radius: 20px 20px 10px 10px;
  pointer-events: none;
  opacity: 0.6;
}

#navbar-date .date-time {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

#navbar-date .time-info {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* 滚动收缩效果 */
#navbar-date.scrolled {
  padding: 6px 16px;
  top: 10px;
  background: var(--glass-bg-hover);
}

#navbar-date.scrolled .date-time {
  font-size: 14px;
}

#navbar-date.scrolled .time-info {
  font-size: 11px;
}

/* 响应式调整 */
@media (max-width: 768px) {
  #navbar-date {
    top: 70px;
    /* 移动端下移，避开左右按钮 */
    padding: 6px 16px;
    background: rgba(255, 255, 255, 0.1);
    /* 减淡背景以免过于抢眼 */
    border-radius: 16px;
  }

  #navbar-date .date-time {
    font-size: 14px;
  }

  #navbar-date .time-info {
    font-size: 11px;
  }

  /* 滚动时隐藏或极小化 */
  #navbar-date.scrolled {
    top: 60px;
    opacity: 0.8;
  }
}

@media (max-width: 480px) {
  #navbar-date {
    top: 65px;
    padding: 4px 12px;
  }

  #navbar-date .date-time {
    font-size: 13px;
  }

  #navbar-date .time-info {
    font-size: 10px;
  }
}