/* ========================================
   MARIACHI 2000 - LOGIN
   Estilos profesionales con accesibilidad
   ======================================== */

:root {
    /* ========================================
       AZUL MARINO - COLOR PRINCIPAL DE MARCA
       ======================================== */

    --color-navy-bright: #0a3d5c;
    --color-navy-hover: #082f47;
    --color-navy: #01151f;
    --color-navy-medium: #021a27;
    --color-navy-dark: #010f16;
    --color-navy-deep: #010a0f;
    --color-navy-darkest: #000508;

    --color-secondary: #01151f;
    --color-secondary-light: #0a2c3d;
    --color-secondary-dark: #000508;
    --color-secondary-alt: #052030;

    --gradient-brand: linear-gradient(155deg, #000508 0%, #01151f 44%, #0a2c3d 55%, #052030 70%);

    /* ========================================
       DORADO - COLOR DE ACENTO (MARIACHI 2000)
       ======================================== */

    --color-gold-light: #FEDB37;
    --color-gold-medium: #FDB931;
    --color-gold: #fec611;
    --color-gold-dark: #D4AF37;
    --color-gold-bronze: #9f7928;

    --color-primary: #fec611;
    --color-primary-light: #FEDB37;
    --color-primary-dark: #9f7928;
    --color-primary-alt: #D4AF37;

    /* ========================================
       CREMAS - FONDOS CÁLIDOS
       ======================================== */

    --color-cream-white: #fff9db;
    --color-cream-light: #fff4b8;
    --color-cream: #F5EEE6;
    --color-cream-deep: #EBE3D9;

    /* ========================================
       VERDE BOSQUE - ACENTO SECUNDARIO (ÉXITO)
       ======================================== */

    --color-forest-deep: #2D4A3E;
    --color-forest: #3A5248;
    --color-forest-light: #4A6358;
    --color-forest-muted: #5A7368;
    --color-forest-night: #1F3D32;

    /* ========================================
       COLORES DE TEXTO
       ======================================== */

    --color-text-primary: #222;
    --color-text-secondary: #666;
    --color-text-tertiary: #999;
    --color-text-muted: #adadad;
    --color-text-light: #ccc;
    --color-text-white: #fff;

    /* ========================================
       COLORES DE FONDO
       ======================================== */

    --color-bg-white: #fff;
    --color-bg-cream: #FAF6F1;
    --color-bg-light: #F5EEE6;
    --color-bg-dark: #222;
    --color-bg-darker: #1a1a1a;
    --color-bg-black: #000;

    /* ========================================
       COLORES DE BORDES Y SEPARADORES
       ======================================== */

    --color-border-light: #ececec;
    --color-border-medium: #ccc;
    --color-border-cream: #EBE3D9;
    --color-border-gold: #D4B896;

    /* ========================================
       COLORES DE ESTADO
       ======================================== */

    --color-error: #B91400;
    --color-error-dark: #330000;
    --color-success: #2D4A3E;
    --color-success-light: #3A5248;
    --color-warning: #C4A67A;

    /* ========================================
       TIPOGRAFÍA
       ======================================== */

    --font-main: 'VT323', monospace;

    /* ========================================
       TRANSICIONES Y BORDES
       ======================================== */

    --transition-fast: 0.3s ease;
    --transition-medium: 0.5s ease;
    --border-radius: 8px;
    --border-radius-lg: 15px;

    /* ========================================
       SOMBRAS
       ======================================== */

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --shadow-gold: 0 4px 15px rgba(254, 198, 17, 0.3);
    --shadow-navy: 0 4px 15px rgba(1, 21, 31, 0.3);
}

/* ========================================
   BASE
   ======================================== */

body {
  min-height: 100vh;
  background: #000;
  font-family: var(--font-main);
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

/* ========================================
   FONDO MATRIX
   ======================================== */

.matrix-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#matrix-canvas {
  display: block;
}

/* ========================================
   CONTENEDOR PRINCIPAL
   ======================================== */

.contenedor {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

/* ========================================
   CAJA DE LOGIN
   ======================================== */

.login-box {
  position: relative;
  width: 450px;
  max-width: 100%;
  /* Glassmorphism */
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(20px);
  border: 2px solid rgba(170, 132, 83, 0.4);
  border-radius: var(--border-radius-lg);
  padding: 50px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.6),
    inset 0 0 30px rgba(170, 132, 83, 0.08),
    0 0 20px rgba(170, 132, 83, 0.2);
  transform: perspective(1000px) rotateX(5deg);
  transition: all var(--transition-medium);
}

.login-box.error {
  animation: glitchError 0.5s ease;
  border-color: var(--color-error);
  box-shadow:
    0 0 30px rgba(185, 20, 0, 0.8),
    0 10px 20px rgba(0, 0, 0, 0.9),
    inset 0 0 15px rgba(185, 20, 0, 0.3);
}

@keyframes glitchError {
  0%, 100% { transform: perspective(1000px) rotateX(5deg); }
  20% { transform: perspective(1000px) rotateX(5deg) translate(-5px, 5px); }
  40% { transform: perspective(1000px) rotateX(5deg) translate(5px, -5px); }
  60% { transform: perspective(1000px) rotateX(5deg) translate(-5px, 0); }
  80% { transform: perspective(1000px) rotateX(5deg) translate(5px, 0); }
}

/* ========================================
   EFECTO GLITCH OVERLAY
   ======================================== */

.glitch-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  pointer-events: none;
  border-radius: var(--border-radius-lg);
}

