/* ─── Perfil page ─────────────────────────────────────────────────────────── */

.pf-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 32px 24px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* ── Sección genérica ───────────────────────────────────────────────────── */
.pf-section {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.pf-section-title {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}

/* ── Tarjeta hero ───────────────────────────────────────────────────────── */
.pf-card {
  width: 100%;
  max-width: 680px;
  border: 2px solid #252B5C;
  border-radius: 22px;
  background: #12173A;
  padding: 28px 28px 22px;
  position: relative; /* para el botón editar en esquina */
}

.pf-hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Botón editar — esquina superior derecha de la tarjeta */
.pf-edit-btn {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid #252B5C;
  background: #1B2150;
  color: #8A91BD;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  flex-shrink: 0;
}
.pf-edit-btn:hover {
  border-color: #5B3DF5;
  color: #B4A5FF;
}

/* Fila avatar + identidad */
.pf-hero-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Avatar */
.pf-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5B3DF5 0%, #22D3A6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  font-weight: 900;
  border: 3px solid #252B5C;
  user-select: none;
  flex-shrink: 0;
  overflow: hidden;
}

/* Formulario de edición */
.pf-edit-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pf-edit-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pf-edit-label {
  font-size: 12px;
  font-weight: 800;
  color: #8A91BD;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.pf-edit-handle-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pf-edit-at {
  position: absolute;
  left: 14px;
  font-size: 15px;
  font-weight: 900;
  color: #8A91BD;
  pointer-events: none;
  user-select: none;
}
.pf-edit-handle-wrap .pf-edit-input {
  padding-left: 28px;
}
.pf-edit-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid #5B3DF5;
  background: #0B0F2B;
  color: #fff;
  font: 800 15px Nunito, sans-serif;
  outline: none;
  box-sizing: border-box;
}
.pf-edit-input:focus {
  border-color: #22D3A6;
}
.pf-edit-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.pf-edit-save {
  padding: 10px 20px;
  border: 0;
  border-radius: 12px;
  background: #5B3DF5;
  color: #fff;
  font: 900 14px Nunito, sans-serif;
  letter-spacing: .6px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 3px 0 #3B22B8;
}
.pf-edit-save:active { transform: translateY(2px); box-shadow: none; }
.pf-edit-cancel {
  padding: 10px 16px;
  border: 2px solid #252B5C;
  border-radius: 12px;
  background: transparent;
  color: #8A91BD;
  font: 800 13px Nunito, sans-serif;
  cursor: pointer;
}
.pf-edit-cancel:hover { border-color: #5B3DF5; color: #B4A5FF; }

/* Identidad */
.pf-identity { display: flex; flex-direction: column; gap: 4px; }
.pf-name {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.1;
}
.pf-username {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #8A91BD;
}
.pf-since {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #5A628F;
}

/* Tags de temas completados */
.pf-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pf-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 30px;
  border: 2px solid #252B5C;
  background: #1B2150;
  font-size: 13px;
  font-weight: 800;
  color: #B4A5FF;
  letter-spacing: .4px;
}
.pf-tag.done { border-color: #22D3A6; color: #22D3A6; background: rgba(34,211,166,.08); }

/* ── Grid de estadísticas ───────────────────────────────────────────────── */
.pf-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.pf-stat {
  border: 2px solid #252B5C;
  border-radius: 18px;
  background: #12173A;
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.pf-stat-icon {
  font-size: 28px;
  flex: none;
  line-height: 1;
}
.pf-stat-body { display: flex; flex-direction: column; gap: 2px; }
.pf-stat-val {
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
}
.pf-stat-label {
  font-size: 13px;
  font-weight: 700;
  color: #8A91BD;
}

/* Colores por tipo de stat */
.pf-stat[data-type="streak"]  .pf-stat-val { color: #FF9040; }
.pf-stat[data-type="xp"]      .pf-stat-val { color: #F5C542; }
.pf-stat[data-type="lessons"] .pf-stat-val { color: #22D3A6; }
.pf-stat[data-type="top3"]    .pf-stat-val { color: #B4A5FF; }

/* ── Barra de progreso por unidad ───────────────────────────────────────── */
.pf-unit-row {
  border: 2px solid #252B5C;
  border-radius: 18px;
  background: #12173A;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pf-unit-row.done-unit { border-color: #22D3A6; }
.pf-unit-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pf-unit-name {
  font-size: 16px;
  font-weight: 900;
}
.pf-unit-pct {
  font-size: 14px;
  font-weight: 900;
  color: #22D3A6;
  flex: none;
}
.pf-bar {
  height: 16px;
  border-radius: 8px;
  background: #252B5C;
  overflow: hidden;
}
.pf-bar-fill {
  height: 100%;
  border-radius: 8px;
  background: #22D3A6;
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
.pf-unit-row.done-unit .pf-bar-fill { background: #22D3A6; }

/* ── Actividad reciente (7 días) ────────────────────────────────────────── */
.pf-activity {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: flex-end;
}
.pf-day {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.pf-day-bar-wrap {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: flex-end;
  background: #12173A;
  border: 2px solid #252B5C;
  border-radius: 10px;
  overflow: hidden;
}
.pf-day-bar {
  width: 100%;
  background: #5B3DF5;
  border-radius: 8px 8px 0 0;
  transition: height .4s;
  min-height: 0;
}
.pf-day-bar.today { background: #22D3A6; }
.pf-day-label {
  font-size: 11px;
  font-weight: 800;
  color: #8A91BD;
  letter-spacing: .4px;
  text-transform: uppercase;
}

/* Texto vacío */
.pf-empty {
  font-size: 15px;
  font-weight: 700;
  color: #5A628F;
  margin: 0;
  text-align: center;
  padding: 12px 0;
}

/* ── Panel derecho: insignias ───────────────────────────────────────────── */
.pf-badge-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.pf-badge-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid #252B5C;
  background: #0B0F2B;
}
.pf-badge-item.earned {
  border-color: #5B3DF5;
  background: #1B2150;
}
.pf-badge-icon {
  font-size: 26px;
  flex: none;
  opacity: .35;
}
.pf-badge-item.earned .pf-badge-icon { opacity: 1; }
.pf-badge-text { font-size: 14px; font-weight: 800; color: #5A628F; }
.pf-badge-item.earned .pf-badge-text { color: #B4A5FF; }
.pf-badge-sub { font-size: 12px; font-weight: 700; color: #8A91BD; }

/* ── División ────────────────────────────────────────────────────────────── */
.pf-division {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 14px;
  background: #0B0F2B;
  border: 2px solid #252B5C;
}
.pf-division-icon { font-size: 36px; flex: none; }
.pf-division-name { font-size: 18px; font-weight: 900; color: #B4A5FF; }
.pf-division-sub  { font-size: 13px; font-weight: 700; color: #8A91BD; margin-top: 2px; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1000px) { .right { display: none; } }

@media (max-width: 700px) {
  .pf-main {
    padding: 80px 14px calc(64px + env(safe-area-inset-bottom,0px) + 24px);
    gap: 18px;
  }
  .pf-card { padding: 20px 18px 18px; }
  .pf-edit-btn { top: 14px; right: 14px; }
  .pf-name { font-size: 24px; }
  .pf-avatar { width: 78px; height: 78px; font-size: 32px; }
  .pf-hero-row { gap: 14px; }
  .pf-stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pf-stat-val { font-size: 22px; }
  .pf-section-title { font-size: 20px; }
}

@media (max-width: 420px) {
  .pf-stats-grid { grid-template-columns: 1fr; }
  .pf-activity { gap: 5px; }
  .pf-day-label { font-size: 10px; }
}
