/* ═══════════════════════════════════════════════════════════════
   AUTH COMPONENTS - Componentes globales de autenticación

   Componentes reutilizables:
   - Avatar con iniciales (.user-avatar)
   - Dropdown menu de usuario (.user-dropdown-menu)
   - Animación de éxito con checkmark (.success-animation)

   Compatible con: Desktop + Mobile + Dark Mode
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   1. USER AVATAR (Círculo con iniciales)
   ═══════════════════════════════════════════════════════════════ */

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 2px solid transparent;
  user-select: none;
  position: relative;
}

.user-avatar-dropdown { 
  height: 40px; 
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 2px solid transparent;
  user-select: none;
  position: relative;
  border-radius: var(--radius-sm);
    /* 🔹 Truncar texto */
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.user-avatar-dropdown:hover {
  transform: scale(1.05);
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(17, 87, 238, 0.3);
}

.user-avatar:hover {
  transform: scale(1.05);
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(17, 87, 238, 0.3);
}

/* Variante pequeña para móvil */
.user-avatar-sm {
  width: 36px;
  height: 36px;
  font-size: 0.75rem;
}

/* Variante grande para perfil */
.user-avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 1.25rem;
}

/* Dark mode */
.dark_mode .user-avatar:hover {
  box-shadow: 0 4px 12px rgba(17, 87, 238, 0.5);
}

/* ═══════════════════════════════════════════════════════════════
   2. USER DROPDOWN MENU (Menú desplegable)
   ═══════════════════════════════════════════════════════════════ */

/* Contenedor del avatar + dropdown */
.user-menu-container {
  position: relative;
  display: inline-block;
  padding: 0.875rem 1.25rem;
}

/* Dropdown menu */
.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 220px;
  padding: 0.5rem 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  overflow: hidden;
}

/* Estado abierto */
.user-dropdown-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Flecha decorativa arriba */
.user-dropdown-menu::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 12px;
  width: 12px;
  height: 12px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
  transform: rotate(45deg);
}

/* Header del dropdown (info usuario) */
.user-dropdown-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
}

.user-dropdown-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.25rem 0;
}

.user-dropdown-email {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Links del menu */
.user-dropdown-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: var(--transition-fast);
  cursor: pointer;
}

.user-dropdown-link:hover {
  background: var(--bg-secondary);
  color: var(--primary-color);
}

.user-dropdown-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Separador */
.user-dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.5rem 0;
}

/* Link de cerrar sesión (destacado) */
.user-dropdown-link.logout {
  color: #dc2626;
  margin-top: 0.25rem;
}

.user-dropdown-link.logout:hover {
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
}

/* Dark mode */
.dark_mode .user-dropdown-menu::before {
  background: var(--bg-primary);
}

/* ═══════════════════════════════════════════════════════════════
   3. SUCCESS ANIMATION (Animación de check con círculo)
   ═══════════════════════════════════════════════════════════════ */

.success-animation-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
}

/* Círculo del checkmark */
.success-checkmark {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
  margin-bottom: 1.5rem;
  animation: checkmarkScale 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-checkmark svg {
  width: 48px;
  height: 48px;
  stroke: white;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  animation: checkmarkDraw 0.5s ease 0.2s forwards;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

/* Texto de éxito */
.success-message {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
  animation: fadeInUp 0.5s ease 0.3s backwards;
}

.success-submessage {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin: 0;
  animation: fadeInUp 0.5s ease 0.4s backwards;
}

/* Animaciones */
@keyframes checkmarkScale {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes checkmarkDraw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════════════════════════
   4. LOADING STATE (Estado de carga para avatar)
   ═══════════════════════════════════════════════════════════════ */

.user-avatar.loading {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--border-color) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ═══════════════════════════════════════════════════════════════
   5. RESPONSIVE (Mobile adaptations)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Avatar más pequeño en móvil */
  .user-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.75rem;
  }

  /* Dropdown ocupa más ancho en móvil */
  .user-dropdown-menu {
    min-width: 260px;
    right: -20px;
  }

  /* Ajustar flecha */
  .user-dropdown-menu::before {
    right: 30px;
  }

  /* Links más grandes para touch */
  .user-dropdown-link {
    padding: 1rem 1.25rem;
    font-size: 0.95rem;
  }

  /* Success animation más compacta */
  .success-checkmark {
    width: 64px;
    height: 64px;
  }

  .success-checkmark svg {
    width: 36px;
    height: 36px;
  }

  .success-message {
    font-size: 1.1rem;
  }
}

/* ═══════════════════════════════════════════════════════════════
   6. ACCESSIBILITY & STATES
   ═══════════════════════════════════════════════════════════════ */

/* Focus visible para teclado */
.user-avatar:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.user-dropdown-link:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
}

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
  .user-avatar,
  .user-dropdown-menu,
  .user-dropdown-link,
  .success-checkmark,
  .success-checkmark svg,
  .success-message,
  .success-submessage {
    animation: none !important;
    transition: none !important;
  }

  .user-dropdown-menu.active {
    transform: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   7. MOBILE NAV BAR DROPDOWN (Dropdown que abre hacia arriba)
   ═══════════════════════════════════════════════════════════════ */

/* Dropdown para mobile-nav-bar (barra inferior) - abre hacia ARRIBA */
.mobile-nav-dropdown {
  position: fixed; /* Fixed para evitar que se corte */
  bottom: 70px; /* Altura de la barra inferior (aprox 55px) + margen (15px) */
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  right: auto;
  top: auto;
  min-width: 280px;
  max-width: 90vw;
  z-index: 1001; /* Por encima de mobile-nav-bar (z-index: 1000) */
}

/* Flecha apunta hacia abajo (dropdown arriba) */
.mobile-nav-dropdown::before {
  top: auto;
  bottom: -6px;
  right: 50%;
  transform: translateX(50%) rotate(225deg);
  border-left: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
}

/* Estado abierto - se mueve hacia arriba */
.mobile-nav-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Avatar pequeño para mobile nav bar */
.user-avatar-small {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  margin: 0 auto 0.25rem;
}

/* ═══════════════════════════════════════════════════════════════
   8. UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════ */

/* Ocultar elementos (útil para cambiar entre estados) */
.auth-hidden {
  display: none !important;
}

/* Mostrar solo en desktop */
@media (max-width: 768px) {
  .auth-desktop-only {
    display: none !important;
  }
}

/* Mostrar solo en móvil */
@media (min-width: 769px) {
  .auth-mobile-only {
    display: none !important;
  }
}
