/* ============================================
   社区功能样式
   ============================================ */

/* ===== 通用组件 ===== */

/* 头像 */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
  background: var(--gray-100);
}

.avatar-xs { width: 24px; height: 24px; }
.avatar-sm { width: 32px; height: 32px; }
.avatar-md { width: 40px; height: 40px; }
.avatar-lg { width: 48px; height: 48px; }
.avatar-xl { width: 64px; height: 64px; }
.avatar-2xl { width: 96px; height: 96px; }

/* 徽章/角标 */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  line-height: 1;
  color: #fff;
  background: var(--danger);
  border-radius: var(--radius-full);
}

.badge-primary { background: var(--primary); }
.badge-success { background: var(--success); }
.badge-warning { background: var(--warning); }

/* 状态指示器 */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--gray-400);
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--gray-400); }
.status-dot.busy { background: var(--danger); }

/* ===== 点赞按钮 ===== */
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  transition: var(--transition-base);
}

.like-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-bg);
}

.like-btn.liked {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-bg);
}

.like-btn .like-icon {
  font-size: var(--text-base);
  transition: transform 0.2s ease;
}

.like-btn:active .like-icon {
  transform: scale(1.3);
}

.like-btn.liked .like-icon {
  animation: heartBeat 0.3s ease;
}

@keyframes heartBeat {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ===== 关注按钮 ===== */
.follow-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  transition: var(--transition-base);
}

.follow-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px var(--primary-shadow);
}

.follow-btn.following {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.follow-btn.following:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-bg);
}

/* ===== 用户卡片 ===== */
.user-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  transition: var(--transition-base);
}

.user-card:hover {
  background: var(--gray-50);
}

.user-card .user-info {
  flex: 1;
  min-width: 0;
}

.user-card .username {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card .user-handle {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ===== 动态流卡片 ===== */
.feed-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-base);
}

.feed-card:hover {
  box-shadow: var(--shadow-md);
}

.feed-card .feed-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.feed-card .feed-body {
  margin-bottom: var(--space-4);
}

.feed-card .feed-footer {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-light);
}

.feed-type-badge {
  display: inline-block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--gray-100);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

/* ===== 对话列表 ===== */
.conversation-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition-base);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.conversation-item:hover {
  background: var(--gray-50);
}

.conversation-item:last-child {
  border-bottom: none;
}

.conversation-item .conv-avatar {
  position: relative;
  flex-shrink: 0;
}

.conversation-item .conv-info {
  flex: 1;
  min-width: 0;
}

.conversation-item .conv-name {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-1);
}

.conversation-item .conv-name span:first-child {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.conversation-item .conv-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.conversation-item .conv-preview {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item .unread-badge {
  position: absolute;
  top: -2px;
  right: -2px;
}

/* ===== 聊天气泡 ===== */
.message-bubble {
  display: flex;
  gap: var(--space-2);
  max-width: 75%;
  margin-bottom: var(--space-3);
}

.message-bubble.sent {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-bubble.received {
  margin-right: auto;
}

.message-bubble .bubble-content {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  line-height: var(--line-height-normal);
  word-break: break-word;
}

.message-bubble.sent .bubble-content {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: var(--radius-xs);
}

.message-bubble.received .bubble-content {
  background: var(--gray-100);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-xs);
}

.message-bubble .bubble-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
  display: block;
}

.message-bubble.sent .bubble-time {
  text-align: right;
}

/* ===== 通知下拉 ===== */
.notification-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  width: 360px;
  max-height: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
  overflow: hidden;
  animation: dropdownIn 0.2s ease;
}

.notification-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-light);
}

.notification-header h4 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

.notification-list {
  max-height: 400px;
  overflow-y: auto;
}

.notification-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition-base);
  cursor: pointer;
}

.notification-item:hover {
  background: var(--gray-50);
}

.notification-item.unread {
  background: var(--primary-bg);
}

.notification-item .notif-content {
  flex: 1;
  min-width: 0;
}

.notification-item .notif-title {
  font-weight: var(--font-medium);
  margin-bottom: var(--space-1);
}

.notification-item .notif-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notification-item .notif-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* ===== 用户统计 ===== */
.user-stats {
  display: flex;
  gap: var(--space-6);
}

.stat-item {
  text-align: center;
}

.stat-count {
  display: block;
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.empty-state h3 {
  font-size: var(--text-xl);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state p {
  margin-bottom: var(--space-6);
}

/* ===== 加载状态 ===== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

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

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-8);
  color: var(--text-muted);
}

/* ===== 骨架屏 ===== */
.skeleton {
  background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-shine) 50%, var(--skeleton-base) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 16px;
  margin-bottom: var(--space-2);
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton-image {
  width: 100%;
  height: 200px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .notification-dropdown {
    width: calc(100vw - var(--space-8));
    right: calc(-1 * var(--space-2));
  }

  .user-stats {
    gap: var(--space-4);
  }

  .stat-count {
    font-size: var(--text-xl);
  }

  .message-bubble {
    max-width: 85%;
  }
}

@media (max-width: 480px) {
  .feed-card {
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }

  .conversation-item {
    padding: var(--space-3);
  }
}

/* ===== 私信弹窗 ===== */
.chat-modal-overlay {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
}

.chat-modal {
  width: 380px;
  height: 500px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
}

.chat-modal-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-modal-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.3);
}

.chat-modal-username {
  font-weight: 600;
  font-size: 16px;
}

.chat-modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.8;
}

.chat-modal-close:hover {
  opacity: 1;
}

.chat-modal-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-modal-empty {
  text-align: center;
  color: #999;
  padding: 40px;
}

.chat-modal-msg {
  display: flex;
  gap: 8px;
  max-width: 80%;
}

.chat-modal-msg.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}

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

.chat-modal-msg .msg-content {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-modal-msg.sent .msg-content {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-modal-msg.received .msg-content {
  background: #f0f0f0;
  color: #333;
  border-bottom-left-radius: 4px;
}

.chat-modal-msg .msg-time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

.chat-modal-msg.sent .msg-time {
  text-align: right;
}

.chat-modal-input {
  display: flex;
  padding: 12px 16px;
  border-top: 1px solid #eee;
  gap: 8px;
}

.chat-modal-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
}

.chat-modal-input input:focus {
  border-color: var(--primary);
}

.chat-modal-input button {
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
}

.chat-modal-input button:hover {
  background: var(--primary-dark);
}

@media (max-width: 480px) {
  .chat-modal-overlay {
    bottom: 0;
    right: 0;
    left: 0;
  }

  .chat-modal {
    width: 100%;
    height: 70vh;
    border-radius: 16px 16px 0 0;
  }
}
