/* ============================================================
   ENGAGEMENT PAGE STYLES
   User-facing engagement and contests page
   ============================================================ */

/* Main Container - 66% + 33% Layout */
.engagement-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 66% 33%;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1200px) {
  .engagement-main {
    grid-template-columns: 1fr;
  }
  
  .engagement-sidebar {
    order: -1;
  }
}

/* Left Feed - 66% */
.engagement-feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Engagement Tabs */
.engagement-tabs {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r16);
  box-shadow: var(--shadow1);
}

.engagement-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--r12);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.70);
  color: var(--text);
  font-weight: 700;
  font-size: var(--t-sm);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

[data-theme="dark"] .engagement-tab {
  background: rgba(255, 255, 255, 0.06);
}

.engagement-tab:hover {
  border-color: rgba(124, 58, 237, 0.5);
  background: rgba(124, 58, 237, 0.08);
}

.engagement-tab.active {
  border-color: rgba(124, 58, 237, 0.55);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.16), rgba(14, 165, 233, 0.10));
  color: var(--brand3);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.15);
}

.engagement-tab svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Contests Feed Container */
.contests-feed-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Contest Card - Similar to Post Item */
.contest-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r20);
  padding: 24px;
  box-shadow: var(--shadow1);
  transition: all 0.2s var(--ease);
}

.contest-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow2);
}

/* Contest Header - Author Info */
.contest-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.contest-author-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--r12);
  border: 2px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--panel2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  color: var(--text);
}

.contest-author-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.contest-author-info {
  flex: 1;
  min-width: 0;
}

.contest-author-name {
  font-size: var(--t-lg);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.contest-timestamp {
  font-size: var(--t-xs);
  color: var(--muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.contest-timestamp::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
}

/* Contest Content */
.contest-content {
  margin: 16px 0;
}

.contest-title {
  font-size: var(--t-xl);
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.3;
}

.contest-description {
  font-size: var(--t-md);
  font-weight: 500;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.contest-image {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: var(--r16);
  margin: 16px 0;
  border: 1px solid var(--border);
}

.contest-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px;
  background: var(--panel2);
  border-radius: var(--r12);
  margin: 16px 0;
  font-size: var(--t-sm);
}

.contest-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
}

.contest-meta-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Contest Countdown */
.contest-countdown {
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(14, 165, 233, 0.08));
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: var(--r12);
  margin: 16px 0;
  font-size: var(--t-md);
  font-weight: 700;
  color: var(--brand3);
  text-align: center;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.countdown-timer {
  font-size: var(--t-md);
  font-weight: 700;
  color: var(--brand3);
}

/* Live Countdown Styles */
.countdown-live {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  color: var(--brand3);
  font-size: var(--t-md);
  letter-spacing: 0.5px;
}

.countdown-value {
  display: inline-block;
  min-width: 28px;
  text-align: center;
  padding: 2px 6px;
  background: rgba(124, 58, 237, 0.15);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  animation: countdownPulse 1s ease-in-out infinite;
}

@keyframes countdownPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.9;
    transform: scale(0.98);
  }
}

.countdown-ended {
  font-size: var(--t-sm);
  font-weight: 700;
}

/* Contest Actions - Like, Share, Comment */
.contest-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.contest-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--r12);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.70);
  color: var(--text);
  font-weight: 700;
  font-size: var(--t-sm);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  flex: 1;
  min-width: 120px;
  justify-content: center;
}

[data-theme="dark"] .contest-action-btn {
  background: rgba(255, 255, 255, 0.06);
}

.contest-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow1);
}

.contest-action-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.contest-action-btn.like.active {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
}

.contest-action-btn.share.active {
  border-color: rgba(124, 58, 237, 0.55);
  background: rgba(124, 58, 237, 0.12);
  color: var(--brand3);
}

.contest-action-btn.comment.active {
  border-color: rgba(16, 185, 129, 0.55);
  background: rgba(16, 185, 129, 0.12);
  color: var(--good);
}

.contest-action-btn.participate {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.16), rgba(14, 165, 233, 0.10));
  border-color: rgba(124, 58, 237, 0.55);
  color: var(--brand);
  font-weight: 800;
}

.contest-action-btn.participate:hover {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.25), rgba(14, 165, 233, 0.15));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.contest-action-btn.participate.participated {
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.16), rgba(16, 185, 129, 0.10));
  border-color: rgba(22, 163, 74, 0.55);
  color: var(--good);
}

.contest-action-btn.participate.participated:hover {
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.25), rgba(16, 185, 129, 0.15));
}

/* Past Contest Winners Section */
.contest-winners {
  margin-top: 20px;
  padding: 16px;
  background: var(--panel2);
  border-radius: var(--r16);
  border: 1px solid var(--border);
}

.contest-winners-title {
  font-size: var(--t-lg);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.contest-winners-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.winner-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--panel);
  border-radius: var(--r12);
  border: 1px solid var(--border);
}

.winner-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--r12);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--panel2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}

.winner-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.winner-name {
  font-size: var(--t-md);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.winner-position {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--brand);
}

/* Right Sidebar - 33% */
.engagement-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 24px;
}

/* Sidebar Widget */
.sidebar-widget {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r20);
  box-shadow: var(--shadow1);
  overflow: hidden;
}

.widget-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.widget-header h3 {
  font-size: var(--t-lg);
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.widget-header p {
  font-size: var(--t-sm);
  color: var(--muted);
  font-weight: 600;
}

.widget-content {
  padding: 16px;
  max-height: 600px;
  overflow-y: auto;
}

.widget-content::-webkit-scrollbar {
  width: 6px;
}

.widget-content::-webkit-scrollbar-track {
  background: transparent;
}

.widget-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

/* Leaderboard Tabs */
.leaderboard-tabs {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--border);
}

