/* ============================================================
   MODULE: AVATAR SELECTOR & EDIT — QuiniGold Club
   Estilos para el selector de avatares (Iniciales, Subida, Gravatar)
   Tokens Dark Glassmorphism, Oro Deportivo y Ergonomía Móvil (WCAG AA).
   ============================================================ */

/* ─── Trigger de Edición en Profile Sheet ──────────────────── */
.psheet-avatar-wrap {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.psheet-avatar {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.psheet-avatar:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 24px rgba(245, 158, 11, 0.45);
}

.psheet-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.psheet-avatar-edit-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-gold, #f59e0b);
  color: #0b0f19;
  border: 2px solid #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

/* ─── Modal Overlay ────────────────────────────────────────── */
.modal-avatar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 0.2s ease-out;
}

.avatar-card {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(165deg, rgba(20, 26, 43, 0.96) 0%, rgba(10, 14, 26, 0.98) 100%);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-xl, 20px);
  padding: var(--space-5) var(--space-6);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), 0 0 30px rgba(245, 158, 11, 0.15);
  position: relative;
}

.avatar-card-header {
  position: relative;
  text-align: center;
  margin-bottom: var(--space-4);
}

.avatar-badge-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--color-gold, #f59e0b);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 2px 10px;
  border-radius: 20px;
  margin-bottom: 6px;
}

.avatar-card-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  margin: 0;
}

.avatar-close-btn {
  position: absolute;
  top: -8px;
  right: -4px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 26px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color var(--transition-fast);
}
.avatar-close-btn:hover {
  color: #fff;
}

/* ─── Preview Circular Central ────────────────────────────── */
.avatar-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: var(--space-4);
}

