/* Perfis de aprendiz: tela "Quem vai treinar hoje?", formulário do aprendiz e botão de troca no menu. */
.profile-avatar {
  --profile-color: #94a3b8;
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--profile-color);
  color: #ffffff;
  font-weight: 900;
  font-size: 1.2rem;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.55);
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar.is-small {
  width: 34px;
  height: 34px;
  font-size: 1rem;
}

/* Tela de escolha: cobre o app inteiro, com o mesmo céu da tela inicial (casas). */
.profile-picker {
  --bubble: clamp(112px, min(17vw, 21vh), 168px);
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  padding: clamp(16px, 4vw, 48px);
  background: linear-gradient(180deg, #29a8f3 0%, #35b2fa 22%, #4abffe 45%, #68cdfd 68%, #92dcfa 100%);
}

.profile-picker[hidden] {
  display: none;
}

/* Nuvens. */
.profile-picker::before,
.profile-picker::after {
  content: "";
  position: absolute;
  pointer-events: none;
  background:
    radial-gradient(closest-side, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 100%) 0 30px / 120px 70px no-repeat,
    radial-gradient(closest-side, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 100%) 60px 0 / 150px 100px no-repeat,
    radial-gradient(closest-side, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 100%) 150px 25px / 130px 80px no-repeat;
  width: 290px;
  height: 110px;
  opacity: 0.85;
}

.profile-picker::before {
  top: 9%;
  left: 6%;
}

.profile-picker::after {
  right: 5%;
  bottom: 14%;
  transform: scale(0.8);
  opacity: 0.7;
}

body.profile-picker-open {
  overflow: hidden;
}

.profile-picker-panel {
  position: relative;
  z-index: 1;
  width: min(1040px, 100%);
  display: grid;
  gap: clamp(20px, 4vh, 40px);
}

.profile-picker-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  text-align: center;
}

.profile-picker-header > div {
  grid-column: 1 / -1;
  grid-row: 1;
}

.profile-picker-header .icon-button {
  grid-column: 2;
  grid-row: 1;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 18px;
  background: #ffffff;
  color: #1d6fd6;
  font-size: 2rem;
  font-weight: 900;
  box-shadow: 0 6px 0 #b9dcf5, 0 12px 20px rgba(9, 54, 94, 0.25);
}

.profile-picker-header h1 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(2rem, 4.6vw, 3.2rem);
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  text-wrap: balance;
  text-shadow: 0 4px 6px rgba(5, 22, 38, 0.75);
}

.profile-picker-header p {
  margin: 12px 0 0;
  color: #ffffff;
  font-size: clamp(1.05rem, 2.1vw, 1.35rem);
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(5, 22, 38, 0.6);
}

.profile-picker-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(18px, 3vw, 36px) clamp(16px, 2.6vw, 34px);
}

/* Cada aprendiz é uma "bolha" redonda com nome embaixo. */
.profile-card {
  position: relative;
  width: calc(var(--bubble) + 20px);
}

.profile-card-open,
.profile-card-add {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.profile-card.profile-card-add {
  width: calc(var(--bubble) + 20px);
}

.profile-card-open strong,
.profile-card-add strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ffffff;
  font-size: clamp(1.15rem, 2.2vw, 1.5rem);
  font-weight: 950;
  line-height: 1.05;
  text-shadow: 0 3px 5px rgba(5, 22, 38, 0.85);
}

/* Nome composto: quebra em até duas linhas, centralizado. */
.profile-card-open strong,
.profile-card-add strong {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

.profile-card-open small {
  min-height: 1.6em;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #0f5c99;
  font-size: 0.95rem;
  font-weight: 900;
  box-shadow: 0 3px 8px rgba(9, 54, 94, 0.2);
}

.profile-card-add small {
  display: none;
}

.profile-card-open small:empty {
  visibility: hidden;
}

/* A bolha: cor do aprendiz com brilho, borda branca grossa e sombra de "objeto" como as casas. */
.profile-picker .profile-avatar.is-large,
.profile-form .profile-avatar.is-large {
  position: relative;
  width: var(--bubble, 128px);
  height: var(--bubble, 128px);
  border: 6px solid #ffffff;
  background: var(--profile-color);
  background: radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--profile-color) 45%, #ffffff) 0%, var(--profile-color) 52%, color-mix(in srgb, var(--profile-color) 72%, #000000) 100%);
  font-size: calc(var(--bubble, 128px) * 0.42);
  text-shadow: 0 4px 6px rgba(0, 0, 0, 0.28);
  box-shadow: 0 8px 0 rgba(9, 54, 94, 0.28), 0 18px 28px rgba(9, 54, 94, 0.32), inset 0 -10px 18px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}

