/**
 * Local System Styles
 * ====================
 * Styles for authentication popups, leaderboards, and notifications
 */

/* === AUTH POPUP === */
.auth-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-popup {
  background: linear-gradient(135deg, #0f1128 0%, #1a1d3b 100%);
  border: 2px solid #6f86ff;
  border-radius: 16px;
  padding: 32px;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-popup h2 {
  margin: 0 0 8px 0;
  color: #ffd700;
  font-size: 1.8rem;
  text-align: center;
}

.auth-popup > p {
  color: #cfd4ff;
  text-align: center;
  margin: 0 0 24px 0;
  font-size: 0.95rem;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 2px solid rgba(111, 134, 255, 0.3);
}

.auth-tab {
  flex: 1;
  padding: 12px;
  background: transparent;
  color: #cfd4ff;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.auth-tab:hover {
  color: #fff;
  background: rgba(111, 134, 255, 0.1);
}

.auth-tab.active {
  color: #ffd700;
  border-bottom-color: #ffd700;
}

.auth-content {
  min-height: 180px;
}

.auth-tab-content {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.auth-tab-content.active {
  display: block;
}

.auth-popup input[type="text"] {
  width: 100%;
  padding: 14px;
  border: 2px solid #6f86ff;
  border-radius: 8px;
  background: rgba(15, 17, 40, 0.8);
  color: #fff;
  font-size: 1rem;
  margin-bottom: 12px;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

.auth-popup input[type="text"]:focus {
  outline: none;
  border-color: #ffd700;
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.2);
}

.auth-error {
  color: #ff6b9d;
  font-size: 0.9rem;
  margin: 8px 0;
  min-height: 20px;
}

.auth-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 8px;
}

.auth-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(111, 134, 255, 0.4);
}

.auth-btn-secondary {
  background: #2b2f5a;
  margin-top: 12px;
}

.auth-btn-secondary:hover {
  background: #3a4070;
}

.auth-token-display {
  text-align: center;
  animation: fadeIn 0.3s ease-out;
}

.auth-token-display h3 {
  color: #4caf50;
  margin: 0 0 12px 0;
  font-size: 1.5rem;
}

.auth-token-display p {
  color: #cfd4ff;
  margin: 0 0 16px 0;
}

.token-box {
  background: rgba(15, 17, 40, 0.8);
  border: 2px dashed #6f86ff;
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  word-break: break-all;
  color: #ffd700;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* === LEADERBOARD WIDGET === */
.leaderboard-section {
  margin: 32px 0;
  display: flex;
  justify-content: center;
  align-self: stretch;
}

/* Leaderboard in right sidebar (floating on desktop, centered on mobile) */
@media (min-width: 1200px) {
  /* On large screens, use flex container around main game area */
  body {
    --leaderboard-width: 300px;
  }
  
  .game-content-wrapper {
    display: flex;
    gap: 32px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  
  .leaderboard-section {
    width: 320px;
    min-width: 300px;
    max-width: 340px;
    margin: 0;
    flex-shrink: 0;
    position: sticky;
    top: 90px;
  }
}

@media (max-width: 1199px) {
  .leaderboard-section {
    margin: 32px auto;
    max-width: 500px;
    width: 90%;
  }
}

.leaderboard-widget {
  background: linear-gradient(135deg, #16213e 0%, #0f1128 100%);
  border: 2px solid #6f86ff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.leaderboard-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 12px 16px;
  border-bottom: 2px solid #6f86ff;
}

.leaderboard-header h3 {
  margin: 0;
  color: #fff;
  font-size: 1.1rem;
  text-align: center;
}

.leaderboard-body {
  padding: 8px;
  overflow-y: auto;
  max-height: 400px;
}

.leaderboard-body::-webkit-scrollbar {
  width: 8px;
}

.leaderboard-body::-webkit-scrollbar-track {
  background: rgba(15, 17, 40, 0.5);
}

.leaderboard-body::-webkit-scrollbar-thumb {
  background: #6f86ff;
  border-radius: 4px;
}

.leaderboard-empty {
  text-align: center;
  padding: 32px 20px;
  color: #cfd4ff;
  font-style: italic;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-row {
  border-bottom: 1px solid rgba(111, 134, 255, 0.2);
  transition: all 0.3s ease;
}

.leaderboard-row:hover {
  background: rgba(111, 134, 255, 0.1);
}

.leaderboard-row.rank-1 {
  background: rgba(255, 215, 0, 0.1);
}

.leaderboard-row.rank-2 {
  background: rgba(192, 192, 192, 0.1);
}

.leaderboard-row.rank-3 {
  background: rgba(205, 127, 50, 0.1);
}

.leaderboard-row td {
  padding: 8px 6px;
  vertical-align: middle;
}

.leaderboard-rank {
  width: 40px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffd700;
}

.leaderboard-nickname {
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  text-align: right;
  color: #6f86ff;
  font-weight: 700;
  font-size: 1rem;
  padding-right: 8px;
}

.leaderboard-time {
  text-align: right;
  color: #cfd4ff;
  font-size: 0.85rem;
  opacity: 0.7;
}

/* === RANK NOTIFICATION === */
.rank-notification {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 20px 32px;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border: 2px solid #ffd700;
}

.rank-notification.show {
  top: 20px;
}

.rank-notification-content p {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

/* === RESPONSIVE === */
@media (max-width: 600px) {
  .auth-popup {
    padding: 24px;
    width: 95%;
  }

  .auth-popup h2 {
    font-size: 1.5rem;
  }

  .token-box {
    font-size: 0.75rem;
    padding: 12px;
  }

  .leaderboard-widget {
    margin: 0 -10px;
  }

  .leaderboard-header h3 {
    font-size: 1.1rem;
  }

  .leaderboard-row td {
    padding: 10px 6px;
  }

  .leaderboard-nickname {
    font-size: 0.9rem;
  }

  .leaderboard-score {
    font-size: 1rem;
  }

  .rank-notification {
    width: 90%;
    max-width: 350px;
  }

  .rank-notification-content p {
    font-size: 0.95rem;
  }
}
