/* ========================================
   Modal Styles - 弹窗基础样式
   ======================================== */

/* 弹窗根容器 */
.modal-root {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  overscroll-behavior: contain;
}

/* 发布需求弹窗需要更高的z-index，确保在人脉管理弹窗之上 */
#publish-demand-modal {
  z-index: 55;
}

/* 认证弹窗需要较高的z-index，确保在资源网络等基础弹窗之上，但在确认类弹窗之下 */
#verify-modal {
  z-index: 58;
}

/* 登录弹窗需要较高的z-index，确保在探索弹窗等其他弹窗之上 */
#tg-login-modal {
  z-index: 58;
}

/* 确认类弹窗（如删除、下架确认）需要最高的z-index，确保在所有其他弹窗之上 */
#publish-demand-confirm-modal,
#demand-offline-confirm-modal,
#delete-modal,
#logout-modal {
  z-index: 60;
}

.modal-root.open {
  display: flex;
}

/* 弹窗背景遮罩 */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17,24,39,0.35);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  touch-action: none; /* 避免在遮罩上触发滚动手势 */
}

/* 打开弹窗时冻结页面在 iOS/PWA 下防止背景滑动 */
body.modal-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

/* 弹窗面板 */
.modal-panel {
  position: relative;
  margin: auto;
  width: min(560px, calc(100% - 24px));
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: 0 16px 40px var(--shadow), inset 0 1px rgba(255,255,255,0.6);
  color: var(--text);
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

#tge-detail-modal .modal-panel {
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

/* 弹窗头部 */
.modal-head {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid rgba(17,24,39,0.08);
}

.modal-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.modal-title {
  font-weight: 600;
}

.modal-sub {
  font-size: 12px;
  color: var(--muted);
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-handle {
  font-size: 12px;
  color: var(--muted);
}

.modal-bio {
  display: none;
}

.modal-updated {
  font-size: 11px;
  color: var(--muted);
  justify-self: end;
  text-align: right;
  margin-top: 2px;
  max-width: 84px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-stats {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.55);
}

.stat-num {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
}

/* 弹窗操作按钮 */
.modal-action {
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.70);
  color: var(--text);
  font-size: 12px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  box-sizing: border-box;
}

.modal-action:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.modal-action[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.7;
}

.modal-action.loading {
  opacity: 0.75;
}

.modal-action.success {
  background: rgba(255,255,255,0.80);
  box-shadow: inset 0 1px rgba(255,255,255,0.7);
}

.modal-action .action-title {
  line-height: 1.1;
}

.modal-action .action-sub {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.1;
}

/* 强调色按钮：用于 AI 搜索等主操作 */
.accent-action {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 2px 8px rgba(17,24,39,0.12);
}

.accent-action .action-sub {
  color: rgba(255,255,255,0.85);
}

.accent-action:hover {
  filter: brightness(1.02);
}

.accent-action.loading .action-title::after {
  border-color: rgba(255,255,255,0.6);
  border-top-color: #fff;
}

/* 完成态：强调按钮保持渐变，不变成白色 */
.accent-action.success {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 2px 8px rgba(17,24,39,0.14);
}

.accent-action.success .action-sub {
  color: rgba(255,255,255,0.85);
}

/* 按钮加载中：在标题后显示旋转指示 */
.modal-action.loading .action-title::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 6px;
  border-radius: 50%;
  border: 2px solid rgba(17,24,39,0.15);
  border-top-color: var(--accent-2);
  animation: prspin 600ms linear infinite;
  vertical-align: -2px;
}

/* 原文弹窗中的 AI 搜索按钮：更小、更明显的加载旋转指示（主题色） */
#content-ai-explore-btn.loading .action-title::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  position: relative;
  top: 0px;
  border-radius: 50%;
  border: 2px solid rgba(17,24,39,0.22);
  border-top-color: var(--accent-2);
  animation: prspin 600ms linear infinite;
}

/* 弹窗关闭按钮 */
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255,255,255,0.65);
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  cursor: pointer;
}

.modal-close span {
  font-size: 16px;
  line-height: 1;
  color: var(--text);
}

/* 弹窗分隔线 */
.modal-divider {
  height: 1px;
  background: rgba(17,24,39,0.10);
  margin: 6px 0;
}

/* 弹窗选项卡 */
.modal-tabs {
  display: flex;
  gap: 0;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(17,24,39,0.10);
}

.modal-tabs .tab {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}

.modal-tabs .tab.active {
  background: transparent;
  border-bottom-color: var(--accent-2);
}

/* 选项卡加载中：显示旋转指示 */
.modal-tabs .tab.loading::after {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 6px;
  border-radius: 50%;
  border: 2px solid rgba(17,24,39,0.15);
  border-top-color: var(--accent-2);
  animation: prspin 600ms linear infinite;
  vertical-align: -1px;
}

/* 选项卡锁定：不可点击，显示锁图标 */
.modal-tabs .tab.locked {
  cursor: not-allowed;
  opacity: 0.6;
}