/* Reflexo de luz no alto da bolha (também sobre a foto). */
.profile-picker .profile-avatar.is-large::after,
.profile-form .profile-avatar.is-large::after {
  content: "";
  position: absolute;
  top: 7%;
  left: 16%;
  width: 46%;
  height: 26%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0));
  transform: rotate(-18deg);
  pointer-events: none;
}

/* Sobre foto ou imagem de perfil o reflexo vira mancha: só nas bolhas com a inicial. */
.profile-avatar.is-large.has-image::after {
  display: none;
}

.profile-picker .profile-avatar.is-large img,
.profile-form .profile-avatar.is-large img {
  position: absolute;
  inset: 0;
}

.profile-card.is-current .profile-avatar.is-large {
  border-color: #fde047;
  box-shadow: 0 0 0 6px rgba(253, 224, 71, 0.55), 0 8px 0 rgba(9, 54, 94, 0.28), 0 18px 28px rgba(9, 54, 94, 0.32), inset 0 -10px 18px rgba(0, 0, 0, 0.18);
}

.profile-picker .profile-avatar.is-add {
  border: 6px dashed #ffffff;
  background: rgba(255, 255, 255, 0.28);
  color: #ffffff;
  font-size: calc(var(--bubble) * 0.5);
  box-shadow: 0 14px 24px rgba(9, 54, 94, 0.2);
}

.profile-picker .profile-avatar.is-add::after {
  display: none;
}

.profile-card-open:active .profile-avatar,
.profile-card-add:active .profile-avatar {
  transform: scale(0.94);
}

@media (hover: hover) and (pointer: fine) {
  .profile-card-open:hover .profile-avatar,
  .profile-card-add:hover .profile-avatar {
    transform: translateY(-6px) scale(1.03);
  }
}

/* Lápis de editar: botão redondo laranja na borda da bolha. */
.profile-card-edit {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffb547, #f97316);
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 900;
  box-shadow: 0 4px 0 #c2550c, 0 8px 14px rgba(9, 54, 94, 0.3);
  cursor: pointer;
}

.profile-picker-count {
  justify-self: center;
  margin: 0;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #0f5c99;
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(9, 54, 94, 0.18);
}

/* Formulário do aprendiz. */
.profile-form-modal {
  z-index: 100;
}

.profile-form {
  --bubble: 128px;
  width: min(620px, 100%);
  border-radius: 24px;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.profile-form-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(16px, 3vw, 28px);
  align-items: start;
  overflow-y: auto;
}

.profile-form-photo {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.profile-photo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #4abffe, #1d8fe0);
  color: #ffffff;
  font-weight: 900;
  box-shadow: 0 4px 0 #14659f;
  cursor: pointer;
}

.profile-form-fields {
  display: grid;
  gap: 14px;
}

.profile-form-fields label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-weight: 900;
}

.profile-form-fields input {
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

/* Gênero e imagem provisória. */
.profile-form-gender,
.profile-form-avatars {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.profile-form-gender legend,
.profile-form-avatars legend {
  padding: 0;
  margin-bottom: 6px;
  color: var(--ink);
  font-weight: 900;
}

.profile-form-avatars legend small {
  color: #64748b;
  font-weight: 700;
}

.profile-form-avatars[hidden] {
  display: none;
}

.profile-gender-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.profile-gender-option {
  min-height: 46px;
  border: 2px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.profile-gender-option[aria-pressed="true"] {
  border-color: #1d8fe0;
  background: linear-gradient(180deg, #4abffe, #1d8fe0);
  color: #ffffff;
  box-shadow: 0 4px 0 #14659f;
}

.profile-avatar-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.profile-avatar-choice {
  width: 64px;
  height: 64px;
  padding: 0;
  overflow: hidden;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #e2e8f0;
  box-shadow: 0 0 0 2px #cbd5e1;
  cursor: pointer;
  touch-action: manipulation;
}

.profile-avatar-choice img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-avatar-choice.is-selected {
  box-shadow: 0 0 0 4px #1d8fe0;
}

.profile-form-error {
  margin: 0;
  color: #b91c1c;
  font-weight: 800;
}

.profile-form-error[hidden] {
  display: none;
}

.profile-form-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.profile-form-actions .primary-button {
  margin-left: auto;
  min-width: 140px;
}

@media (max-width: 560px) {
  .profile-form-body {
    grid-template-columns: 1fr;
  }
}

/* Botão de troca de aprendiz no menu de configurações. */
.profile-switch-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 5px 14px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

/* Na tela cheia do treino o nome do aprendiz não aparece (a tela é só da criança). */
body.training-fullscreen .profile-switch-button {
  display: none;
}

.profile-switch-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.profile-switch-text {
  display: grid;
  text-align: left;
  line-height: 1.1;
}

.profile-switch-text small {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.profile-switch-text strong {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}
