/* ============================================
   心迹 · MindTrace — 自定义样式
   简约小清新风格
   ============================================ */

/* --- 基础 --- */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background-color: #FAFAF8;
}

/* --- 导航标签 --- */
.nav-tab {
  color: #636E72;
  transition: all 0.2s ease;
}
.nav-tab:hover {
  color: #2D3436;
  background-color: rgba(0,0,0,0.04);
}
.nav-tab.active {
  background-color: #ffffff;
  color: #4A7C59;
  box-shadow: 0 2px 8px -2px rgba(74, 124, 89, 0.15);
}

/* --- 粒度按钮 --- */
.granularity-btn {
  transition: all 0.2s ease;
}
.granularity-btn.active {
  background-color: #4A7C59 !important;
  color: #ffffff !important;
}

/* --- 自定义滚动条 --- */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #dfe6e9;
  border-radius: 999px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #b2bec3;
}

/* --- 卡片悬停 --- */
.entry-card {
  transition: all 0.2s ease;
}
.entry-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 32px -8px rgba(74, 124, 89, 0.15);
  border-color: rgba(74, 124, 89, 0.2);
}

/* --- 突破点卡片 --- */
.breakthrough-card {
  transition: all 0.2s ease;
  cursor: pointer;
}
.breakthrough-card:hover {
  transform: translateX(2px);
  border-color: rgba(232, 168, 124, 0.4);
  background-color: #fdf9f5;
}

/* --- 标签徽章 --- */
.tag-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background-color: #f0f7f3;
  color: #4A7C59;
}

