/* ═══════════════════════════════════════════
   discovery.css — 发现窗口样式
   白底设计，使用 style.css 变量
   P2 社群区样式 + P3 草稿区样式
   ═══════════════════════════════════════════ */

/* ─── 容器 ─── */
.discovery-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--c-bg, #fff);
  color: var(--c-text, #1a1a1a);
  font-size: 14px;
}

/* ─── Tab 栏 ─── */
.discovery-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--c-border, #e5e5e5);
  flex-shrink: 0;
}

.discovery-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--c-text-secondary, #666);
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--r-xs, 4px) var(--r-xs, 4px) 0 0;
  transition: all 0.15s ease;
}

.discovery-tab:hover:not(.disabled) {
  color: var(--c-text, #1a1a1a);
  background: var(--c-bg-hover, #f5f5f5);
}

.discovery-tab.active {
  color: var(--c-accent, #2563eb);
  border-bottom-color: var(--c-accent, #2563eb);
  font-weight: 500;
}

.discovery-tab.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tab-icon {
  font-size: 14px;
}

.tab-label {
  font-size: 13px;
}

.tab-soon {
  font-size: 10px;
  opacity: 0.6;
  margin-left: 2px;
}

/* ─── Tab 内容区 ─── */
.discovery-tab-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
}

.tab-content-inner {
  height: 100%;
}

/* ─── 占位 ─── */
.tab-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--c-text-secondary, #666);
  text-align: center;
}

.placeholder-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.tab-placeholder p {
  margin: 4px 0;
}

.placeholder-hint {
  font-size: 12px;
  opacity: 0.6;
}

/* ─── 工具栏（排序 + 类型筛选） ─── */
.discovery-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.sort-group,
.type-group {
  display: flex;
  gap: 4px;
  background: var(--c-bg-secondary, #f8f8f8);
  border-radius: var(--r-sm, 6px);
  padding: 2px;
}

.sort-btn,
.type-btn {
  padding: 5px 12px;
  border: none;
  border-radius: var(--r-xs, 4px);
  background: transparent;
  color: var(--c-text-secondary, #666);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.sort-btn:hover,
.type-btn:hover {
  color: var(--c-text, #1a1a1a);
}

.sort-btn.active,
.type-btn.active {
  background: var(--c-bg, #fff);
  color: var(--c-accent, #2563eb);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.06));
  font-weight: 500;
}

/* ═══════════════════════════════════════════
   P1 成品区 — 瀑布流网格
   ═══════════════════════════════════════════ */

.works-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.works-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 0;
  color: var(--c-text-secondary, #666);
  font-size: 13px;
}

/* ─── 作品卡片 ─── */
.work-card {
  background: var(--c-bg, #fff);
  border: 1px solid var(--c-border, #e5e5e5);
  border-radius: var(--r-md, 10px);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.work-card:hover {
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,.08));
  transform: translateY(-1px);
}

.work-card-cover {
  position: relative;
  width: 100%;
  padding-top: 66%; /* 3:2 比例 */
  background: var(--c-bg-secondary, #f8f8f8);
  overflow: hidden;
}

.work-card-cover img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.work-card-cover-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--c-text-secondary, #666);
  opacity: 0.3;
}

/* 类型标签 */
.work-card-type {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 8px;
  border-radius: var(--r-xs, 4px);
  font-size: 11px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
}

.work-card-type.type-novel { background: rgba(37, 99, 235, 0.8); }
.work-card-type.type-video { background: rgba(220, 38, 38, 0.8); }
.work-card-type.type-game { background: rgba(22, 163, 74, 0.8); }
.work-card-type.type-other { background: rgba(107, 114, 128, 0.8); }

/* 卡片内容 */
.work-card-body {
  padding: 10px;
}

.work-card-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--c-text, #1a1a1a);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 作者行 */
.work-card-author {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.work-card-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.work-card-avatar--default {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-accent, #2563eb);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
}

.work-card-author-name {
  font-size: 12px;
  color: var(--c-text-secondary, #666);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-card-author-name:hover {
  color: var(--c-accent, #2563eb);
}

/* 统计按钮行 */
.work-card-stats {
  display: flex;
  gap: 12px;
}

.stat-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--c-text-secondary, #666);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.stat-btn:hover {
  color: var(--c-text, #1a1a1a);
}

.stat-icon {
  font-size: 14px;
}

.stat-btn.active .stat-icon {
  color: #ef4444;
}

.stat-btn.active.like-btn .stat-icon {
  color: #ef4444;
}

.stat-btn.active.fav-btn .stat-icon {
  color: #f59e0b;
}

.stat-count {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* ─── 加载状态 ─── */
.works-loading,
.posts-loading,
.drafts-loading {
  text-align: center;
  padding: 16px 0;
  color: var(--c-text-secondary, #666);
  font-size: 12px;
}

.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--c-border, #e5e5e5);
  border-top-color: var(--c-accent, #2563eb);
  border-radius: 50%;
  animation: discovery-spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes discovery-spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════
   P2 社群区 — 单列动态流
   ═══════════════════════════════════════════ */

/* ─── 动态流容器 ─── */
.posts-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.posts-empty {
  text-align: center;
  padding: 48px 0;
  color: var(--c-text-secondary, #666);
  font-size: 13px;
}

/* ─── 帖子卡片 ─── */
.post-card {
  background: var(--c-bg, #fff);
  border: 1px solid var(--c-border, #e5e5e5);
  border-radius: var(--r-md, 10px);
  padding: 14px;
  transition: box-shadow 0.2s ease;
}

.post-card:hover {
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.06));
}

/* 卡片头部：作者信息 + 类型标签 */
.post-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.post-card-author {
  display: flex;
  align-items: center;
  gap: 8px;
}

.post-card-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.post-card-avatar--default {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-accent, #2563eb);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}

.post-card-author-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.post-card-author-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text, #1a1a1a);
  cursor: pointer;
  line-height: 1.2;
}

.post-card-author-name:hover {
  color: var(--c-accent, #2563eb);
}

.post-card-time {
  font-size: 11px;
  color: var(--c-text-secondary, #666);
  line-height: 1.2;
}

/* 类型标签 */
.post-card-type-badge {
  padding: 2px 8px;
  border-radius: var(--r-xs, 4px);
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
}

.post-card-type-badge.type-thought {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.post-card-type-badge.type-share {
  background: rgba(22, 163, 74, 0.1);
  color: #16a34a;
}

.post-card-type-badge.type-question {
  background: rgba(234, 179, 8, 0.1);
  color: #ca8a04;
}

.post-card-type-badge.type-progress {
  background: rgba(168, 85, 247, 0.1);
  color: #9333ea;
}

/* ─── 帖子内容区 ─── */
.post-card-content {
  margin-bottom: 10px;
}

.post-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--c-text, #1a1a1a);
  word-break: break-word;
  white-space: pre-wrap;
}

/* 提问标题 */
.post-question-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--c-text, #1a1a1a);
}

/* 进展标题 */
.post-progress-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--c-text, #1a1a1a);
}

/* 分享卡片 */
.post-share-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--c-bg-secondary, #f8f8f8);
  border: 1px solid var(--c-border, #e5e5e5);
  border-radius: var(--r-sm, 6px);
  cursor: pointer;
  transition: background 0.15s ease;
}

.post-share-card:hover {
  background: var(--c-bg-hover, #f5f5f5);
}

.post-share-icon {
  font-size: 18px;
  flex-shrink: 0;
  opacity: 0.6;
}

.post-share-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.post-share-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text, #1a1a1a);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-share-url {
  font-size: 11px;
  color: var(--c-text-secondary, #666);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 进展关联作品 */
.post-progress-ref {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--c-bg-secondary, #f8f8f8);
  border-radius: var(--r-sm, 6px);
}

.post-ref-label {
  font-size: 11px;
  color: var(--c-text-secondary, #666);
  flex-shrink: 0;
}

.post-ref-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--c-accent, #2563eb);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── 帖子操作行 ─── */
.post-card-actions {
  display: flex;
  gap: 16px;
  padding-top: 8px;
  border-top: 1px solid var(--c-border, #e5e5e5);
}

.post-card-actions .stat-btn {
  padding: 4px 8px;
  border-radius: var(--r-xs, 4px);
  transition: all 0.15s ease;
}

.post-card-actions .stat-btn:hover {
  background: var(--c-bg-secondary, #f8f8f8);
}

/* ═══════════════════════════════════════════
   P3 草稿区 — 双列网格 + 详情面板
   ═══════════════════════════════════════════ */

/* ─── 草稿网格 ─── */
.drafts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.drafts-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 0;
  color: var(--c-text-secondary, #666);
  font-size: 13px;
}

/* ─── 草稿卡片 ─── */
.draft-card {
  background: var(--c-bg, #fff);
  border: 1px solid var(--c-border, #e5e5e5);
  border-radius: var(--r-md, 10px);
  padding: 14px;
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.draft-card:hover {
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,.08));
  transform: translateY(-1px);
}

.draft-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.draft-card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--c-text, #1a1a1a);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* 草稿类型标签 */
.draft-card-type {
  padding: 2px 8px;
  border-radius: var(--r-xs, 4px);
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
}

.draft-card-type.type-novel {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.draft-card-type.type-art {
  background: rgba(168, 85, 247, 0.1);
  color: #9333ea;
}

.draft-card-type.type-code {
  background: rgba(22, 163, 74, 0.1);
  color: #16a34a;
}

.draft-card-type.type-other {
  background: rgba(107, 114, 128, 0.1);
  color: #6b7280;
}

.draft-card-body {
  flex: 1;
}

.draft-card-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--c-text-secondary, #666);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.draft-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--c-border, #e5e5e5);
}

.draft-feedback-count {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--c-text-secondary, #666);
  font-size: 12px;
}

.draft-feedback-count .stat-icon {
  font-size: 13px;
}

/* ─── 详情面板遮罩 ─── */
.draft-detail-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: draft-overlay-in 0.15s ease;
}

@keyframes draft-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ─── 详情面板 ─── */
.draft-detail-panel {
  width: 90%;
  max-width: 480px;
  max-height: 85%;
  background: var(--c-bg, #fff);
  border-radius: var(--r-lg, 16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  overflow-y: auto;
  animation: draft-panel-in 0.2s ease;
}

@keyframes draft-panel-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.draft-detail-close-bar {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px 0;
}

.draft-detail-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--c-bg-secondary, #f8f8f8);
  color: var(--c-text-secondary, #666);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.draft-detail-close:hover {
  background: var(--c-bg-hover, #f0f0f0);
  color: var(--c-text, #1a1a1a);
}

.draft-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px 0;
}

.draft-detail-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--c-text, #1a1a1a);
  flex: 1;
}

.draft-detail-desc {
  margin: 8px 16px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--c-text-secondary, #666);
}

.draft-detail-content {
  margin: 12px 16px;
  padding: 12px;
  background: var(--c-bg-secondary, #f8f8f8);
  border-radius: var(--r-sm, 6px);
  font-size: 13px;
  line-height: 1.6;
  color: var(--c-text, #1a1a1a);
  white-space: pre-wrap;
  word-break: break-word;
}

.draft-content-json {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  overflow-x: auto;
}

/* ─── 反馈区 ─── */
.feedback-section {
  padding: 0 16px 16px;
}

.feedback-section-title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text, #1a1a1a);
  padding-top: 12px;
  border-top: 1px solid var(--c-border, #e5e5e5);
}

.feedback-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.feedback-empty {
  text-align: center;
  padding: 16px 0;
  color: var(--c-text-secondary, #666);
  font-size: 12px;
}

.feedback-item {
  padding: 10px 12px;
  background: var(--c-bg-secondary, #f8f8f8);
  border-radius: var(--r-sm, 6px);
}

.feedback-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.feedback-author {
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text, #1a1a1a);
}

.feedback-rating {
  font-size: 11px;
  color: #f59e0b;
  letter-spacing: -1px;
}

.feedback-time {
  font-size: 11px;
  color: var(--c-text-secondary, #666);
  margin-left: auto;
}

.feedback-content {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--c-text, #1a1a1a);
  word-break: break-word;
  white-space: pre-wrap;
}

/* ─── 反馈输入区 ─── */
.feedback-input-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feedback-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--c-border, #e5e5e5);
  border-radius: var(--r-sm, 6px);
  background: var(--c-bg, #fff);
  color: var(--c-text, #1a1a1a);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.feedback-input:focus {
  outline: none;
  border-color: var(--c-accent, #2563eb);
}

.feedback-input::placeholder {
  color: var(--c-text-secondary, #999);
}

.feedback-input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.feedback-rating-input {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rating-label {
  font-size: 12px;
  color: var(--c-text-secondary, #666);
}

.rating-stars {
  display: flex;
  gap: 2px;
}

.rating-star {
  font-size: 16px;
  color: var(--c-border, #e5e5e5);
  cursor: pointer;
  transition: color 0.1s ease;
  user-select: none;
}

.rating-star:hover,
.rating-star.active {
  color: #f59e0b;
}

.feedback-submit-btn {
  padding: 6px 16px;
  border: none;
  border-radius: var(--r-xs, 4px);
  background: var(--c-accent, #2563eb);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.feedback-submit-btn:hover:not(:disabled) {
  background: #1d4ed8;
}

.feedback-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── 响应式 ─── */
@media (max-width: 400px) {
  .works-grid,
  .drafts-grid {
    grid-template-columns: 1fr;
  }

  .discovery-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .sort-group,
  .type-group {
    justify-content: center;
  }

  .post-card {
    padding: 12px;
  }

  .post-card-avatar {
    width: 24px;
    height: 24px;
  }

  .post-card-avatar--default {
    font-size: 11px;
  }

  .draft-detail-panel {
    width: 95%;
    max-height: 90%;
  }

  .draft-detail-title {
    font-size: 16px;
  }
}
