/**
 * Game Lobby Spectator Frontend Styles
 * Dark theme for "live stream" aesthetic
 */

/* CSS Variables */
:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #252525;
  --bg-hover: #2a2a2a;

  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-muted: #707070;

  --accent-blue: #3b82f6;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-yellow: #eab308;
  --accent-purple: #a855f7;

  --player-x: #3b82f6;
  --player-o: #ef4444;

  --border-color: #333333;
  --border-radius: 8px;

  --font-mono: 'SF Mono', 'Consolas', 'Monaco', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* App Container */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* Status Bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.status-left,
.status-center,
.status-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.game-name {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--accent-purple);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-yellow);
  animation: pulse 1.5s ease-in-out infinite;
}

.connection-status.connected .status-dot {
  background-color: var(--accent-green);
  animation: none;
}

.connection-status.disconnected .status-dot {
  background-color: var(--accent-red);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.room-status {
  font-size: 1rem;
  color: var(--text-secondary);
}

.spectator-count {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Main Content */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Game Area */
.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
}

/* Players Info */
.players-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  margin-bottom: 20px;
}

.player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius);
  border: 2px solid transparent;
  transition: border-color var(--transition-normal);
}

.player.active {
  border-color: var(--accent-yellow);
}

.player.winner {
  border-color: var(--accent-green);
}

.player-1 .player-symbol {
  color: var(--player-x);
  font-weight: bold;
  font-size: 1.2rem;
}

.player-2 .player-symbol {
  color: var(--player-o);
  font-weight: bold;
  font-size: 1.2rem;
}

.player-name {
  font-size: 1rem;
  color: var(--text-primary);
}

.player-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.player.connected .player-indicator {
  background-color: var(--accent-green);
}

.player.disconnected .player-indicator {
  background-color: var(--accent-red);
}

.vs {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--text-muted);
}

/* Game Board Container */
.game-board-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  min-height: 300px;
  position: relative;
}

.waiting-message {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1.2rem;
}

/* Game Board (Tic-Tac-Toe specific) */
.tic-tac-toe-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  width: min(400px, 80vw);
  height: min(400px, 80vw);
  background-color: var(--bg-tertiary);
  padding: 8px;
  border-radius: var(--border-radius);
}

.cell {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--bg-secondary);
  border-radius: 4px;
  font-size: 4rem;
  font-weight: bold;
  transition: all var(--transition-fast);
}

.cell.x {
  color: var(--player-x);
}

.cell.o {
  color: var(--player-o);
}

.cell.winning {
  background-color: var(--bg-hover);
  animation: winPulse 0.6s ease-in-out infinite alternate;
}

@keyframes winPulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

.cell.new-move {
  animation: placeMove 0.3s ease-out;
}

@keyframes placeMove {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* Game Result Overlay */
.game-result {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background-color: rgba(15, 15, 15, 0.9);
  z-index: 10;
}

.game-result:not([hidden]) {
  display: flex;
}

.result-content {
  text-align: center;
  padding: 30px;
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.result-title {
  font-size: 1.5rem;
  margin-bottom: 10px;
}

.result-message {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 15px;
}

.result-waiting {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Move History */
.move-history {
  margin-top: 20px;
  padding: 15px;
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius);
  max-height: 200px;
  overflow-y: auto;
}

.move-history h3 {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.history-list {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.history-item {
  padding: 4px 0;
  color: var(--text-secondary);
}

.history-item .move-number {
  color: var(--text-muted);
}

.history-item .player-x {
  color: var(--player-x);
}

.history-item .player-o {
  color: var(--player-o);
}

.history-empty {
  color: var(--text-muted);
  font-style: italic;
}

/* Comment Section */
.comment-section {
  width: 320px;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
}

.comment-section h3 {
  padding: 15px 20px;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.comment-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 15px;
}

.comment-empty {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.comment-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

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

.comment-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.75rem;
}

.comment-time {
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.comment-name {
  color: var(--accent-blue);
  font-weight: 500;
}

.comment-item.own .comment-name {
  color: var(--accent-green);
}

.comment-text {
  color: var(--text-primary);
  word-wrap: break-word;
}

.comment-input-area {
  display: flex;
  padding: 15px;
  gap: 10px;
  border-top: 1px solid var(--border-color);
}

.comment-input-area input {
  flex: 1;
  padding: 10px 12px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.comment-input-area input:focus {
  border-color: var(--accent-blue);
}

.comment-input-area input::placeholder {
  color: var(--text-muted);
}

.comment-input-area button {
  padding: 10px 16px;
  background-color: var(--accent-blue);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.comment-input-area button:hover {
  background-color: #2563eb;
}

.comment-input-area button:disabled {
  background-color: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 100;
}

.modal:not([hidden]) {
  display: flex;
}

.modal-content {
  padding: 30px 40px;
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius);
  text-align: center;
  border: 1px solid var(--border-color);
}

.modal-content h2 {
  margin-bottom: 10px;
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal-content input {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 1rem;
  text-align: center;
  outline: none;
}

.modal-content input:focus {
  border-color: var(--accent-blue);
}

.modal-content button {
  width: 100%;
  padding: 12px;
  background-color: var(--accent-blue);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.modal-content button:hover {
  background-color: #2563eb;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }

  .comment-section {
    width: 100%;
    max-height: 300px;
    border-left: none;
    border-top: 1px solid var(--border-color);
  }

  .players-info {
    gap: 15px;
  }

  .player {
    padding: 8px 12px;
  }

  .player-name {
    font-size: 0.875rem;
  }

  .cell {
    font-size: 2.5rem;
  }

  .move-history {
    max-height: 150px;
  }
}

@media (max-width: 480px) {
  .status-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
  }

  .status-left,
  .status-center,
  .status-right {
    flex-basis: 100%;
    justify-content: center;
  }

  .players-info {
    flex-direction: column;
    gap: 10px;
  }

  .vs {
    display: none;
  }
}

/* Match History */
.match-history {
  margin-top: 10px;
  padding: 10px 15px;
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  max-height: 200px;
  overflow-y: auto;
}

.match-history h3 {
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.match-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  background-color: var(--bg-primary);
  font-size: 13px;
}

.match-item .match-time {
  color: var(--text-secondary);
  font-size: 11px;
  min-width: 60px;
}

.match-item .match-players {
  flex: 1;
  margin: 0 8px;
}

.match-item .match-result {
  font-weight: bold;
  min-width: 80px;
  text-align: right;
}

.match-item .match-result.win {
  color: #4ade80;
}

.match-item .match-result.draw {
  color: #fbbf24;
}
