/* ==========================================================================
   CSSI CLOUD - SISTEMA DE CONTROL DE COMPRAS, INVENTARIO, STOCK Y VENTAS
   Estilos Modernos para Pantalla de Autenticación (Fondo Dinámico + Formulario Centrado)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #0080B7;
  --primary-dark: #005F8A;
  --primary-light: #00A6EB;
  --accent: #00E5FF;
  --accent-glow: rgba(0, 229, 255, 0.35);
  
  --bg-gradient-start: #06111C;
  --bg-gradient-mid: #0B1F33;
  --bg-gradient-end: #003652;
  
  --surface-card: rgba(255, 255, 255, 0.94);
  --surface-card-subtle: #F8FAFC;
  --text-main: #1E293B;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  
  --border-color: #E2E8F0;
  --border-focus: #0080B7;
  
  --error-bg: #FEF2F2;
  --error-border: #FECACA;
  --error-text: #DC2626;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 25px 60px -12px rgba(0, 10, 25, 0.55), 0 0 35px rgba(0, 128, 183, 0.28);
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', 'Poppins', sans-serif;
  background-color: var(--bg-gradient-start);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
  padding: 1.5rem;
}

/* ==========================================================================
   FONDO DINÁMICO: GRADIENTES VIVOS + BLOBS FLOTANTES + CANVAS DE RED
   ========================================================================== */
.login-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 50%, var(--bg-gradient-end) 100%);
  overflow: hidden;
  z-index: 0;
}

/* Canvas interactivo de partículas en red */
#bgCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Blobs de luz ambiental flotantes y animados */
.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
}

.glow-1 {
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, rgba(0, 128, 183, 0.55) 0%, rgba(0, 128, 183, 0) 70%);
  top: -15%;
  left: -10%;
  animation: floatOrb1 20s infinite alternate;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.45) 0%, rgba(0, 229, 255, 0) 70%);
  bottom: -15%;
  right: -10%;
  animation: floatOrb2 18s infinite alternate;
}

.glow-3 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.4) 0%, rgba(14, 165, 233, 0) 70%);
  top: 40%;
  right: 25%;
  animation: floatOrb3 24s infinite alternate;
}

@keyframes floatOrb1 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(120px, 80px) scale(1.15); }
  100% { transform: translate(60px, 160px) scale(0.95); }
}

@keyframes floatOrb2 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-100px, -70px) scale(1.18); }
  100% { transform: translate(-160px, -40px) scale(0.92); }
}

@keyframes floatOrb3 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-80px, 60px) scale(1.1); }
  100% { transform: translate(90px, -50px) scale(0.9); }
}

/* Patrón técnico de cuadrícula fina */
.grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: 1;
  pointer-events: none;
}

/* ==========================================================================
   CONTENEDOR Y TARJETA DEL FORMULARIO
   ========================================================================== */
.login-wrapper {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 470px;
  margin: auto;
  display: flex;
  justify-content: center;
}

/* Tarjeta con efecto Glassmorphism refinado */
.login-card {
  width: 100%;
  background: var(--surface-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  padding: 3rem 2.5rem 2.5rem;
  box-shadow: var(--shadow-xl);
  border: 1px solid rgba(255, 255, 255, 0.7);
  position: relative;
  overflow: hidden;
  animation: fadeInDown 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Barra superior decorativa */
.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 50%, #005F8A 100%);
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Encabezado del Formulario */
.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.brand-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.brand-logo-wrap img {
  height: 52px;
  max-width: 240px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.08));
}

.auth-header h2 {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
  margin-bottom: 0.4rem;
}

/* Etiqueta identificadora del sistema */
.system-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: #EBF7FC;
  border: 1px solid #BAE6FD;
  color: #0369A1;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 50px;
  margin-top: 0.3rem;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 6px rgba(0, 128, 183, 0.08);
}

.system-tag i {
  color: var(--primary);
  font-size: 0.75rem;
}

/* Banner de error dinámico */
.alert-error {
  background-color: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.alert-error i {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.alert-error span {
  flex-grow: 1;
  line-height: 1.35;
}

.alert-close {
  background: none;
  border: none;
  color: var(--error-text);
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.7;
  transition: opacity 0.2s;
  padding: 0 0.2rem;
}

.alert-close:hover {
  opacity: 1;
}

/* Campos de formulario */
.form-group {
  margin-bottom: 1.35rem;
  position: relative;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.45rem;
}

.input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-left {
  position: absolute;
  left: 1.1rem;
  color: var(--text-light);
  font-size: 1rem;
  pointer-events: none;
  transition: var(--transition);
}

.form-control-modern {
  width: 100%;
  height: 50px;
  padding: 0 2.8rem 0 2.8rem;
  background-color: var(--surface-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--text-main);
  font-weight: 500;
  transition: var(--transition);
}

.form-control-modern::placeholder {
  color: #94A3B8;
  font-weight: 400;
}

.form-control-modern:hover {
  border-color: #CBD5E1;
  background-color: #FFFFFF;
}

.form-control-modern:focus {
  outline: none;
  border-color: var(--primary);
  background-color: #FFFFFF;
  box-shadow: 0 0 0 4px rgba(0, 128, 183, 0.15);
}

.input-container:focus-within .input-icon-left {
  color: var(--primary);
}

/* Botón para ver/ocultar contraseña */
.toggle-password {
  position: absolute;
  right: 0.85rem;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.45rem;
  font-size: 0.95rem;
  border-radius: 6px;
  transition: var(--transition);
}

.toggle-password:hover {
  color: var(--primary);
}

/* Mensajes de validación inline */
.field-error-msg {
  color: var(--error-text);
  font-size: 0.76rem;
  margin-top: 0.35rem;
  display: none;
}

.form-group.has-error .form-control-modern {
  border-color: var(--error-text);
  background-color: #FFFDFD;
}

.form-group.has-error .field-error-msg {
  display: block;
}

/* Opciones de formulario */
.form-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  font-size: 0.82rem;
}

.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  color: var(--text-muted);
}

.custom-checkbox input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.link-forgot {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
}

.link-forgot:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* Botón de envío */
.btn-submit {
  width: 100%;
  height: 52px;
  background: linear-gradient(135deg, var(--primary) 0%, #005F8A 100%);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.98rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  box-shadow: 0 6px 20px rgba(0, 128, 183, 0.35);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 128, 183, 0.45);
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
}

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

/* Estado de carga */
.btn-submit.is-loading {
  pointer-events: none;
  opacity: 0.85;
}

.btn-submit .btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-submit.is-loading .btn-spinner {
  display: inline-block;
}

.btn-submit.is-loading .btn-text,
.btn-submit.is-loading .btn-icon {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Pie del formulario / Redes sociales */
.auth-footer {
  /*margin-top: 2rem;*/
  text-align: center;
}

.auth-footer-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 1.5rem 0 1.2rem;
}

.auth-footer-divider::before,
.auth-footer-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}

.auth-footer-divider span {
  padding: 0 0.8rem;
  color: var(--text-light);
  font-size: 0.74rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}

.social-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  transition: var(--transition);
}

.social-btn:hover {
  background-color: #FFFFFF;
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.copyright-text {
  font-size: 0.76rem;
  color: var(--text-light);
}

.copyright-text a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}

.copyright-text a:hover {
  color: var(--primary);
}

/* Responsividad */
@media (max-width: 520px) {
  body {
    padding: 1rem 0.75rem;
  }
  
  .login-card {
    padding: 2.2rem 1.5rem 1.8rem;
    border-radius: var(--radius-lg);
  }
  
  .auth-header h2 {
    font-size: 1.45rem;
  }
}
