/* ═══════════════════════════════════════
   ShellGames Player Profile Styles
   ═══════════════════════════════════════ */

.profile-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
}

.profile-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  color: var(--text-muted);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

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

/* Error State */
.error-state {
  text-align: center;
  padding: 4rem 2rem;
}
.error-icon { font-size: 4rem; margin-bottom: 1rem; }
.error-state h2 { margin-bottom: 0.5rem; }
.error-state p { color: var(--text-muted); margin-bottom: 2rem; }

/* ─── Profile Header ─── */
.profile-header {
  display: flex;
  gap: 2rem;
  align-items: center;
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}

.profile-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--secondary), #a855f7);
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(233, 69, 96, 0.3);
}

.profile-info {
  flex: 1;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.profile-name-row h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.profile-type-badge {
  padding: 0.2rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-type-badge.human {
  background: rgba(0, 212, 170, 0.15);
  color: var(--secondary);
  border: 1px solid rgba(0, 212, 170, 0.3);
}

.challenge-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.35rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  background: linear-gradient(135deg, var(--accent), #c23152);
  color: white;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.challenge-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(233, 69, 96, 0.4);
  text-decoration: none;
  color: white;
}

.profile-type-badge.agent {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.profile-meta {
  display: flex;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.profile-uid {
  font-family: monospace;
  font-size: 0.8rem;
  opacity: 0.6;
}

.profile-elo-display {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 1.5rem;
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: var(--radius-sm);
}

.elo-number {
  font-size: 2rem;
  font-weight: 800;
  color: #FFD700;
  line-height: 1;
}

.elo-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ─── Stats Grid ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem 1rem;
  text-align: center;
  transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 0.25rem;
}

.stat-wins .stat-value { color: var(--secondary); }
.stat-losses .stat-value { color: var(--accent); }
.stat-streak .stat-value { color: #FFD700; }

/* ─── Win Rate Bar ─── */
.winrate-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.winrate-section h3 { margin-bottom: 1rem; font-size: 1rem; }

.winrate-bar {
  display: flex;
  height: 28px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg);
}

.winrate-wins {
  background: linear-gradient(90deg, #00d4aa, #2ecc71);
  transition: width 0.6s ease;
  min-width: 2px;
}

.winrate-draws {
  background: #6b6b8a;
  transition: width 0.6s ease;
}

.winrate-losses {
  background: linear-gradient(90deg, #e94560, #c23152);
  transition: width 0.6s ease;
  min-width: 2px;
}

.winrate-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

.winrate-label-wins { color: var(--secondary); }
.winrate-label-draws { color: var(--text-muted); }
.winrate-label-losses { color: var(--accent); }

/* ─── Achievements ─── */
.achievements-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h3 { font-size: 1rem; }

.achievement-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 0.2rem 0.75rem;
  border-radius: 12px;
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.achievement-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
  transition: transform 0.15s, box-shadow 0.15s;
}

.achievement-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.achievement-card.locked {
  background: rgba(42, 42, 74, 0.3);
  border-color: var(--border);
  opacity: 0.45;
}

.achievement-emoji {
  font-size: 1.75rem;
  flex-shrink: 0;
  width: 40px;
  text-align: center;
}

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

.achievement-name {
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.3;
}

.achievement-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.achievement-card.locked .achievement-emoji {
  filter: grayscale(1);
}

/* ─── Game Stats ─── */
.game-stats-section {
  margin-bottom: 1.5rem;
}

.game-stats-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.game-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.game-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  transition: border-color 0.2s;
}

.game-stat-card:hover {
  border-color: var(--accent);
}

.game-stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.game-stat-name {
  font-weight: 700;
  font-size: 1rem;
}

.game-stat-elo {
  font-weight: 800;
  color: #FFD700;
  font-size: 1.1rem;
}

.game-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 0.25rem 0;
  color: var(--text-muted);
}

.game-stat-row span:last-child {
  color: var(--text);
  font-weight: 600;
}

.game-stat-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg);
  margin-top: 0.5rem;
  overflow: hidden;
}

.game-stat-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--secondary), var(--accent));
  transition: width 0.6s ease;
}

/* ─── Match History ─── */
.history-section {
  margin-bottom: 2rem;
}

.history-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.history-item:hover { background: var(--bg-card-hover); }

.history-result {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.history-result.win {
  background: rgba(0, 212, 170, 0.15);
  color: var(--secondary);
  border: 2px solid rgba(0, 212, 170, 0.3);
}

.history-result.loss {
  background: rgba(233, 69, 96, 0.15);
  color: var(--accent);
  border: 2px solid rgba(233, 69, 96, 0.3);
}

.history-result.draw {
  background: rgba(107, 107, 138, 0.15);
  color: var(--text-muted);
  border: 2px solid rgba(107, 107, 138, 0.3);
}

.history-details {
  flex: 1;
  min-width: 0;
}

.history-opponent {
  font-weight: 600;
  font-size: 0.9rem;
}

.history-game-type {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.history-elo-change {
  font-weight: 700;
  font-size: 0.9rem;
  text-align: right;
  white-space: nowrap;
}

.history-elo-change.positive { color: var(--secondary); }
.history-elo-change.negative { color: var(--accent); }
.history-elo-change.neutral { color: var(--text-muted); }

.history-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

.history-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
  .profile-header {
    flex-direction: column;
    text-align: center;
  }
  
  .profile-meta { justify-content: center; flex-wrap: wrap; }
  .profile-name-row { justify-content: center; }
  .profile-elo-display { align-self: center; }
  
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }
  
  .stat-card { padding: 0.75rem 0.5rem; }
  .stat-value { font-size: 1.4rem; }
  
  .achievements-grid {
    grid-template-columns: 1fr;
  }
  
  .history-item { flex-wrap: wrap; }
}
