/* Variables CSS – VirtualGift */
:root {
  /* Acentos */
  --primary: #8d17fb;        /* morado principal */
  --secondary: #70189b;      /* morado profundo (hover/fin de gradiente) */

  /* Fondos */
  --bg-primary: #020515;     /* fondo app */
  --bg-secondary: #06011c;   /* degradado de fondo */
  --bg-card: #1c1f2f;        /* tarjetas / contenedores */

  /* Texto */
  --text-primary: #dcefff;   /* texto principal */
  --text-secondary: #b6c6d9; /* texto secundario */
  --text-muted: #8ea2b8;     /* placeholders / ayudas */

  /* Bordes y líneas */
  --border: #293244;

  /* Estados */
  --error: #f43f5e;   /* puedes ajustar si quieres morado para error */
  --success: #28d27d; /* sugerido en guía */

  /* Espaciado y formas */
  --spacing: 15px;
  --border-radius: 12px;

  /* Sombras y brillos */
  --shadow-card: 0 6px 25px rgba(0,0,0,0.5);
  --glow-primary: 0 0 12px rgba(141,23,251,0.45), 0 0 20px rgba(112,24,155,0.35);
  --glow-hover: 0 0 20px rgba(141,23,251,0.6), 0 0 35px rgba(112,24,155,0.5);
}

/* Reset y Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', 'Roboto', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  background: linear-gradient(180deg, var(--bg-primary), var(--bg-secondary)) !important;
  background-attachment: fixed;
  color: var(--text-primary);
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--spacing);
  overflow-x: hidden;
}

/* Container Principal */
.auth-container {
  width: 100%;
  max-width: 400px;
}

.auth-card {
  background: var(--bg-card) !important;
  border: 1px solid rgba(41, 50, 68, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 22px;
  padding: 30px 25px;
  text-align: center;
  box-shadow: var(--shadow-card);
  animation: fadeIn 0.6s ease;
}

/* Logo y Bienvenida */
.logo img {
  width: 70px;
  margin-bottom: var(--spacing);
}

.welcome {
  font-size: 1.3em;
  font-weight: 500;
  margin-bottom: 18px;
}

.welcome span {
  color: var(--primary);
}

/* Formularios */
.form { 
  display: none; 
  text-align: left; 
}
.form.active { 
  display: block; 
}

label {
  font-size: 0.85em;
  margin: 10px 0 5px;
  display: block;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Inputs */
input {
  width: 100%;
  padding: 10px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border) !important;
  background: rgba(16, 7, 21, 0.95) !important; /* #100715 con opacidad */
  color: var(--text-primary);
  margin-bottom: 10px;
  outline: none !important;
  transition: border 0.2s ease, box-shadow 0.2s ease;
  font-size: 16px;
  min-height: 44px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  box-shadow: none !important;
}

/* Remover estilos nativos de validación */
input:invalid,
input:valid,
input:required,
input:optional {
  box-shadow: none !important;
  border: 1px solid var(--border) !important;
  outline: none !important;
}

/* Focus accesible personalizado (morado) */
input:focus,
input:focus-visible,
input:focus-within {
  border: 2px solid var(--primary) !important;
  box-shadow: var(--glow-primary) !important;
  outline: none !important;
}

/* Mientras escribe */
input:not(:placeholder-shown) {
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}

input:not(:placeholder-shown):focus {
  border: 2px solid var(--primary) !important;
  box-shadow: var(--glow-primary) !important;
}

/* Autofill */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px rgba(16, 7, 21, 0.95) inset !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
  outline: none !important;
}
input:-webkit-autofill:focus {
  border: 2px solid var(--primary) !important;
  box-shadow: var(--glow-primary) !important;
}

/* Outline global limpio */
input, button, *:focus {
  outline: none !important;
}

/* Tipos de input */
input[type="email"],
input[type="password"],
input[type="text"] {
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
  outline: none !important;
}
input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  border: 2px solid var(--primary) !important;
  box-shadow: var(--glow-primary) !important;
}

input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

/* Botones */
.btn {
  width: 100%;
  padding: 15px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  margin: 10px 0;
  transition: all 0.2s ease;
  font-size: 0.95em;
  touch-action: manipulation;
  user-select: none;
  min-height: 50px;
}

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

.btn.gradient {
  background: linear-gradient(90deg, var(--primary), var(--secondary)) !important;
  color: var(--text-primary);
  box-shadow: var(--glow-primary);
}

