/* profile.css — Pantalla de Perfil del Jugador */

.screen-profile {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  background: var(--color-bg);
  padding-bottom: calc(var(--bnav-height, 60px) + 1rem);
}

/* ── Header ── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.profile-back-btn {
  background: none;
  border: none;
  color: var(--color-accent);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}
.profile-back-btn:hover { background: var(--color-surface-2); }

.profile-header-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

/* ── Body ── */
.profile-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

/* ── Profile Card ── */
.profile-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6A1B9A, #C2185B);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

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

.profile-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 0.15rem;
}

.profile-tipo {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.profile-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.profile-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  background: var(--color-surface-2);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.profile-badge--nivel {
  background: rgba(0,229,255,0.1);
  color: var(--color-accent);
  border-color: rgba(0,229,255,0.3);
}

.profile-desc {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* ── Two-col grid ── */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 480px) {
  .profile-grid { grid-template-columns: 1fr; }
}

/* ── Info Card shared ── */
.profile-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1rem;
}

.profile-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  margin: 0 0 0.25rem;
}

.profile-section-desc {
  font-size: 0.7rem;
  color: var(--color-text-muted, rgba(255,255,255,0.4));
  margin: 0 0 0.75rem;
}

/* ── Radar Chart ── */
.radar-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

#bfi-radar {
  width: 100%;
  max-width: 320px;
  height: auto;
  overflow: visible;
}

/* ── Radar Tooltip ── */
.radar-tip {
  position: absolute;
  display: none;
  background: rgba(18, 18, 30, 0.95);
  border: 1px solid rgba(0, 229, 255, 0.35);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  pointer-events: none;
  z-index: 20;
  min-width: 130px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.radar-tip-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.15rem;
}

.radar-tip-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1.1;
  margin-bottom: 0.2rem;
}

.radar-tip-val span {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.55;
  margin-left: 1px;
}

.radar-tip-desc {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.3;
}

/* ── BFI Legend ── */
.bfi-legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.bfi-legend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  gap: 0.5rem;
}

.bfi-legend-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
}

.bfi-legend-label {
  color: var(--color-text-secondary);
  font-weight: 500;
}

.bfi-legend-sublabel {
  font-size: 0.65rem;
  color: var(--color-text-muted, rgba(255,255,255,0.35));
}