.titulo.glitch {
  position: relative;
  animation: glitchText 0.3s ease;
}

.titulo.glitch::before,
.titulo.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  color: var(--color-gold);
}

.titulo.glitch::before {
  clip: rect(0, 900px, 0, 0);
  animation: glitchTop 0.3s linear;
  left: 2px;
  text-shadow: -2px 0 var(--color-navy-bright);
}

.titulo.glitch::after {
  clip: rect(0, 900px, 0, 0);
  animation: glitchBottom 0.3s linear;
  left: -2px;
  text-shadow: 2px 0 var(--color-forest-deep);
}

@keyframes glitchText {
  0% { transform: translate(0); }
  20% { transform: translate(-3px, 3px); }
  40% { transform: translate(3px, -3px); }
  60% { transform: translate(-3px, 0); }
  80% { transform: translate(3px, 0); }
  100% { transform: translate(0); }
}

@keyframes glitchTop {
  0% { clip: rect(10px, 9999px, 20px, 0); }
  50% { clip: rect(50px, 9999px, 60px, 0); }
  100% { clip: rect(30px, 9999px, 40px, 0); }
}

@keyframes glitchBottom {
  0% { clip: rect(60px, 9999px, 70px, 0); }
  50% { clip: rect(20px, 9999px, 30px, 0); }
  100% { clip: rect(40px, 9999px, 50px, 0); }
}

/* ========================================
   NODO DE ENERGÍA
   ======================================== */

.energy-node {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 40px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.node-core {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, var(--color-navy-dark) 0%, var(--color-navy-darkest) 70%);
  border-radius: 50%;
  border: 2px solid var(--color-gold);
  box-shadow: 0 0 20px rgba(170, 132, 83, 0.4), inset 0 0 20px rgba(0, 0, 0, 0.5);
  animation: corePulse 3s infinite ease-in-out;
  transition: all var(--transition-medium);
  z-index: 2;
}

.mariachi-icon {
  position: relative;
  z-index: 3;
  font-size: 4rem;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
  transition: all 0.3s ease;
}

/* Efecto glitch ocasional (activado por JS) */
.energy-node.glitch .node-core {
  animation: nodeGlitch 0.3s ease;
}

.energy-node.glitch .mariachi-icon {
  animation: iconGlitch 0.3s ease;
}

@keyframes nodeGlitch {
  0% { transform: translate(0); }
  20% { transform: translate(-2px, 2px); filter: brightness(1.2); }
  40% { transform: translate(2px, -2px); filter: brightness(0.8); }
  60% { transform: translate(-2px, 0); }
  80% { transform: translate(2px, 0); filter: brightness(1.1); }
  100% { transform: translate(0); filter: brightness(1); }
}