.btn.gradient:hover {
  transform: scale(1.02);
  box-shadow: var(--glow-hover);
}

.btn.social {
  background: rgba(28, 31, 47, 0.9) !important; /* #1c1f2f con opacidad */
  border: 1px solid var(--border);
  color: #e7f0ff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn.social:hover { 
  background: rgba(28, 31, 47, 1) !important; 
}

.social-icon { 
  width: 20px; 
  height: 20px; 
  flex-shrink: 0;
}

/* Spinner loading para Discord */
.btn-loading {
  position: relative;
  color: transparent !important;
}
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-right-color: transparent;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Links */
.forgot {
  display: block;
  text-align: right;
  font-size: 0.8em;
  margin-bottom: var(--spacing);
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
  padding: 8px 0;
}
.forgot:hover { 
  color: var(--primary); 
}

.switch-form { 
  text-align: center; 
  font-size: 0.85em; 
  margin-top: 8px; 
  color: var(--text-secondary); 
}
.switch-form a { 
  color: var(--primary); 
  font-weight: 600; 
  text-decoration: none; 
  transition: color 0.2s ease; 
  padding: 8px 4px;
}
.switch-form a:hover { 
  color: var(--secondary); 
}

/* Divider */
.divider {
  text-align: center;
  margin: 20px 0;
  position: relative;
}
.divider span {
  background: var(--bg-card);
  padding: 0 10px;
  color: var(--text-muted);
  font-size: 0.8em;
}
.divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--border);
  z-index: -1;
}

/* Errores y Password */
.error-msg {
  color: var(--error);
  font-size: 0.75em;
  margin-bottom: 6px;
  display: block;
  min-height: 1em;
}

.password-strength {
  width: 100%;
  height: 5px;
  background: var(--border);
  border-radius: 4px;
  margin-bottom: 10px;
  overflow: hidden;
}

#password-strength-bar {
  height: 100%;
  width: 0;
  border-radius: 4px;
  transition: all 0.3s ease;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

/* Términos - Interruptor (Toggle Switch) */
.terms {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.85em;
  margin: var(--spacing) 0;
  cursor: pointer;
  text-align: center;
  padding: 8px;
  flex-wrap: wrap;
}

/* Ocultar el checkbox original */
.terms input[type="checkbox"] { display: none; }

/* Toggle */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 26px;
  min-width: 52px;
  flex-shrink: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border);
  transition: all 0.35s ease;
  border-radius: 26px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.4);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px; width: 20px;
  left: 3px; bottom: 3px;
  background: #fff;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Estado activo */
input:checked + .toggle-slider {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  box-shadow: var(--glow-primary);
}
input:checked + .toggle-slider:before {
  transform: translateX(26px);
  background: #fff;
  box-shadow: 0 0 10px rgba(255,255,255,0.8);
}

/* Hover del toggle */
.toggle-switch:hover .toggle-slider { filter: brightness(1.1); }

/* Footer */
footer { 
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(220,239,255,0.1);
  font-size: 0.7em; 
  color: var(--text-muted);
  width: 100%;
}
footer p {
  text-align: center;
  margin: 0 0 1rem 0;
  font-size: 0.875rem;
  color: rgba(220,239,255,0.6);
  margin-bottom: 8px;
}
.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 8px;
  flex-wrap: wrap;
  width: 100%;
}
.footer-links a { 
  color: rgba(220,239,255,0.8);
  text-decoration: none; 
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  transition: all 0.3s ease;
  position: relative;
  white-space: nowrap;
  text-align: center;
}
.footer-links a:hover,
.footer-links a:focus { 
  color: #fff; 
  background-color: rgba(141,23,251,0.12);
  transform: translateY(-1px);
}
.footer-links a:active {
  transform: translateY(0);
  background-color: rgba(141,23,251,0.18);
}
/* Separador visual entre enlaces */
.footer-links a:not(:last-child)::after {
  content: '•';
  position: absolute;
  right: -0.5rem;
  color: rgba(220,239,255,0.4);
  font-weight: bold;
}