.bfi-legend-value {
  font-weight: 600;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bfi-legend-value small {
  font-weight: 400;
  opacity: 0.6;
  font-size: 0.6rem;
}

/* ── Game Stats ── */
.stat-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.stat-label { color: var(--color-text-secondary); }
.stat-value {
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.stat-value--win  { color: #4CAF50; }
.stat-value--loss { color: #F44336; }
.stat-value--draw { color: var(--color-text-secondary); }

.winrate-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--color-surface-2);
  overflow: hidden;
  margin-bottom: 0.5rem;
  display: flex;
}
.winrate-bar-win  { background: #4CAF50; }
.winrate-bar-draw { background: #9E9E9E; }
.winrate-bar-loss { background: #F44336; }

.stat-total {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.75rem;
  line-height: 1;
}
.stat-total small {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-text-secondary);
  margin-left: 0.25rem;
}

/* ── Aperturas Card ── */
.apertura-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.apertura-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  background: var(--color-surface-2);
}

.apertura-icon {
  font-size: 1rem;
  width: 1.5rem;
  text-align: center;
}

.apertura-info { flex: 1; min-width: 0; }
.apertura-tipo {
  font-size: 0.7rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.1rem;
}
.apertura-nombre {
  color: var(--color-text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Empty / Loading states ── */
.profile-loading,
.profile-error {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.profile-no-calibration {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.85rem;
  line-height: 1.6;
}
.profile-no-calibration strong {
  display: block;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

/* ── Post-Game Stats Panel ── */
.postgame-card { padding: 0.75rem; }

#postgame-stats:empty { display: none; }

.pgs-header {
  text-align: center;
  margin-bottom: 0.5rem;
}
.pgs-result {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.pgs-precision {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 0.75rem;
}
.pgs-precision-val {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
}
.pgs-precision-lbl {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.15rem;
}
.pgs-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.pgs-cell {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.pgs-val {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
}
.pgs-val--elo  { color: var(--color-cyan); }
.pgs-val--cp   { color: #FFD700; }
.pgs-lbl {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.15rem;
  text-align: center;
}
.pgs-row--moves {
  flex-wrap: wrap;
  gap: 0.35rem;
}
.pgs-move-type {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.pgs-blunder    { background: rgba(229,57,53,0.20); color: #ef5350; }
.pgs-mistake    { background: rgba(255,87,34,0.20); color: #ff7043; }
.pgs-inaccuracy { background: rgba(255,235,59,0.20); color: #ffd740; }
.pgs-perfect    { background: rgba(0,229,255,0.12); color: var(--color-cyan); }
.pgs-moves-count {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  text-align: center;
  margin: 0.25rem 0 0.6rem;
}

/* ── Phase accuracy row ── */
.pgs-phase-row {
  display: flex;
  gap: 0.25rem;
  margin: 0.3rem 0;
}
.pgs-phase-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm, 4px);
  padding: 0.3rem 0.2rem;
}
.pgs-phase-val {
  font-size: 1rem;
  font-weight: 700;
  color: #FFD700;
  font-family: var(--font-mono);
}
.pgs-phase-lbl {
  font-size: 0.6rem;
  color: var(--color-text-muted);
  margin-top: 0.1rem;
  text-align: center;
}

/* ── Extra stats (streak, worst move) ── */
.pgs-extra-stat {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  text-align: center;
  margin: 0.15rem 0;
}
.pgs-extra-stat b {
  color: var(--color-text-primary);
}

/* ── Postgame interactive eval chart ── */
#postgame-eval-chart-wrap {
  margin: 0.5rem 0 0.25rem;
}
.pgec-svg {
  width: 100%;
  height: auto;
  display: block;
  cursor: crosshair;
}
.pgec-pt {
  cursor: pointer;
  transition: r 0.1s;
}
.pgec-pt:hover { r: 4; }

/* ── Move detail tooltip (click feedback) ── */
.pgs-eval-detail {
  font-size: 0.68rem;
  color: var(--color-cyan, #00E5FF);
  text-align: center;
  min-height: 1.2em;
  margin: 0.1rem 0 0.4rem;
  font-family: var(--font-mono);
}

/* ── Eval Chart in Game ── */
.eval-chart-card { margin-top: 0; }

.eval-chart-wrap {
  width: 100%;
  height: 52px;
  position: relative;
}

#eval-chart {
  width: 100%;
  height: 52px;
  display: block;
}

/* ── Historial de Partidas ── */
.hist-count {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  margin-left: 0.4rem;
  vertical-align: middle;
}

.hist-empty {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-align: center;
  padding: 1rem 0;
}

.hist-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.hist-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  border-radius: var(--radius-sm, 4px);
  transition: background 0.15s;
  user-select: none;
}
.hist-row:hover,
.hist-row:focus-visible {
  background: rgba(255,255,255,0.04);
  outline: none;
}

.hist-result-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  min-width: 4.5rem;
  text-align: center;
}
.hist-win  { background: rgba(0,200,83,0.18);  color: #00c853; }
.hist-draw { background: rgba(255,215,0,0.15); color: #ffd740; }
.hist-loss { background: rgba(229,57,53,0.18); color: #ef5350; }

.hist-piece {
  font-size: 1rem;
  flex-shrink: 0;
}

.hist-rival {
  font-size: 0.75rem;
  color: var(--color-text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-precision {
  font-size: 0.7rem;
  color: #00E5FF;
  font-family: var(--font-mono, monospace);
  flex-shrink: 0;
}

.hist-fecha {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.hist-expand-icon {
  font-size: 0.6rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: transform 0.2s;
}

/* ── Historial PGN Viewer ── */
.hist-viewer {
  display: none;
  background: rgba(0,0,0,0.25);
  border-radius: var(--radius-md, 6px);
  margin-bottom: 0.25rem;
  overflow: hidden;
}

.hist-viewer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem;
  gap: 0.6rem;
}

.hist-board-wrap {
  width: 100%;
  max-width: 240px;
}

.hist-board {
  width: 100% !important;
}

/* Reuse board.css fixes for hist-board squares */
#hist-board-wrap .square-55d63,
[id^="hist-board-"] .square-55d63 {
  float: left !important;
  position: relative !important;
  overflow: hidden !important;
  padding: 0 !important;
  width: 12.5% !important;
  height: auto !important;
  aspect-ratio: 1 !important;
}
[id^="hist-board-"] .board-b72b1 {
  width: 100% !important;
  height: auto !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
  border-radius: 4px;
  overflow: hidden;
}
[id^="hist-board-"] img.piece-417db {
  position: absolute !important;
  width: 100% !important;
  height: 100% !important;
  top: 0 !important;
  left: 0 !important;
}
[id^="hist-board-"] .clearfix-7da63 { clear: both !important; }
[id^="hist-board-"] .white-1e1d7 { background-color: #f0d9b5 !important; }
[id^="hist-board-"] .black-3c85d { background-color: #b58863 !important; }

.hist-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hist-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--color-text-primary);
  border-radius: var(--radius-sm, 4px);
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  font-size: 0.75rem;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.hist-btn:hover { background: rgba(0,229,255,0.15); }
.hist-btn:active { background: rgba(0,229,255,0.25); }

.hist-move-label {
  font-size: 0.7rem;
  color: var(--color-cyan, #00E5FF);
  font-family: var(--font-mono, monospace);
  min-width: 8rem;
  text-align: center;
}

.hist-no-pgn {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-align: center;
  padding: 0.75rem;
}
