/**
 * AUTH MODAL SYSTEM
 * Sistema modular de autenticación para redes sociales
 * 
 * @author MrGreen Development Team
 * @version 2.0.0
 * @since 2025-01-08
 */

/* ===== VARIABLES CSS ===== */
:root {
  /* Colores principales de la marca */
  --primary-gradient: linear-gradient(135deg, #ff0050 0%, #ff5b2e 100%);
  --primary-gradient-hover: linear-gradient(135deg, #ff5b2e 0%, #ff0050 100%);
  --secondary-gradient: linear-gradient(120deg, #232526 0%, #414345 100%);
  
  /* Colores de texto */
  --text-primary: #ffffff;
  --text-secondary: #aaaaaa;
  --text-muted: #666666;
  
  /* Sombras */
  --shadow-soft: 0 2px 12px rgba(255,0,80,0.13);
  --shadow-medium: 0 4px 24px rgba(255,0,80,0.18);
  --shadow-strong: 0 8px 48px rgba(31,38,135,0.37);
  
  /* Transiciones */
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  
  /* Z-indexes */
  --z-auth-button: 12001;
  --z-auth-modal: 13000;
}

/* ===== BOTÓN DE LOGIN FLOTANTE ===== */
.auth-login-btn {
  position: fixed;
  top: 32px;
  right: 32px;
  z-index: var(--z-auth-button);
  background: var(--primary-gradient);
  color: var(--text-primary);
  border: none;
  border-radius: 32px;
  padding: 0 32px;
  height: 48px;
  display: flex;
  align-items: center;
  font-size: 1.15rem;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
  letter-spacing: 0.5px;
  animation: authButtonPopIn 0.2s ease-out;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Botón flotante oculto por defecto (se usa el header universal) */
.auth-login-btn--floating {
  display: none !important;
}

.auth-login-btn:hover {
  background: var(--primary-gradient-hover);
  box-shadow: var(--shadow-medium);
  transform: scale(1.04);
}

.auth-login-btn:active {
  transform: scale(0.98);
}

.auth-login-btn__icon {
  font-size: 1.5rem;
  margin-right: 12px;
  animation: authIconBounce 1.2s infinite alternate;
}

/* ===== OVERLAY DEL MODAL ===== */
.auth-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  z-index: var(--z-auth-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-smooth), visibility var(--transition-smooth);
}

.auth-modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* ===== MODAL PRINCIPAL ===== */
.auth-modal {
  background: #ffffff;
  color: #1a1a1a;
  border-radius: 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 8px 32px rgba(0, 0, 0, 0.1);
  padding: 2.5rem 2rem 2rem 2rem;
  max-width: 400px;
  width: 95vw;
  position: relative;
  animation: authModalPopIn 0.2s var(--transition-bounce);
  border: 1px solid rgba(0, 0, 0, 0.05);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== BOTÓN DE CIERRE ===== */
.auth-modal__close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  background: none;
  border: none;
  color: #6b7280;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.7;
  transition: all var(--transition-fast);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.auth-modal__close-btn:hover {
  opacity: 1;
  background: none;
  color: #374151;
}

/* ===== TÍTULO DEL MODAL ===== */
.auth-modal__title {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 2rem;
  letter-spacing: -0.025em;
  color: #111827;
  line-height: 1.2;
}

/* ===== OPCIONES DE LOGIN ===== */
.auth-modal__options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.auth-modal__option-btn {
  background: #ffffff;
  color: #374151;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.875rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.auth-modal__option-btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.auth-modal__option-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.auth-modal__option-btn:disabled {
  background: #f3f4f6;
  color: #9ca3af;
  border-color: #e5e7eb;
  cursor: not-allowed;
  opacity: 0.6;
}

.auth-modal__option-btn__icon {
  font-size: 1.1rem;
  min-width: 20px;
  color: #6b7280;
}

.auth-modal__option-btn__text {
  flex: 1;
  text-align: left;
  color: #374151;
}

.auth-modal__option-btn__badge {
  font-size: 0.8rem;
  color: #9ca3af;
  font-weight: 400;
  font-style: italic;
}

/* Iconos específicos para redes sociales */
.auth-modal__option-btn .fa-envelope {
  color: #6b7280;
}

.auth-modal__option-btn .fa-qrcode {
  color: #9ca3af;
}

.auth-modal__option-btn .fab.fa-facebook-f {
  color: #1877f2;
}

.auth-modal__option-btn .fab.fa-google {
  color: #ea4335;
}

/* ===== DIVISOR ===== */
.auth-modal__divider {
  text-align: center;
  color: #6b7280;
  margin: 1.5rem 0 1rem 0;
  font-size: 0.9rem;
  position: relative;
}

.auth-modal__divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #e5e7eb;
  z-index: 1;
}

.auth-modal__divider span {
  background: #ffffff;
  padding: 0 1rem;
  position: relative;
  z-index: 2;
}

/* ===== FOOTER DEL MODAL ===== */
.auth-modal__footer {
  text-align: center;
  color: #6b7280;
  font-size: 0.9rem;
  margin-top: 1rem;
}

.auth-modal__footer-link {
  color: #ff0050;
  font-weight: 600;
  text-decoration: none;
  margin-left: 4px;
  transition: color var(--transition-fast);
}

.auth-modal__footer-link:hover {
  color: #e6004a;
  text-decoration: underline;
}

/* ===== ANIMACIONES ===== */
@keyframes authButtonPopIn {
  0% { 
    transform: scale(0.95); 
    opacity: 0.8; 
  }
  100% { 
    transform: scale(1); 
    opacity: 1; 
  }
}

@keyframes authIconBounce {
  0% { 
    transform: translateY(0); 
  }
  100% { 
    transform: translateY(-6px); 
  }
}

@keyframes authModalPopIn {
  0% { 
    transform: scale(0.95) translateY(10px); 
    opacity: 0; 
  }
  100% { 
    transform: scale(1) translateY(0); 
    opacity: 1; 
  }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 900px) {
  .auth-login-btn {
    top: 14px;
    right: 10px;
    height: 40px;
    font-size: 1rem;
    padding: 0 18px;
  }
  
  .auth-login-btn__icon {
    font-size: 1.2rem;
    margin-right: 7px;
  }
  
  .auth-modal {
    margin: 20px;
    padding: 2rem 1.5rem 1.5rem 1.5rem;
    max-width: 380px;
  }
  
  .auth-modal__title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
  }
  
  .auth-modal__option-btn {
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .auth-modal {
    margin: 16px;
    padding: 1.5rem 1.25rem 1.25rem 1.25rem;
    border-radius: 1rem;
    max-width: calc(100vw - 32px);
  }
  
  .auth-modal__title {
    font-size: 1.375rem;
    margin-bottom: 1.25rem;
  }
  
  .auth-modal__option-btn {
    padding: 0.75rem 0.875rem;
    font-size: 0.875rem;
  }
  
  .auth-modal__close-btn {
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    font-size: 1.25rem;
  }
}

/* ===== ESTADOS DE CARGA ===== */
.auth-modal__option-btn.loading {
  opacity: 0.7;
  cursor: not-allowed;
  pointer-events: none;
}

.auth-modal__option-btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

@keyframes spin {
  0% { transform: translateY(-50%) rotate(0deg); }
  100% { transform: translateY(-50%) rotate(360deg); }
}

/* ===== ACCESIBILIDAD ===== */
@media (prefers-reduced-motion: reduce) {
  .auth-login-btn,
  .auth-modal,
  .auth-modal-overlay,
  .auth-modal__option-btn {
    animation: none;
    transition: none;
  }
}

/* Focus visible para accesibilidad */
.auth-login-btn:focus-visible,
.auth-modal__close-btn:focus-visible,
.auth-modal__option-btn:focus-visible {
  outline: 2px solid #ff0050;
  outline-offset: 2px;
}

/* ===== MODO OSCURO ADICIONAL ===== */
@media (prefers-color-scheme: dark) {
  .auth-modal {
    border-color: rgba(255, 255, 255, 0.15);
  }
  
  .auth-modal__option-btn {
    border-color: rgba(255, 255, 255, 0.15);
  }
}

/* ===== FORZAR DISEÑO CLARO EN MODO OSCURO ===== */
.dark-mode .auth-modal-overlay {
  background: rgba(0, 0, 0, 0.6) !important;
  backdrop-filter: blur(12px) !important;
}

.dark-mode .auth-modal {
  background: #ffffff !important;
  color: #1a1a1a !important;
  border-color: rgba(0, 0, 0, 0.05) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 8px 32px rgba(0, 0, 0, 0.1) !important;
}

.dark-mode .auth-modal__title {
  color: #111827 !important;
}

.dark-mode .auth-modal__option-btn {
  background: #ffffff !important;
  color: #374151 !important;
  border-color: #e5e7eb !important;
}

.dark-mode .auth-modal__option-btn:hover {
  background: #f9fafb !important;
  border-color: #d1d5db !important;
}

.dark-mode .auth-modal__option-btn__text {
  color: #374151 !important;
}

.dark-mode .auth-modal__option-btn__icon {
  color: #6b7280 !important;
}

.dark-mode .auth-modal__divider {
  color: #6b7280 !important;
}

.dark-mode .auth-modal__divider::before {
  background: #e5e7eb !important;
}

.dark-mode .auth-modal__divider span {
  background: #ffffff !important;
}

.dark-mode .auth-modal__footer {
  color: #6b7280 !important;
}

.dark-mode .auth-modal__footer-link {
  color: #ff0050 !important;
}

.dark-mode .auth-modal__footer-link:hover {
  color: #e6004a !important;
}

.dark-mode .auth-modal__close-btn {
  color: #6b7280 !important;
}

.dark-mode .auth-modal__close-btn:hover {
  background: none !important;
  color: #374151 !important;
}