@keyframes iconGlitch {
  0% { transform: translate(0); filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5)); }
  25% { transform: translate(-3px, 0); filter: drop-shadow(3px 0 0 var(--color-navy-bright)) drop-shadow(-3px 0 0 var(--color-forest-deep)); }
  50% { transform: translate(3px, 0); filter: drop-shadow(-3px 0 0 var(--color-navy-bright)) drop-shadow(3px 0 0 var(--color-forest-deep)); }
  75% { transform: translate(-1px, 1px); filter: brightness(1.2); }
  100% { transform: translate(0); filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5)); }
}

.energy-waves {
  position: absolute;
  top: -20px;
  left: -20px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(170, 132, 83, 0.2);
  opacity: 0;
  transform: scale(0.8);
  transition: all var(--transition-medium);
}

.energy-node.active .node-core {
  animation: coreActive 0.5s infinite alternate;
}

.energy-node.active .energy-waves {
  opacity: 0.6;
  transform: scale(1);
  animation: waveBurst 1.5s infinite;
}

.energy-node.success .node-core {
  background: radial-gradient(circle, var(--color-forest-deep) 40%, var(--color-forest) 80%);
  box-shadow: 0 0 40px var(--color-forest-deep);
  animation: coreSuccess 0.5s infinite;
}

.energy-node.error .node-core {
  background: radial-gradient(circle, var(--color-error) 20%, var(--color-error-dark) 70%);
  box-shadow: 0 0 20px var(--color-error);
  animation: coreError 0.5s infinite alternate;
}

@keyframes corePulse {
  0% { transform: scale(1); box-shadow: 0 0 20px rgba(170, 132, 83, 0.4), inset 0 0 20px rgba(0, 0, 0, 0.5); }
  50% { transform: scale(1.03); box-shadow: 0 0 30px rgba(170, 132, 83, 0.6), inset 0 0 15px rgba(0, 0, 0, 0.4); }
  100% { transform: scale(1); box-shadow: 0 0 20px rgba(170, 132, 83, 0.4), inset 0 0 20px rgba(0, 0, 0, 0.5); }
}

@keyframes coreActive {
  0% { transform: scale(1); }
  100% { transform: scale(1.1); }
}

@keyframes waveBurst {
  0% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 0.3; }
  100% { transform: scale(1); opacity: 0.6; }
}

@keyframes coreSuccess {
  0% { transform: scale(1); }
  100% { transform: scale(1.15); }
}

@keyframes coreError {
  0% { transform: scale(1); box-shadow: 0 0 20px var(--color-error); }
  100% { transform: scale(0.95); box-shadow: 0 0 10px var(--color-error); }
}

/* ========================================
   TÍTULO
   ======================================== */

.titulo {
  font-size: 2.5rem;
  color: var(--color-gold);
  text-shadow: 0 0 15px var(--color-gold), 0 0 30px var(--color-gold-light);
  margin-bottom: 40px;
  position: relative;
  text-align: center;
}

/* ========================================
   FORMULARIO
   ======================================== */

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-group {
  position: relative;
}

.input-group input[type="text"],
.input-group input[type="password"] {
  width: 100%;
  padding: 12px 12px 12px 45px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(170, 132, 83, 0.5);
  border-radius: var(--border-radius);
  color: var(--color-gold-light);
  font-family: var(--font-main);
  font-size: 1.6rem;
  outline: none;
  transition: all var(--transition-fast);
}

.password-group input[type="text"],
.password-group input[type="password"] {
  padding-right: 50px;
}

.input-group input:focus,
.input-group.active input {
  box-shadow: 0 0 15px rgba(170, 132, 83, 0.4);
  background: rgba(0, 0, 0, 0.5);
  border-color: var(--color-gold);
}

.input-group input::placeholder {
  color: rgba(212, 184, 150, 0.5);
}

.input-group input.invalid {
  border-color: var(--color-error);
  box-shadow: 0 0 10px rgba(185, 20, 0, 0.5);
}

.input-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-gold);
  font-size: 1.4rem;
  z-index: 1;
}

/* ========================================
   TOGGLE PASSWORD
   ======================================== */

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-gold);
  cursor: pointer;
  padding: 8px;
  font-size: 1.2rem;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-toggle:hover,
.password-toggle:focus {
  opacity: 1;
}

.password-toggle[aria-pressed="true"] i::before {
  content: "\f070";
}

/* ========================================
   CAPS LOCK WARNING
   ======================================== */