/* Notificación */
.notification {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 10px;
  display: none;
  font-size: 0.85em;
  z-index: 100;
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  max-width: 90%;
}
.notification.show { 
  display: block; 
  animation: slideUp 0.3s ease; 
}
.notification.error { background: var(--error); }
.notification.success { background: var(--success); }
.notification.info { background-color: #1e293b; }

/* Recovery */
.recovery-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 50;
  cursor: pointer;
}
.recovery-overlay.active,
.recovery-overlay.show { 
  display: block; 
  animation: fadeIn 0.3s ease; 
}

.recovery-container {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 20px;
  background: var(--bg-card) !important;
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  border-radius: 22px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  text-align: center;
  z-index: 60;
  width: 90%;
  max-width: 350px;
}
.recovery-container.active,
.recovery-container.show { display: block; }
.recovery-container h3 { 
  margin-bottom: 10px; 
  color: var(--text-primary); 
  font-size: 1.2em; 
}
.recovery-container p { 
  margin-bottom: var(--spacing); 
  color: var(--text-muted); 
  font-size: 0.85em; 
  line-height: 1.4; 
}

.recovery-buttons {
  display: flex;
  gap: 10px;
  margin-top: 1rem;
  flex-direction: column;
}
.recovery-buttons .btn { flex: 1; }

/* Animaciones */
@keyframes fadeIn { 
  from { opacity: 0; transform: translateY(15px); } 
  to   { opacity: 1; transform: translateY(0); } 
}
@keyframes slideUp { 
  from { opacity: 0; transform: translateX(-50%) translateY(20px); } 
  to   { opacity: 1; transform: translateX(-50%) translateY(0); } 
}

/* Responsive */
@media (max-width: 768px) {
  html, body { background-attachment: scroll !important; }
  
  body {
    padding: 15px;
    align-items: flex-start;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  
  .auth-card { 
    padding: 25px 20px;
    background: var(--bg-card) !important;
    border: 1px solid var(--border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    backdrop-filter: none;
  }

  .logo img { width: 60px; }
  .welcome { font-size: 1.2em; margin-bottom: 15px; }
  
  .terms {
    justify-content: flex-start;
    text-align: left;
    padding: 10px 0;
  }
  .footer-links { gap: 0.75rem; }
}

@media (max-width: 480px) {
  body { 
    padding: 10px;
    padding-top: max(15px, env(safe-area-inset-top));
    padding-bottom: max(15px, env(safe-area-inset-bottom));
  }
  
  .auth-card {
    padding: 20px 15px;
    border-radius: 18px;
  }
  
  .logo img { width: 55px; }
  .welcome { font-size: 1.1em; margin-bottom: 12px; }
  
  .footer-links {
    gap: 0.5rem;
    justify-content: center;
    flex-direction: row;
    text-align: center;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
  }
  
  .footer-links a {
    font-size: 0.8rem;
    padding: 0.5rem 0.5rem;
    min-width: auto;
    text-align: center;
    flex: 0 0 auto;
  }
  
  .terms {
    justify-content: flex-start;
    text-align: left;
    padding: 10px 0;
  }
  
  .btn { padding: 14px; font-size: 0.95rem; }
  input { padding: 10px; }
  .divider { margin: 15px 0; }
  footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
  }
  footer p {
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
  }
}

@media (max-width: 350px) {
  body { padding: 8px; }
  .auth-card { padding: 15px 12px; border-radius: 15px; }
  .logo img { width: 50px; }
  .welcome { font-size: 1em; margin-bottom: 10px; }
  .btn { padding: 12px; font-size: 0.9rem; }
  input { padding: 8px; }
  
  .footer-links {
    font-size: 0.65em;
    gap: 5px;
    justify-content: center;
  }
  .footer-links a { font-size: 0.7em; padding: 6px 3px; }
  .terms { font-size: 0.8em; padding: 8px 0; }
}

/* Landscape móvil */
@media screen and (max-width: 768px) and (orientation: landscape) {
  body { align-items: flex-start; padding: 10px; }
  .auth-card { padding: 15px; }
  .logo img { width: 45px; margin-bottom: 8px; }
  .welcome { font-size: 1em; margin-bottom: 8px; }
  .btn { padding: 10px; margin: 5px 0; }
  input { padding: 8px; margin-bottom: 8px; }
  .divider { margin: 10px 0; }
}

/* Accesibilidad */
@media (prefers-reduced-motion: reduce) {
  * { 
    animation-duration: 0.01ms !important; 
    transition-duration: 0.01ms !important; 
  }
}

*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (pointer: coarse) {
  .footer-links a, .forgot, .switch-form a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}
