/* =========================================================
   SHC · Página de perfil (/perfil)
   Se carga después de styles.css. Reutiliza encabezado, botones
   y tarjetas, y ajusta los colores a la paleta:
   #1D1D1F texto · #D77655 acento · #F3D4CA secundario
   #FCF2EE fondo · #FFFFFF tarjetas
   ========================================================= */

:root {
  --background: #FCF2EE;
  --foreground: #1D1D1F;
  --card: #FFFFFF;
  --primary: #D77655;
  --primary-hover: #D77655;
  --primary-foreground: #1D1D1F;
  --muted-foreground: #1D1D1F;
  --border: #F3D4CA;
  --surface-alt: #F3D4CA;
  --shadow-soft: 0 1px 2px rgba(29, 29, 31, .08);
}

.page-perfil { font-family: "Poppins", sans-serif; }

/* ---------- Encabezado: mismos elementos, colores de la paleta ---------- */
.page-perfil .site-header {
  background: var(--background);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.page-perfil .main-nav a:hover,
.page-perfil .logout-link:hover { color: var(--foreground); text-decoration: underline; }
.page-perfil .logout-link { color: var(--foreground); }
.page-perfil .logout-link[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.3em; }
.page-perfil .btn-outline:hover { background: var(--surface-alt); color: var(--foreground); }
.page-perfil .btn-primary:hover { text-decoration: underline; }

/* Foco visible en todo: contorno #1D1D1F */
.page-perfil :focus-visible { outline: 2px solid var(--foreground); outline-offset: 2px; }

/* Texto pequeño mínimo 14px también en móvil */
@media (max-width: 479px) {
  .page-perfil .header-actions .btn-outline { padding: 0.375rem 0.875rem; font-size: 0.875rem; }
  .page-perfil .logout-link { font-size: 0.875rem; }
}

/* ---------- Contenedor de la página ---------- */
.perfil { padding-top: 2rem; }
.perfil-wrap { max-width: 40rem; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.back-link svg { width: 1.25rem; height: 1.25rem; }
.perfil h1 { margin-top: 1rem; }

/* ---------- Carga ---------- */
.perfil-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  font-size: 1rem;
}
.perfil-loading[hidden] { display: none; }
.spinner { width: 1.5rem; height: 1.5rem; animation: perfil-spin 0.9s linear infinite; }
@keyframes perfil-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.perfil-content { margin-top: 2rem; display: grid; gap: 1.5rem; }
.perfil-content[hidden] { display: none; }

/* ---------- Tarjetas ---------- */
.perfil-card h2 { font-size: 24px; font-weight: 600; }

/* ---------- Foto ---------- */
.avatar-row { display: flex; align-items: center; gap: 1.25rem; margin-top: 1.25rem; flex-wrap: wrap; }
.avatar {
  position: relative;
  flex: none;
  width: 6rem;
  height: 6rem;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--surface-alt);
  border: 1px solid var(--foreground);
  font-size: 1.75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar img[hidden] { display: none; }
.avatar-actions { display: flex; flex-direction: column; align-items: flex-start; }
.avatar-actions .btn-outline { cursor: pointer; }
.avatar-actions .btn-outline:disabled { cursor: wait; }

.upload-progress { margin-top: 1.25rem; }
.upload-progress[hidden] { display: none; }
.progress-track {
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--surface-alt);
  border: 1px solid var(--foreground);
  overflow: hidden;
}
.progress-fill { height: 100%; width: 0; background: var(--foreground); transition: width .15s; }

/* ---------- Campos ---------- */
.field { display: flex; flex-direction: column; margin-top: 1.25rem; }
.field label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 1rem;
  font-weight: 600;
}
.field .lock { width: 1rem; height: 1rem; }
.field input {
  margin-top: 0.375rem;
  padding: 0.75rem 0.875rem;
  font: inherit;
  font-size: 1rem;
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--foreground);
  border-radius: var(--radius);
}
.field input:focus-visible { outline-offset: 1px; }
.field input[aria-invalid="true"] { border-width: 2px; }

/* Solo lectura: fondo secundario, borde punteado y candado */
.field input[readonly] {
  background: var(--surface-alt);
  border-style: dashed;
  cursor: default;
}

.help { margin-top: 0.375rem; font-size: 0.875rem; }

/* ---------- Mensajes (siempre ícono + texto) ---------- */
.field-error,
.status-msg {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}
.field-error[hidden],
.status-msg[hidden] { display: none; }
.status-msg { margin-top: 1.25rem; font-size: 1rem; }
.msg-icon { flex: none; width: 1.25rem; height: 1.25rem; }

/* ---------- Botones ---------- */
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; margin-top: 1.5rem; }
.form-actions .btn-primary,
.perfil-logout .btn-outline,
.confirm-modal .btn-outline { border: 0; font-family: inherit; cursor: pointer; }
.perfil-logout .btn-outline,
.confirm-modal .btn-outline { border: 1px solid var(--foreground); padding: 0.875rem 1.75rem; }
.form-actions .btn-primary:disabled {
  background: var(--surface-alt);
  box-shadow: none;
  text-decoration: none;
  cursor: not-allowed;
}
.form-actions .btn-primary[aria-busy="true"] { cursor: wait; }

.text-btn {
  background: none;
  border: 0;
  padding: 0.5rem 0;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--foreground);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.text-btn:disabled { text-decoration: none; cursor: not-allowed; }

.perfil-logout { padding-bottom: 1rem; }

/* ---------- Confirmación ---------- */
.confirm-modal {
  margin: auto;
  width: calc(100% - 2rem);
  max-width: 28rem;
  padding: 1.75rem;
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: var(--shadow-soft);
}
.confirm-modal::backdrop { background: rgba(29, 29, 31, .45); }
.confirm-modal h2 { font-size: 24px; font-weight: 600; }
.confirm-modal p { margin-top: 0.75rem; font-size: 1rem; }

@media (min-width: 768px) {
  .perfil { padding-top: 3rem; }
}