.avatar-preview-ring {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  padding: 4px;
  background: linear-gradient(135deg, var(--color-gold, #f59e0b), var(--color-accent, #e63946));
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.35);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.avatar-preview-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #0f172a;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-initials-text {
  font-family: var(--font-body);
  font-size: 2.1rem;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

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

.avatar-rank-pill {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  background: #111827;
  border: 2px solid var(--color-gold, #f59e0b);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.avatar-preview-caption {
  font-size: 12px;
  color: var(--color-text-secondary, #94a3b8);
  margin-top: 8px;
  font-weight: 500;
}

/* ─── Segmented Control (Pills táctiles de 44px mín.) ─────── */
.avatar-segmented-control {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: var(--space-4);
}

@media (max-width: 480px) {
  .avatar-segmented-control {
    grid-template-columns: repeat(2, 1fr);
  }
}

.avatar-seg-btn {
  height: 44px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  touch-action: manipulation;
  transition: all var(--transition-fast);
}

.avatar-seg-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.avatar-seg-btn.active {
  background: rgba(245, 158, 11, 0.18);
  color: var(--color-gold, #f59e0b);
  border: 1px solid rgba(245, 158, 11, 0.45);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ─── Contenedor de Paneles ────────────────────────────────── */
.avatar-tab-content {
  min-height: 96px;
  margin-bottom: var(--space-4);
}

.avatar-panel {
  display: none;
  animation: fadeIn 0.2s ease;
}

.avatar-panel.active {
  display: block;
}

.avatar-hint-text {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.45;
  margin-bottom: 8px;
  text-align: center;
}

/* Panel 1: Paleta de Fondo para Iniciales */
.avatar-color-toggles {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  transform: scale(1.15);
}

.color-swatch[data-gradient="gold-dark"] {
  background: linear-gradient(135deg, #f59e0b, #b45309);
}
.color-swatch[data-gradient="crimson-dark"] {
  background: linear-gradient(135deg, #e63946, #800f2f);
}
.color-swatch[data-gradient="emerald-dark"] {
  background: linear-gradient(135deg, #10b981, #065f46);
}
.color-swatch[data-gradient="sapphire-dark"] {
  background: linear-gradient(135deg, #3b82f6, #1e3a8a);
}
.color-swatch[data-gradient="amethyst-dark"] {
  background: linear-gradient(135deg, #a855f7, #581c87);
}

/* Panel 2: Dropzone de Imagen */
.avatar-dropzone {
  border: 2px dashed rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.04);
  border-radius: 14px;
  padding: var(--space-4) var(--space-3);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.avatar-dropzone:hover, .avatar-dropzone:focus, .avatar-dropzone.dragover {
  border-color: var(--color-gold, #f59e0b);
  background: rgba(245, 158, 11, 0.1);
  transform: scale(1.01);
}

.dropzone-icon {
  font-size: 26px;
  display: block;
  margin-bottom: 4px;
}

.dropzone-text {
  font-size: 13px;
  color: #fff;
  margin-bottom: 2px;
}

.dropzone-sub {
  font-size: 11px;
  color: var(--color-text-muted);
  display: block;
}

/* Panel 3: Gravatar Box */
.gravatar-info-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.gravatar-email-line {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.gravatar-email-line strong {
  color: #fff;
  display: block;
  font-size: 13px;
  margin-top: 2px;
}

/* ─── Acciones Inferiores ──────────────────────────────────── */
.avatar-card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.avatar-save-btn {
  padding: 12px;
  font-weight: 800;
  font-size: 14px;
}

/* ─── Estilos Generales para Avatares con Imagen en Header y Ranking ── */
.profile-chip-avatar img,
.user-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* ─── Adaptabilidad Móvil (< 380px) ────────────────────────── */
@media (max-width: 380px) {
  .avatar-card {
    padding: var(--space-4);
  }
  .avatar-preview-ring {
    width: 80px;
    height: 80px;
  }
  .avatar-initials-text {
    font-size: 1.6rem;
  }
  .avatar-seg-btn {
    font-size: 11px;
    gap: 3px;
  }
}

/* ─── Marcos de Avatar y Estatus Social (Armería & Vestuario) ─── */
.avatar-frame-fuego {
  position: relative !important;
  border: 3px solid #f97316 !important;
  box-shadow: 
    0 0 10px #ff3b00,
    0 -5px 16px rgba(255, 69, 0, 0.85),
    0 -12px 24px rgba(249, 115, 22, 0.7),
    0 -20px 35px rgba(253, 224, 71, 0.5),
    inset 0 0 10px rgba(255, 69, 0, 0.6) !important;
  animation: flameFlicker 1.1s infinite alternate ease-in-out, flameTongues 2.2s infinite ease-in-out !important;
}

@keyframes flameFlicker {
  0% {
    border-color: #ff3b00;
    box-shadow: 
      0 0 8px #ff3b00,
      0 -4px 14px rgba(255, 69, 0, 0.8),
      0 -10px 22px rgba(249, 115, 22, 0.65),
      0 -18px 30px rgba(253, 224, 71, 0.45),
      inset 0 0 8px rgba(255, 69, 0, 0.5);
    filter: brightness(1) drop-shadow(0 -4px 8px rgba(255, 69, 0, 0.7));
  }
  50% {
    border-color: #f97316;
    box-shadow: 
      0 0 16px #ff6600,
      0 -8px 22px rgba(255, 80, 0, 0.95),
      0 -16px 32px rgba(249, 115, 22, 0.85),
      0 -26px 44px rgba(254, 240, 138, 0.65),
      inset 0 0 14px rgba(255, 100, 0, 0.75);
    filter: brightness(1.25) drop-shadow(0 -7px 14px rgba(249, 115, 22, 0.9));
  }
  100% {
    border-color: #fbbf24;
    box-shadow: 
      0 0 12px #ff4500,
      0 -6px 18px rgba(255, 69, 0, 0.85),
      0 -13px 26px rgba(249, 115, 22, 0.7),
      0 -22px 36px rgba(253, 224, 71, 0.5),
      inset 0 0 10px rgba(255, 69, 0, 0.6);
    filter: brightness(1.1) drop-shadow(0 -5px 10px rgba(255, 100, 0, 0.8));
  }
}

@keyframes flameTongues {
  0%, 100% {
    border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%;
  }
  25% {
    border-radius: 47% 53% 48% 52% / 44% 47% 53% 56%;
  }
  50% {
    border-radius: 53% 47% 52% 48% / 56% 53% 47% 44%;
  }
  75% {
    border-radius: 48% 52% 53% 47% / 52% 45% 55% 48%;
  }
}

.avatar-frame-dorado {
  border: 2.5px solid #f59e0b !important;
  box-shadow: 0 0 10px #f59e0b, 0 0 20px rgba(234, 179, 8, 0.7), inset 0 0 8px rgba(245, 158, 11, 0.4) !important;
  animation: goldPulse 2s infinite alternate ease-in-out;
}
@keyframes goldPulse {
  0% {
    box-shadow: 0 0 8px #f59e0b, 0 0 16px rgba(234, 179, 8, 0.5);
    border-color: #f59e0b;
  }
  100% {
    box-shadow: 0 0 16px #fbbf24, 0 0 30px rgba(245, 158, 11, 0.9), 0 0 40px rgba(253, 224, 71, 0.6);
    border-color: #fef08a;
  }
}

/* Chips de Cosméticos en Armería */
.cosmetico-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
}
.cosmetico-card:hover {
  background: rgba(245, 158, 11, 0.06);
  border-color: rgba(245, 158, 11, 0.3);
}
.cosmetico-card.equipped {
  background: rgba(245, 158, 11, 0.12);
  border-color: var(--color-gold, #f59e0b);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
}
.cosmetico-badge-equipped {
  background: var(--color-gold, #f59e0b);
  color: #0b0f19;
  font-weight: 800;
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 6px;
}