.leaderboard-tab {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--r12);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.70);
  color: var(--text);
  font-weight: 700;
  font-size: var(--t-xs);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  text-align: center;
}

[data-theme="dark"] .leaderboard-tab {
  background: rgba(255, 255, 255, 0.06);
}

.leaderboard-tab:hover {
  border-color: rgba(124, 58, 237, 0.5);
}

.leaderboard-tab.active {
  border-color: rgba(124, 58, 237, 0.55);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.16), rgba(14, 165, 233, 0.10));
  color: var(--brand3);
}

/* Participation Card */
.participation-card {
  padding: 16px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--r16);
  margin-bottom: 12px;
  transition: all 0.2s var(--ease);
}

.participation-card:hover {
  border-color: rgba(124, 58, 237, 0.5);
  box-shadow: var(--shadow1);
  transform: translateY(-2px);
}

.participation-card:last-child {
  margin-bottom: 0;
}

.participation-card.past-participation {
  opacity: 0.85;
}

.participation-card-header {
  margin-bottom: 12px;
}

.participation-title {
  font-size: var(--t-md);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}

.participation-engagement {
  font-size: var(--t-xs);
  color: var(--muted);
  font-weight: 600;
  margin-top: 4px;
}

.participation-countdown {
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(14, 165, 233, 0.08));
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: var(--r12);
  margin-bottom: 12px;
  font-size: var(--t-sm);
  font-weight: 700;
  color: var(--brand3);
  text-align: center;
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.participation-status {
  margin-bottom: 12px;
}

.participation-meta {
  font-size: var(--t-sm);
  color: var(--muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.participation-meta svg {
  flex-shrink: 0;
}

/* Leaderboard Entry */
.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--r12);
  margin-bottom: 10px;
  transition: all 0.2s var(--ease);
}

.leaderboard-entry:hover {
  border-color: rgba(124, 58, 237, 0.5);
  box-shadow: var(--shadow1);
}

.leaderboard-entry:last-child {
  margin-bottom: 0;
}

.leaderboard-rank {
  width: 32px;
  height: 32px;
  border-radius: var(--r12);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.16), rgba(14, 165, 233, 0.10));
  border: 1px solid rgba(124, 58, 237, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: var(--t-sm);
  color: var(--brand3);
  flex-shrink: 0;
}

.leaderboard-entry.rank-1 .leaderboard-rank {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(251, 191, 36, 0.15));
  border-color: rgba(245, 158, 11, 0.4);
  color: #f59e0b;
}

.leaderboard-entry.rank-2 .leaderboard-rank {
  background: linear-gradient(135deg, rgba(156, 163, 175, 0.2), rgba(209, 213, 219, 0.15));
  border-color: rgba(156, 163, 175, 0.4);
  color: #9ca3af;
}

.leaderboard-entry.rank-3 .leaderboard-rank {
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.2), rgba(217, 119, 6, 0.15));
  border-color: rgba(180, 83, 9, 0.4);
  color: #b45309;
}

.leaderboard-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--r12);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--panel2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}

.leaderboard-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.leaderboard-name {
  font-size: var(--t-md);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.leaderboard-stats-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.leaderboard-stat-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.leaderboard-stat-number {
  font-size: var(--t-lg);
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.leaderboard-stat-number.stat-wins-number {
  color: #f59e0b;
}

.leaderboard-stat-number.stat-score-number {
  color: var(--brand);
}

.leaderboard-stat-text {
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
}

.leaderboard-stat-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
  flex-shrink: 0;
  opacity: 0.5;
}

/* Empty States */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: var(--t-lg);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: var(--t-md);
  color: var(--muted);
  font-weight: 600;
}

/* Modal Styles (reused from community) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--panel);
  border-radius: var(--r20);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow4);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: var(--t-xl);
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: var(--r12);
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
}

.modal-close:hover {
  border-color: var(--bad);
  background: rgba(239, 68, 68, 0.1);
  color: var(--bad);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Share Popup Styles (reused from community) */
.share-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.share-popup {
  background: var(--panel);
  border-radius: var(--r20);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow4);
  overflow: hidden;
}

.share-popup-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.share-popup-header h3 {
  font-size: var(--t-xl);
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

.share-popup-close {
  width: 36px;
  height: 36px;
  border-radius: var(--r12);
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
}

.share-popup-close:hover {
  border-color: var(--bad);
  background: rgba(239, 68, 68, 0.1);
  color: var(--bad);
}

.share-popup-content {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Participation Modal */
.participation-modal {
  max-width: 700px;
}

.participation-step {
  padding: 8px;
}

/* Contest Comments Section (Inline) */
.contest-comments-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid var(--border);
  animation: fadeIn 0.3s ease;
}

.comment-item-inline {
  padding: 16px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--r12);
  transition: all 0.2s var(--ease);
}

.comment-item-inline:hover {
  border-color: rgba(124, 58, 237, 0.3);
  box-shadow: var(--shadow1);
}

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

/* Responsive */
@media (max-width: 768px) {
  .engagement-main {
    padding: 16px;
    gap: 16px;
  }
  
  .contest-card {
    padding: 16px;
  }
  
  .contest-actions {
    flex-direction: column;
  }
  
  .contest-action-btn {
    width: 100%;
  }
  
  .participation-modal {
    max-width: 95%;
  }
}
