/* ==================================================
   06-sidebar.css (좌우 사이드바, 플레이어 목록, 순위, 통계)
   ================================================= */

/* 1. 좌측 사이드바 기본 스타일 */
.left-sidebar {
  grid-column: 1; /* 첫 번째 열 */
  grid-row: 2; /* 두 번째 행 */
  background: #f8f9fa;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
  gap: 20px;
}

/* 2. 우측 사이드바 기본 스타일 */
.right-sidebar {
  grid-column: 3; /* 세 번째 열 */
  grid-row: 2; /* 두 번째 행 */
  background: #f8f9fa;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
  gap: 20px;
}

/* 3. 방 제한 정보 섹션 */
.room-limits {
  background: white;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.limit-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.limit-icon {
  font-size: 14px;
}

.limit-label {
  font-weight: 500;
  color: #4a5568;
  flex: 1;
  font-size: 13px;
}

.limit-value {
  color: #4299e1;
  font-weight: 600;
  font-size: 13px;
}

/* 4. 플레이어 목록 섹션 */
.players-section {
  background: white;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.players-section h3 {
  margin-bottom: 12px;
  color: #2d3748;
  font-size: 15px;
}

#players-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}

/* 5. 플레이어 아이템 스타일 */
.player-item {
  background: #f7fafc;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.player-item .player-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #48bb78;
}

.player-number {
  background: #4299e1;
  color: white;
  padding: 2px 6px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
}

.player-item .player-name {
  font-weight: 500;
  font-size: 13px;
}

.player-progress {
  font-weight: 600;
  color: #4299e1;
  font-size: 12px;
}

/* 6. 플레이어 상태별 스타일 */
.player-item.playing {
  border-color: #48bb78;
  background: #f0fff4;
}

.player-item.waiting {
  border-color: #ed8936;
  background: #fef5e7;
  opacity: 0.9;
}

/* 7. 실시간 진행률 섹션 */
.live-progress-section {
  background: #f0fff4;
  padding: 16px;
  border-radius: 8px;
  border: 3px solid #48bb78;
  box-shadow: 0 4px 15px rgba(72, 187, 120, 0.2);
  flex: 1;
  min-height: 200px;
}

.live-progress-section h4 {
  margin-bottom: 12px;
  color: #48bb78;
  font-size: 16px;
  font-weight: 600;
}

.live-progress-container {
  overflow-y: auto;
}

/* 8. 실시간 순위 아이템 */
.live-rank-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: white;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 13px;
  border: 1px solid #e2e8f0;
  transition: all 0.2s;
}

.live-rank-item:hover {
  transform: translateX(3px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.live-rank-item.first-place {
  background: #fef5e7;
  border-color: #ed8936;
  font-weight: 600;
}

.rank {
  font-weight: 600;
  color: #48bb78;
  min-width: 24px;
}

.name {
  flex: 1;
  text-align: left;
  margin: 0 8px;
  color: #2d3748;
}

.progress {
  font-weight: 600;
  color: #48bb78;
}

/* 9. 리더보드 섹션 */
.leaderboard {
  background: white;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.leaderboard h3 {
  margin-bottom: 12px;
  color: #2d3748;
  font-size: 15px;
}

#leaderboard-list {
  overflow-y: auto;
}

/* 10. 일반 순위 아이템 */
.rank-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f7fafc;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
  border: 1px solid #e2e8f0;
}

.rank-item:last-child {
  border-bottom: none;
}

.rank-number {
  font-weight: bold;
  color: #007bff;
  width: 30px;
  text-align: center;
}

.rank-player {
  flex-grow: 1;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-wpm {
  font-weight: bold;
  color: #28a745;
  width: 70px;
  text-align: right;
}

.rank-accuracy {
  color: #6c757d;
  font-size: 0.85em;
  width: 50px;
  text-align: right;
}

/* 11. 오늘의 최고 기록 섹션 */
.today-best-section {
  background: white;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.today-best-section h4 {
  margin-bottom: 12px;
  color: #2d3748;
  font-size: 15px;
  font-weight: 600;
}

/* 12. TOP 10 순위 섹션 */
.top-rankings-section {
  background: white;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.top-rankings-section h4 {
  margin-bottom: 12px;
  color: #2d3748;
  font-size: 15px;
  font-weight: 600;
}

/* 13. TOP 10 랭킹 패널 스타일 */
.top-rankings-panel {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  padding: 15px;
  margin-bottom: 20px;
}

.top-rankings-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
}

.top-rankings-panel h3 {
  margin: 0;
  color: #333;
  font-size: 1.1em;
}

.rankings-list .loading,
.rankings-list .no-data,
.rankings-list .error {
  text-align: center;
  color: #777;
  padding: 10px 0;
  font-size: 0.9em;
}

/* 14. 내 오늘 기록 섹션 */
.my-today-section {
  background: #f0f8ff;
  padding: 16px;
  border-radius: 8px;
  border: 2px solid #4299e1;
  box-shadow: 0 2px 8px rgba(66, 153, 225, 0.1);
}

.my-today-section h4 {
  margin-bottom: 12px;
  color: #2b6cb0;
  font-size: 15px;
  font-weight: 600;
}

.my-record-card {
  background: white;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #bee3f8;
  margin-bottom: 8px;
}

.my-record-card .player-name {
  font-weight: 600;
  color: #2b6cb0;
  margin-bottom: 8px;
  font-size: 14px;
}

/* 15. 실시간 진행률 그래프 및 UI 스타일 */
.player-progress-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-bottom: 12px;
}

.player-progress-item .player-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 14px;
}

.player-progress-item .player-name {
  font-weight: bold;
  color: #2d3748;
  text-shadow: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.player-percentage {
  font-family: 'Courier New', Courier, monospace;
  font-weight: bold;
  color: #81c784;
}

/* 16. 진행률 바의 배경(틀) */
.progress-bar-wrapper {
  width: 100%;
  height: 12px;
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

/* 17. 실제 진행률을 표현하는 바 */
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #81c784);
  border-radius: 6px;
  transition: width 0.2s ease-in-out;
  box-shadow: 0 0 5px rgba(76, 175, 80, 0.6);
}

/* 18. 현재 플레이어 순위 강조 */
.final-rank-item.current-player {
  background: linear-gradient(135deg, #48bb78, #38a169);
  color: white;
  border: 2px solid #2f855a;
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
}

.final-rank-item.current-player strong {
  color: #fff3cd;
}

/* 19. 최신 성과의 표시 */
.final-rank-item.current-player div:first-child::after {
  content: " 🏆";
  animation: sparkle 2s infinite;
}

/* 20. 로딩 및 빈 데이터 표시 */
.no-data {
  text-align: center;
  color: #a0aec0;
  font-style: italic;
  padding: 20px;
  font-size: 13px;
}

.loading {
  text-align: center;
  color: #a0aec0;
  font-style: italic;
  padding: 10px;
  font-size: 13px;
}

/* 21. 마지막 업데이트 시각 */
.last-update {
  text-align: center;
  margin-top: 8px;
}

.last-update small {
  color: #718096;
  font-size: 11px;
}

/* 22. 사이드바 관련 애니메이션 */
@keyframes sparkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* 23. 스크롤바 커스터마이징 */
.left-sidebar::-webkit-scrollbar,
.right-sidebar::-webkit-scrollbar,
#players-list::-webkit-scrollbar,
.live-progress-container::-webkit-scrollbar,
#leaderboard-list::-webkit-scrollbar {
  width: 6px;
}

.left-sidebar::-webkit-scrollbar-track,
.right-sidebar::-webkit-scrollbar-track,
#players-list::-webkit-scrollbar-track,
.live-progress-container::-webkit-scrollbar-track,
#leaderboard-list::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.left-sidebar::-webkit-scrollbar-thumb,
.right-sidebar::-webkit-scrollbar-thumb,
#players-list::-webkit-scrollbar-thumb,
.live-progress-container::-webkit-scrollbar-thumb,
#leaderboard-list::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}

.left-sidebar::-webkit-scrollbar-thumb:hover,
.right-sidebar::-webkit-scrollbar-thumb:hover,
#players-list::-webkit-scrollbar-thumb:hover,
.live-progress-container::-webkit-scrollbar-thumb:hover,
#leaderboard-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* 24. 모바일 반응형 (사이드바) */
@media (max-width: 768px) {
  .left-sidebar {
    grid-column: 1;
    grid-row: 2; /* 헤더 다음 */
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
    max-height: 200px;
  }

  .right-sidebar {
    grid-column: 1;
    grid-row: 4; /* 메인 콘텐츠 다음 */
    border-left: none;
    border-top: 1px solid #e2e8f0;
    max-height: 250px;
    flex-direction: row;
    overflow-x: auto;
    gap: 15px;
  }

  .left-sidebar > div,
  .right-sidebar > div {
    min-width: 250px;
  }

  .live-progress-section {
    min-height: 150px;
  }

  .players-section,
  .room-limits,
  .leaderboard,
  .today-best-section,
  .top-rankings-section,
  .my-today-section {
    padding: 12px;
  }

  .player-item {
    padding: 8px;
    font-size: 12px;
  }

  .live-rank-item,
  .rank-item {
    padding: 6px 10px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .left-sidebar,
  .right-sidebar {
    padding: 12px;
    gap: 12px;
  }

  .left-sidebar > div,
  .right-sidebar > div {
    min-width: 200px;
  }

  .live-progress-section {
    min-height: 120px;
  }

  .player-progress-item .player-info {
    font-size: 12px;
  }

  .progress-bar-wrapper {
    height: 10px;
  }
}

/* 25. 다크모드 지원 (사이드바) */
@media (prefers-color-scheme: dark) {
  .left-sidebar,
  .right-sidebar {
    background: #2d3748;
    border-color: #4a5568;
  }

  .room-limits,
  .players-section,
  .leaderboard,
  .today-best-section,
  .top-rankings-section {
    background: #1a202c;
    border-color: #4a5568;
  }

  .room-limits h3,
  .players-section h3,
  .leaderboard h3,
  .today-best-section h4,
  .top-rankings-section h4 {
    color: #f7fafc;
  }

  .player-item {
    background: #4a5568;
    border-color: #718096;
    color: #f7fafc;
  }

  .player-item.playing {
    background: #2d4a3a;
    border-color: #48bb78;
  }

  .live-rank-item,
  .rank-item {
    background: #4a5568;
    border-color: #718096;
    color: #f7fafc;
  }

  .my-today-section {
    background: #2a4a5c;
    border-color: #4299e1;
  }

  .my-record-card {
    background: #1a202c;
    border-color: #4299e1;
  }

  .limit-label {
    color: #a0aec0;
  }

  .rank-player {
    color: #a0aec0;
  }
}

/* 26. 접근성 개선 */
@media (prefers-reduced-motion: reduce) {
  .live-rank-item,
  .player-progress-item,
  .progress-bar-fill {
    transition: none;
    animation: none;
  }

  .final-rank-item.current-player div:first-child::after {
    animation: none;
  }
}

/* 27. 포커스 상태 개선 */
.player-item:focus,
.live-rank-item:focus,
.rank-item:focus {
  outline: 2px solid #4299e1;
  outline-offset: 2px;
}
