/**
 * base.css - CSS变量、重置样式、动画定义
 * 包含：变量定义、全局重置、动画关键帧、容器样式
 */

/* ========== CSS变量 ========== */
:root {
  /* 主题色 - 极简黑白灰 */
  --primary: #333;
  --primary-dark: #1a1a1a;
  --primary-hover: #555;
  --primary-active: #000;
  --secondary: #666;

  /* Markdown字体大小 */
  --md-font-size: 16px;
  
  /* 功能色 - 简化，背景透明 */
  --success: #333;
  --success-bg: transparent;
  --error: #333;
  --error-bg: transparent;
  --warning: #333;
  --warning-bg: transparent;
  --danger: #333;
  --info: #333;
  --info-bg: transparent;
  
  /* 中性色 - 优化层次 */
  --text: #1a1a1a;
  --text-light: #666;
  --text-muted: #999;
  --border: #eee;
  --bg: #f5f5f5;
  --bg-white: #fff;
  --card-bg: #fff;
  --page-bg: #f5f5f5;
  
  /* 间距 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 20px;
  --spacing-xxl: 24px;
  
  /* 圆角 */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  /* 阴影 */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  /* 过渡 */
  --transition-fast: 0.2s;
  --transition-normal: 0.3s;
  --transition-slow: 0.5s;
  
  /* 字体 */
  --font-size-sm: 12px;
  --font-size-base: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-xxl: 20px;
  
  /* 简化颜色 - 不使用渐变 */
}

/* ========== 深色模式 ========== */
:root.dark {
  --text: #e5e5e5;
  --text-light: #a0a0a0;
  --text-muted: #707070;
  --border: #333;
  --bg: #1a1a1a;
  --bg-white: #252525;
  --card-bg: #252525;
  --page-bg: #121212;
}

/* ========== 基础重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

*:focus {
  outline: none;
}

button:focus, a:focus, input:focus, textarea:focus, select:focus {
  outline: none;
}

/* 全局表单元素 */
select {
  background: var(--bg-white);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: inherit;
  cursor: pointer;
}

/* 主题切换按钮 */
.theme-toggle {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--bg);
}

/* 全局平滑滚动 */
html {
  scroll-behavior: smooth;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--page-bg);
  min-height: 100%;
  max-width: 100%;
  width: 100%;
  overflow-x: hidden;
  /* 确保 fixed 定位正常工作 */
  -webkit-overflow-scrolling: touch;
}

/* ========== 动画定义 ========== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@keyframes indeterminateProgress {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}

@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.8); }
  70% { transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

/* ========== 容器 ========== */
.container {
  width: 100%;
  max-width: min(1200px, 100%);
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
}

/* ========== 状态提示 ========== */
.loading, .error, .hint {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 15px;
  animation: fadeIn 0.5s ease;
}

.error {
  color: var(--danger);
}

/* ========== 用户状态样式 ========== */
.user-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.username {
  font-size: 14px;
  color: var(--text);
}

.btn-logout {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  border-color: var(--text);
  color: var(--text);
}

.btn-login {
  padding: 6px 14px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-login:hover {
  background: var(--primary-hover);
}


/* ========== 主题切换提示气泡 ========== */
.theme-tip-bubble {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  padding: 14px 18px;
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.theme-tip-bubble.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.theme-tip-bubble.hide {
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  pointer-events: none;
}

.theme-tip-bubble::before {
  content: '';
  position: absolute;
  top: -8px;
  right: 24px;
  width: 14px;
  height: 14px;
  background: var(--bg-white);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}

.theme-tip-bubble .tip-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-tip-bubble .tip-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.theme-tip-bubble .tip-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.theme-tip-bubble .tip-text strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 14px;
  vertical-align: middle;
  margin: 0 2px;
}

.theme-tip-bubble .tip-never-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-tip-bubble .tip-never-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--text-light);
}

/* 登录提示气泡特殊样式 */
.theme-tip-bubble.login-tip .tip-actions,
.theme-tip-bubble.settings-tip .tip-actions,
.theme-tip-bubble.dark-tip .tip-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.theme-tip-bubble.login-tip .tip-login-btn {
  flex: 1;
  padding: 10px 16px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-tip-bubble.login-tip .tip-login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.theme-tip-bubble.login-tip .tip-never-btn,
.theme-tip-bubble.settings-tip .tip-never-btn,
.theme-tip-bubble.dark-tip .tip-never-btn {
  flex: 1;
  margin-top: 0;
  padding: 10px 12px;
}

/* 取消按钮样式 */
.theme-tip-bubble .tip-cancel-btn {
  flex: 1;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-tip-bubble .tip-cancel-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.theme-tip-bubble .tip-cancel-btn:not(:disabled):hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--text-light);
}

/* 深色模式下的气泡样式 */
:root.dark .theme-tip-bubble {
  background: #2a2a2a;
  border-color: #3a3a3a;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

:root.dark .theme-tip-bubble::before {
  background: #2a2a2a;
  border-color: #3a3a3a;
}

:root.dark .theme-tip-bubble .tip-text strong {
  background: #3a3a3a;
}

:root.dark .theme-tip-bubble .tip-never-btn {
  border-color: #3a3a3a;
}

:root.dark .theme-tip-bubble .tip-never-btn:hover {
  background: #3a3a3a;
  border-color: #555;
}

:root.dark .theme-tip-bubble.login-tip .tip-login-btn {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

:root.dark .theme-tip-bubble.login-tip .tip-login-btn:hover {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
}

:root.dark .theme-tip-bubble .tip-cancel-btn {
  border-color: #3a3a3a;
}

:root.dark .theme-tip-bubble .tip-cancel-btn:not(:disabled):hover {
  background: #3a3a3a;
  border-color: #555;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .theme-tip-bubble {
    top: 60px;
    right: 10px;
    left: auto;
    width: 200px;
    padding: 10px 12px;
  }
  
  .theme-tip-bubble::before {
    right: 20px;
  }
  
  .theme-tip-bubble .tip-content {
    gap: 8px;
  }
  
  .theme-tip-bubble .tip-icon {
    font-size: 16px;
  }
  
  .theme-tip-bubble .tip-text {
    font-size: 11px;
    line-height: 1.4;
  }
  
  .theme-tip-bubble .tip-text strong {
    width: 20px;
    height: 20px;
    font-size: 12px;
  }
  
  .theme-tip-bubble .tip-never-btn,
  .theme-tip-bubble .tip-cancel-btn {
    padding: 6px 8px;
    font-size: 11px;
  }
  
  .theme-tip-bubble.login-tip .tip-actions,
  .theme-tip-bubble.settings-tip .tip-actions {
    gap: 6px;
    margin-top: 10px;
  }
  
  .theme-tip-bubble.login-tip .tip-login-btn {
    padding: 6px 10px;
    font-size: 11px;
  }
}