.caps-warning {
  display: none;
  position: absolute;
  bottom: -28px;
  left: 0;
  font-size: 1rem;
  color: var(--color-warning);
  align-items: center;
  gap: 6px;
  animation: fadeIn 0.3s ease;
}

.caps-warning.visible {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   ERRORES DE CAMPO
   ======================================== */

.field-error {
  display: none;
  position: absolute;
  bottom: -24px;
  left: 0;
  font-size: 1rem;
  color: var(--color-error);
}

.field-error.visible {
  display: block;
}

/* ========================================
   REMEMBER ME CHECKBOX
   ======================================== */

.form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
}

.remember-me {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--color-gold-light);
  font-size: 1.2rem;
  user-select: none;
}

.remember-me input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkbox-custom {
  position: relative;
  width: 22px;
  height: 22px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(170, 132, 83, 0.5);
  border-radius: 4px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.remember-me:hover .checkbox-custom {
  box-shadow: 0 0 10px var(--color-gold);
}

.remember-me input:checked + .checkbox-custom {
  background: var(--color-gold);
}

.remember-me input:checked + .checkbox-custom::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 12px;
  border: solid var(--color-navy-darkest);
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.remember-me input:focus-visible + .checkbox-custom {
  outline: 2px solid var(--color-gold-light);
  outline-offset: 2px;
}

.remember-text {
  opacity: 0.9;
}

/* ========================================
   BOTÓN LOGIN
   ======================================== */

.btn-login {
  position: relative;
  padding: 15px;
  background: linear-gradient(145deg, var(--color-gold), var(--color-gold-dark));
  border: none;
  border-radius: var(--border-radius);
  color: var(--color-navy-darkest);
  font-family: var(--font-main);
  font-size: 1.6rem;
  font-weight: bold;
  cursor: pointer;
  overflow: hidden;
  transition: all var(--transition-fast);
  box-shadow: 0 0 15px rgba(170, 132, 83, 0.5), var(--shadow-gold);
  min-height: 50px;
}

.btn-login:hover:not(:disabled) {
  box-shadow: 0 0 30px var(--color-gold-light), var(--shadow-gold);
  transform: translateY(-2px);
  background: linear-gradient(145deg, var(--color-gold-light), var(--color-gold));
}

.btn-login:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn-login.loading .btn-text {
  display: none;
}

.btn-login.loading .btn-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.btn-loading {
  display: none;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(1, 21, 31, 0.3);
  border-radius: 50%;
  border-top-color: var(--color-navy-darkest);
  animation: spin 1s ease-in-out infinite;
}

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

/* ========================================
   CONTADOR DE INTENTOS
   ======================================== */

.attempt-counter {
  text-align: center;
  font-size: 1.1rem;
  color: rgba(212, 184, 150, 0.8);
  min-height: 1.5em;
  margin-top: 10px;
}

.attempt-counter.warning {
  color: var(--color-warning);
}

.attempt-counter.danger {
  color: var(--color-error);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========================================
   TRANSICIÓN DE ÉXITO
   ======================================== */

.success-transition {
  animation: matrixFade 1.5s ease forwards;
}

@keyframes matrixFade {
  0% { opacity: 1; filter: brightness(1); }
  100% { opacity: 0; filter: brightness(2); }
}

/* ========================================
   FOOTER
   ======================================== */

.footer-text {
  margin-top: 25px;
  color: var(--color-gold);
  font-size: 1.4rem;
  text-shadow: 0 0 10px var(--color-gold);
  text-align: center;
}

/* ========================================
   LOGO MARIACHI
   ======================================== */

.mariachi-logo {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.2rem;
  color: var(--color-gold);
  text-shadow: 0 0 10px var(--color-gold-light);
  letter-spacing: 2px;
  text-transform: uppercase;
  z-index: 10;
  font-family: var(--font-main);
}

/* ========================================
   RESPONSIVE
   ======================================== */

/* Tablets y pantallas medianas */
@media (max-width: 768px) {
  .contenedor {
    padding: 15px;
  }

  .login-box {
    width: 100%;
    max-width: 420px;
    padding: 40px 30px;
  }

  .titulo {
    font-size: 2.2rem;
  }

  .energy-node {
    width: 120px;
    height: 120px;
    margin-bottom: 35px;
  }

  .energy-waves {
    width: 160px;
    height: 160px;
    top: -20px;
    left: -20px;
  }

  .mariachi-icon {
    font-size: 3rem;
  }
}

/* Móviles */
@media (max-width: 500px) {
  .mariachi-logo {
    font-size: 1rem;
    letter-spacing: 1px;
    top: 15px;
  }

  .contenedor {
    padding: 10px;
    align-items: flex-start;
    padding-top: 60px;
  }

  .login-box {
    width: 100%;
    padding: 30px 20px;
    transform: none;
    border-width: 3px;
    border-radius: 12px;
  }

  .titulo {
    font-size: 1.7rem;
    margin-bottom: 30px;
  }

  .energy-node {
    width: 100px;
    height: 100px;
    margin-bottom: 25px;
  }

  .energy-waves {
    width: 140px;
    height: 140px;
    top: -20px;
    left: -20px;
  }

  .mariachi-icon {
    font-size: 2.5rem;
  }

  .login-form {
    gap: 18px;
  }

  .input-group input[type="text"],
  .input-group input[type="password"] {
    font-size: 1.4rem;
    padding: 10px 10px 10px 40px;
  }

  .password-group input[type="text"],
  .password-group input[type="password"] {
    padding-right: 45px;
  }

  .input-icon {
    font-size: 1.2rem;
    left: 12px;
  }

  .password-toggle {
    right: 8px;
    min-width: 40px;
    min-height: 40px;
  }

  .btn-login {
    font-size: 1.4rem;
    padding: 12px;
    min-height: 46px;
  }

  .remember-me {
    font-size: 1.1rem;
  }

  .checkbox-custom {
    width: 20px;
    height: 20px;
  }

  .remember-me input:checked + .checkbox-custom::after {
    left: 5px;
    top: 1px;
    width: 5px;
    height: 11px;
  }

  .footer-text {
    font-size: 1.2rem;
    margin-top: 20px;
  }

  .attempt-counter {
    font-size: 1rem;
  }

  .caps-warning {
    font-size: 0.9rem;
    bottom: -25px;
  }

  .field-error {
    font-size: 0.9rem;
    bottom: -22px;
  }
}

/* Móviles muy pequeños */
@media (max-width: 360px) {
  .contenedor {
    padding: 8px;
    padding-top: 55px;
  }

  .login-box {
    padding: 25px 15px;
  }

  .titulo {
    font-size: 1.5rem;
    margin-bottom: 25px;
  }

  .energy-node {
    width: 85px;
    height: 85px;
    margin-bottom: 20px;
  }

  .energy-waves {
    width: 125px;
    height: 125px;
  }

  .mariachi-icon {
    font-size: 2.2rem;
  }

  .input-group input[type="text"],
  .input-group input[type="password"] {
    font-size: 1.3rem;
    padding: 9px 9px 9px 38px;
  }

  .btn-login {
    font-size: 1.3rem;
    padding: 10px;
  }

  .remember-me {
    font-size: 1rem;
    gap: 8px;
  }

  .footer-text {
    font-size: 1.1rem;
  }
}

/* Landscape en móviles */
@media (max-height: 500px) and (orientation: landscape) {
  .contenedor {
    padding: 10px;
    align-items: flex-start;
    padding-top: 10px;
  }

  .mariachi-logo {
    position: relative;
    top: 0;
    transform: none;
    margin-bottom: 10px;
    text-align: center;
  }

  .login-box {
    transform: none;
    padding: 20px 30px;
  }

  .energy-node {
    width: 70px;
    height: 70px;
    margin-bottom: 15px;
  }

  .energy-waves {
    width: 110px;
    height: 110px;
  }

  .mariachi-icon {
    font-size: 1.8rem;
  }

  .titulo {
    font-size: 1.5rem;
    margin-bottom: 15px;
  }

  .login-form {
    gap: 12px;
  }

  .input-group input[type="text"],
  .input-group input[type="password"] {
    padding: 8px 8px 8px 38px;
    font-size: 1.2rem;
  }

  .btn-login {
    padding: 10px;
    min-height: 40px;
  }

  .form-options {
    margin-top: 0;
  }

  .footer-text {
    margin-top: 15px;
    font-size: 1.1rem;
  }
}

/* Preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
