/* ====================================================================
   PÁGINAS DE AUTENTICACIÓN (Login y Registro)
   Diseño moderno y centrado en UX
   ==================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables específicas para auth ──────────────────────────────── */
:root {
  --auth-gradient-start: #667eea;
  --auth-gradient-end: #764ba2;
  --auth-card-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* ── Base para páginas de autenticación ──────────────────────────── */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* Patrón de fondo decorativo */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

/* ── Tarjeta de autenticación ─────────────────────────────────────── */
.auth-card {
  background: white;
  padding: 2.5rem;
  border-radius: 1rem;
  box-shadow: var(--auth-card-shadow);
  width: 100%;
  max-width: 420px;
  position: relative;
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Encabezados ──────────────────────────────────────────────────── */
.auth-card h2 {
  text-align: center;
  color: #1f2937;
  margin: 0 0 0.5rem;
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.auth-subtitle {
  text-align: center;
  font-size: 0.9375rem;
  color: #6b7280;
  margin: 0 0 2rem;
  font-weight: 400;
}

/* ── Banner de acceso restringido ─────────────────────────────────── */
.restricted-banner {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: 0.5rem;
  padding: 0.875rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  color: #92400e;
  text-align: center;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.restricted-banner::before {
  content: "🔒";
  font-size: 1.25rem;
}

/* ── Formularios ──────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #374151;
  font-size: 0.9375rem;
}

.form-group label .req {
  color: #ef4444;
  margin-left: 0.25rem;
}

/* ── Inputs con wrapper para botón de ojo ────────────────────────── */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-family: inherit;
  color: #1f2937;
  transition: all 200ms ease;
  background: white;
}

.input-wrap input {
  padding-right: 2.75rem;
}

.form-group input::placeholder {
  color: #9ca3af;
}

.form-group input:focus {
  border-color: #667eea;
  outline: none;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input:disabled {
  background: #f3f4f6;
  cursor: not-allowed;
  opacity: 0.6;
}

/* ── Botón de mostrar/ocultar contraseña ─────────────────────────── */
.eye-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: all 200ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.eye-btn:hover {
  color: #374151;
  background: #f3f4f6;
}

.eye-btn:active {
  transform: translateY(-50%) scale(0.95);
}

/* ── Mensajes de error en campos ─────────────────────────────────── */
.field-error {
  color: #ef4444;
  font-size: 0.875rem;
  margin-top: 0.375rem;
  display: block;
  min-height: 1.25rem;
  font-weight: 500;
}

.form-group input.invalid {
  border-color: #ef4444;
  background: #fef2f2;
}

.form-group input.invalid:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* ── Barra de fuerza de contraseña ────────────────────────────────── */
.strength-bar-wrap {
  height: 4px;
  background: #e5e7eb;
  border-radius: 0.25rem;
  margin-top: 0.5rem;
  overflow: hidden;
}

.strength-bar {
  height: 100%;
  width: 0;
  border-radius: 0.25rem;
  transition: width 300ms ease, background 300ms ease;
}

.strength-label {
  font-size: 0.8125rem;
  color: #6b7280;
  margin-top: 0.375rem;
  display: block;
  font-weight: 500;
  transition: color 300ms ease;
}

/* ── Hints y textos de ayuda ──────────────────────────────────────── */
#username-hint {
  font-size: 0.8125rem;
  color: #6b7280;
  margin-top: 0.375rem;
  display: block;
}

/* ── Botón de submit ──────────────────────────────────────────────── */
.submit-btn {
  width: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 0.875rem 1rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: all 200ms ease;
  font-family: inherit;
  box-shadow: 0 4px 6px rgba(102, 126, 234, 0.2);
}

.submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(102, 126, 234, 0.3);
}

.submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ── Spinner de carga en botón ────────────────────────────────────── */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

/* ── Link de vuelta ───────────────────────────────────────────────── */
.back-link {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.9375rem;
  color: #6b7280;
}

.back-link a {
  color: #667eea;
  text-decoration: none;
  font-weight: 600;
  transition: color 200ms ease;
}

.back-link a:hover {
  color: #764ba2;
  text-decoration: underline;
}

/* ── Contenedor de mensajes (sobrescribe para auth) ───────────────── */
.message-container {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1050;
  width: 90%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

/* ── Responsive Design ────────────────────────────────────────────── */

@media (max-width: 640px) {
  body {
    padding: 0.75rem;
  }
  
  .auth-card {
    padding: 2rem 1.5rem;
    max-width: 100%;
  }
  
  .auth-card h2 {
    font-size: 1.625rem;
  }
  
  .auth-subtitle {
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
  }
  
  .restricted-banner {
    font-size: 0.8125rem;
    padding: 0.75rem 0.875rem;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 1.75rem 1.25rem;
  }
  
  .auth-card h2 {
    font-size: 1.5rem;
  }
  
  .form-group {
    margin-bottom: 1rem;
  }
  
  .form-group input {
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
  }
  
  .input-wrap input {
    padding-right: 2.5rem;
  }
  
  .submit-btn {
    padding: 0.75rem 0.875rem;
    font-size: 0.9375rem;
  }
}

/* ── Accesibilidad ────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .auth-card {
    animation: none;
  }
  
  .submit-btn:hover:not(:disabled) {
    transform: none;
  }
  
  .spinner {
    animation: none;
  }
}

@media (prefers-contrast: high) {
  .auth-card {
    border: 2px solid #1f2937;
  }
  
  .form-group input:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
  }
  
  .submit-btn {
    border: 2px solid #4f46e5;
  }
}

/* ── Dark mode support ────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(135deg, #4c1d95 0%, #6b21a8 100%);
  }
  
  .auth-card {
    background: #1f2937;
    color: #f9fafb;
  }
  
  .auth-card h2 {
    color: #f9fafb;
  }
  
  .form-group label {
    color: #e5e7eb;
  }
  
  .form-group input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }
  
  .form-group input::placeholder {
    color: #9ca3af;
  }
  
  .form-group input:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
  }
  
  .eye-btn {
    color: #9ca3af;
  }
  
  .eye-btn:hover {
    color: #e5e7eb;
    background: #4b5563;
  }
  
  .strength-bar-wrap {
    background: #374151;
  }
}