/* --- 认知层级标签 --- */
.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}
.level-L1 { background: #f1f3f4; color: #636E72; }
.level-L2 { background: #e8f0fe; color: #4a6fa5; }
.level-L3 { background: #e0f2ea; color: #3a8a5c; }
.level-L4 { background: #fff3e0; color: #c87f2a; }
.level-L5 { background: #fce4ec; color: #b8456a; }
.level-L6 { background: #f3e5f5; color: #8e44ad; }
.level-L7 { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }

/* --- CGI 分数条 --- */
.cgi-bar {
  height: 6px;
  border-radius: 999px;
  background: #f1f3f4;
  overflow: hidden;
}
.cgi-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7CB9A8, #4A7C59);
  transition: width 0.5s ease;
}

/* --- 加载动画 --- */
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.loading-pulse {
  animation: pulse-soft 1.5s ease-in-out infinite;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.fade-in-up {
  animation: fadeInUp 0.4s ease forwards;
}

/* --- Toast --- */
.toast {
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 32px -8px rgba(0,0,0,0.15);
  animation: fadeInUp 0.3s ease;
  max-width: 360px;
}
.toast-success {
  background: #ffffff;
  color: #2e7d32;
  border-left: 4px solid #4A7C59;
}
.toast-error {
  background: #ffffff;
  color: #c62828;
  border-left: 4px solid #e57373;
}
.toast-info {
  background: #ffffff;
  color: #1565c0;
  border-left: 4px solid #64b5f6;
}
.toast-warning {
  background: #ffffff;
  color: #e65100;
  border-left: 4px solid #ffb74d;
}

/* --- 弹窗 --- */
#breakthrough-modal .relative {
  animation: fadeInUp 0.3s ease;
}

/* --- 空状态 --- */
.empty-state-icon {
  opacity: 0.4;
}

/* --- 文本选择 --- */
::selection {
  background-color: rgba(74, 124, 89, 0.15);
  color: #2D3436;
}

/* --- 输入框聚焦 --- */
input:focus, textarea:focus, select:focus {
  outline: none;
}

/* --- 响应式 --- */
@media (max-width: 768px) {
  #nav-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tab {
    white-space: nowrap;
    flex-shrink: 0;
  }
}

/* === 手机端整体排版优化 === */
@media (max-width: 640px) {
  html { font-size: 16px; }
  body { min-width: 0; }

  /* 顶层容器收紧内边距 */
  main.max-w-7xl,
  nav .max-w-7xl {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  /* 顶部导航：紧凑 */
  nav .px-6 { padding-left: 0 !important; padding-right: 0 !important; }
  nav .py-3 { padding-top: 10px !important; padding-bottom: 10px !important; }
  nav h1 { font-size: 16px !important; }
  nav .w-9.h-9 { width: 32px !important; height: 32px !important; }
  #nav-tabs { gap: 2px !important; padding: 3px !important; border-radius: 12px !important; }
  .nav-tab { padding: 7px 12px !important; font-size: 13px !important; }

  /* 欢迎横幅 */
  .mb-8.bg-gradient-to-r,
  main > section .mb-8 {
    padding: 20px !important;
    border-radius: 20px !important;
  }
  .mb-8.bg-gradient-to-r h2,
  main section h2.text-2xl { font-size: 19px !important; }

  /* 页面大标题统一缩小 */
  section h2.text-2xl { font-size: 19px !important; }
  section p.text-sm.text-ink-400,
  section p.text-sm.text-ink-300 { font-size: 12px !important; }

  /* KPI 卡片：强制 2 列，收紧 */
  #kpi-cards {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  #kpi-cards > div {
    padding: 14px !important;
    border-radius: 16px !important;
  }
  #kpi-cards p.text-3xl { font-size: 24px !important; }
  #kpi-cards p.text-xs { font-size: 10px !important; }

  /* 主内容卡片 */
  .bg-white.rounded-3xl { border-radius: 20px !important; padding: 16px !important; }
  .bg-white.rounded-2xl { border-radius: 14px !important; }

  /* 图表高度适配 */
  #growth-chart { height: 300px !important; }
  #chart-empty { height: 300px !important; }
  #level-chart { height: 240px !important; }

  /* 两栏变单栏 */
  .grid.lg\:grid-cols-5,
  .grid.lg\:grid-cols-2 { grid-template-columns: 1fr !important; gap: 12px !important; }

  /* 图表头部：标题与粒度按钮换行对齐 */
  #view-growth .flex.items-center.justify-between {
    flex-wrap: wrap; gap: 8px;
  }
  .granularity-btn { padding: 6px 11px !important; font-size: 11px !important; }

  /* 突破点列表高度 */
  #breakthrough-list { max-height: none !important; }

  /* 导入区输入行：单列 */
  .flex.items-center.gap-3 { flex-wrap: wrap; }
  .flex.items-center.gap-3 > .flex-1 {
    flex: 1 1 100% !important;
    min-width: 100% !important;
  }

  /* 条目管理：工具栏设为单列、按钮全宽 */
  #view-entries > .flex.items-center.justify-between {
    flex-direction: column; align-items: stretch; gap: 10px;
  }
  #view-entries > .flex.items-center.justify-between > .flex {
    flex-wrap: wrap; gap: 8px;
  }
  #view-entries > .flex.items-center.justify-between > .flex button { flex: 1; }
  .flex.flex-wrap.items-center.gap-3 { gap: 8px !important; }
  #entry-search { font-size: 14px !important; }

  /* 设置页操作按钮全宽 */
  #view-settings .flex.items-center.gap-3.mt-5 button {
    flex: 1; padding: 10px 12px !important;
  }

  /* 弹窗适配 */
  #breakthrough-modal > div.bg-white { padding: 18px !important; max-height: 85vh !important; }

  /* Toast 移动到底部全宽 */
  #toast-container {
    left: 12px; right: 12px; bottom: 12px;
  }
  #toast-container .toast { max-width: none !important; }

  /* 长文本自动换行，避免撑破布局 */
  .prose, #review-content, .breakthrough-card, .entry-card { word-break: break-word; }
  code { word-break: break-all; }
}

/* --- 渐变文字 --- */
.gradient-text {
  background: linear-gradient(135deg, #4A7C59, #7CB9A8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- 分隔线 --- */
.soft-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #e8e8e6, transparent);
  margin: 16px 0;
}