.modal-tabs .tab.locked::before {
  content: '🔒';
  margin-right: 4px;
  font-size: 10px;
}

/* 弹窗内容区域 */
.modal-body {
  padding: 12px;
}

.panel {
  display: none;
}

.panel.active {
  display: grid;
  gap: 8px;
}

/* 特定弹窗的高度限制 */
#content-modal .modal-panel {
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

#content-modal .modal-body {
  flex: 1;
  overflow-y: auto;
  max-height: calc(80vh - 80px);
}

#tge-detail-modal .modal-panel {
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

#tge-detail-modal .modal-body {
  flex: 1;
  overflow-y: auto;
  display: grid;
  gap: 8px;
}

#profile-modal .modal-panel {
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

#profile-modal .modal-body {
  flex: 1;
  overflow-y: auto;
}

#explore-modal .modal-panel {
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

#explore-modal .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* 探索弹窗历史搜索样式优化 */
#explore-modal #history-list {
  display: grid;
  gap: 8px;
}

#explore-modal #history-list .explore-history-item {
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.70);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  transition: all 160ms ease;
  cursor: pointer;
  min-height: auto;
}

#explore-modal #history-list .explore-history-item:hover {
  background: rgba(255,255,255,0.85);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(17,24,39,0.08);
}

.explore-history-row-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.explore-history-content {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.explore-history-title {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.3;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.explore-history-time {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.explore-history-expand-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  transition: transform 200ms ease, color 160ms ease;
}

#explore-modal #history-list .explore-history-item:hover .explore-history-expand-icon {
  color: var(--accent-2);
}

#explore-modal #history-list .explore-history-item[data-expanded="true"] .explore-history-expand-icon {
  transform: rotate(90deg);
  color: var(--accent-2);
}

.explore-history-detail {
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.90);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  max-height: 0px;
  overflow: hidden;
  opacity: 0;
  transition: max-height 220ms ease, opacity 220ms ease, margin-top 220ms ease, padding-top 220ms ease, padding-bottom 220ms ease;
}

.explore-history-detail.expanded {
  max-height: 2000px;
  opacity: 1;
  margin-top: 4px;
  padding-top: 12px;
  padding-bottom: 12px;
}

/* Telegram 登录弹窗和 Bot 弹窗 */
#tg-login-modal .modal-body {
  padding: 12px;
}

#bot-modal .modal-body {
  padding: 12px;
}

#report-modal .modal-panel {
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

#report-modal .modal-body {
  flex: 1;
  overflow-y: auto;
}

/* Report 弹窗：分块间距与样本行样式 */
#report-modal #report-content .analysis-block:not(:last-child) {
  margin-bottom: 12px;
}

#report-modal .summary-row {
  margin-top: 6px;
}

#report-modal .ai-summary-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}

#report-modal .summary-time {
  font-size: 11px;
  color: var(--muted);
  margin-left: 6px;
}

/* 关键词热度标识样式 */
#report-modal .kw-heat {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: #ef4444;
  margin-left: 6px;
}

#report-modal .kw-heat .heat-icon {
  font-size: 11px;
  line-height: 1;
  position: relative;
  top: -1px;
}

/* 报告弹窗：周期按钮选中态使用主题色 */
#report-modal .chip[aria-pressed="true"] {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 2px 8px rgba(17,24,39,0.14);
}

/* 关注星标样式 */
#profile-follow-star {
  width: auto;
  height: auto;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

#profile-follow-star span {
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
}

#profile-follow-star[data-focused="true"] span {
  color: var(--accent-2);
}

#profile-follow-star.loading span {
  animation: starPulse 800ms ease-in-out infinite;
  transform-origin: center;
}

#profile-follow-star[disabled] {
  cursor: default;
  opacity: 0.95;
}

/* 行情弹窗星星图标样式 - 与profile弹窗保持一致 */
#market-follow-star {
  width: auto;
  height: auto;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

#market-follow-star span {
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
}

#market-follow-star[data-focused="true"] span {
  color: var(--accent-2);
}

#market-follow-star.loading span {
  animation: starPulse 800ms ease-in-out infinite;
  transform-origin: center;
}

#market-follow-star[disabled] {
  cursor: default;
  opacity: 0.95;
}

/* 探索与历史列表的通用关注星标样式 */
.follow-star {
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  cursor: pointer;
}

.follow-star span {
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
}

.follow-star[data-focused="true"] span {
  color: var(--accent-2);
}

.follow-star.loading span {
  animation: starPulse 800ms ease-in-out infinite;
  transform-origin: center;
}

.follow-star[disabled] {
  cursor: default;
  opacity: 0.95;
}

/* 星标加载中的细微动效：脉动放大与颜色提升 */
@keyframes starPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); color: var(--accent-2); }
  100% { transform: scale(1); }
}

/* 旋转动画 */
@keyframes prspin {
  to { transform: rotate(360deg); }
}

