/* ========================================
   IMPORTACIONES Y RESET
======================================== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

/* ========================================
   ESTILOS BASE DEL BODY
======================================== */
body {
    background: linear-gradient(135deg, #1b5074 0%, #2a7f00 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    animation: backgroundShift 10s ease-in-out infinite alternate;
}

/* Partículas flotantes de fondo */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 50% 10%, rgba(255, 255, 255, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 10% 90%, rgba(255, 255, 255, 0.06) 0%, transparent 50%);
    animation: floatingParticles 20s ease-in-out infinite;
    pointer-events: none;
}

/* Efecto de ondas en el fondo */
body::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle, rgba(255,255,255,0.03) 1px, transparent 1px),
        radial-gradient(circle, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 5rem 5rem, 7.5rem 7.5rem;
    animation: sparkleMove 25s linear infinite;
    pointer-events: none;
}

/* ========================================
   CONTENEDOR PRINCIPAL
======================================== */
.container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(1.25rem);
    padding: 3.125rem 2.5rem;
    border-radius: 1.5625rem;
    box-shadow: 
        0 1.875rem 3.75rem rgba(0, 0, 0, 0.3),
        0 0 0 0.0625rem rgba(255, 255, 255, 0.2),
        inset 0 0.0625rem 0 rgba(255, 255, 255, 0.4);
    width: 100%;
    max-width: 28.125rem;
    text-align: center;
    position: relative;
    animation: containerEntrance 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow: hidden;
}

/* Efecto de brillo deslizante en el contenedor */
.container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.15), transparent);
    animation: containerShine 4s ease-in-out infinite;
    pointer-events: none;
}

/* Borde animado */
.container::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: #95a5a6;
    background-size: 400% 400%;
    border-radius: 1.5625rem;
    z-index: -1;
    animation: borderGlow 3s ease-in-out infinite;
}

/* ========================================
   TÍTULOS Y TEXTOS
======================================== */
h2 {
    background: linear-gradient(135deg, #1b5074, #2a7f00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2.1875rem;
    font-size: 2.5rem;
    font-weight: 700;
    position: relative;
    animation: titleTypewriter 2s steps(20) 0.5s both;
    cursor: pointer;
    transition: all 0.3s ease;
}

h2:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0.3125rem 0.9375rem rgba(27, 80, 116, 0.3));
}

/* Línea decorativa bajo el título */
h2::after {
    content: '';
    position: absolute;
    bottom: -0.625rem;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0.1875rem;
    background: linear-gradient(90deg, #1b5074, #2a7f00);
    border-radius: 0.125rem;
    animation: lineExpand 1s ease-out 2s both;
}

/* Mensaje de error/token inválido */
p {
    color: #e74c3c;
    font-size: 1.1rem;
    font-weight: 500;
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.1), rgba(231, 76, 60, 0.05));
    border-left: 0.25rem solid #e74c3c;
    border-radius: 0.5rem;
    animation: errorPulse 2s ease-in-out infinite, fadeInError 0.8s ease;
    position: relative;
    overflow: hidden;
}

p::before {
    content: '⚠️';
    font-size: 1.5rem;
    margin-right: 0.625rem;
    animation: iconBounce 1s ease-in-out infinite;
}

/* ========================================
   FORMULARIO Y CAMPOS
======================================== */
form {
    animation: formSlideIn 1s ease-out 0.3s both;
}

.form-group {
    margin-bottom: 1.5625rem;
    position: relative;
    animation: fieldFadeIn 0.6s ease;
    overflow: hidden;
}

/* Efecto de onda en los form-groups */
.form-group::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(27, 80, 116, 0.1), transparent);
    transition: left 0.8s ease;
    pointer-events: none;
}

.form-group:hover::before {
    left: 100%;
}

label {
    display: block;
    margin-bottom: 0.625rem;
    color: #333;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

label:hover {
    color: #1b5074;
    transform: translateX(0.3125rem);
}

/* Efecto de subrayado en labels */
label::after {
    content: '';
    position: absolute;
    bottom: -0.125rem;
    left: 0;
    width: 0;
    height: 0.125rem;
    background: linear-gradient(90deg, #1b5074, #2a7f00);
    transition: width 0.3s ease;
}

label:hover::after {
    width: 100%;
}

.form-control {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 0.125rem solid #e1e5e9;
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    position: relative;
    box-shadow: inset 0 0.125rem 0.25rem rgba(0, 0, 0, 0.05);
}

.form-control:focus {
    outline: none;
    border-color: #1b5074;
    background: white;
    box-shadow: 
        0 0 0 0.25rem rgba(27, 80, 116, 0.1),
        0 0.5rem 1.5625rem rgba(27, 80, 116, 0.15),
        inset 0 0.125rem 0.25rem rgba(0, 0, 0, 0.05);
    transform: translateY(-0.1875rem) scale(1.02);
    animation: inputFocusPulse 0.6s ease;
}

.form-control:hover:not(:focus) {
    border-color: #2a7f00;
    transform: translateY(-0.0625rem);
    box-shadow: 
        0 0.25rem 0.9375rem rgba(42, 127, 0, 0.1),
        inset 0 0.125rem 0.25rem rgba(0, 0, 0, 0.05);
}

/* Efecto de validación en tiempo real */
.form-control:valid {
    border-color: #2a7f00;
    animation: successGlow 0.6s ease;
}

.form-control:invalid:not(:placeholder-shown) {
    border-color: #e74c3c;
    animation: errorShake 0.5s ease;
}

/* ========================================
   BOTONES
======================================== */
.btn {
    display: inline-block;
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 1.25rem;
    animation: buttonEntrance 0.8s ease-out 1s both;
}

.btn-success {
    background: linear-gradient(135deg, #1b5074 0%, #2a7f00 100%);
    color: white;
    box-shadow: 
        0 0.5rem 1.5625rem rgba(27, 80, 116, 0.3),
        0 0.25rem 0.625rem rgba(42, 127, 0, 0.2);
}

/* Efecto de brillo deslizante en el botón */
.btn-success::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.6s ease;
}

/* Efecto de ondas al hacer clic */
.btn-success::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.6s ease;
}

.btn-success:hover {
    transform: translateY(-0.25rem) scale(1.02);
    box-shadow: 
        0 0.9375rem 2.1875rem rgba(27, 80, 116, 0.4),
        0 0.5rem 0.9375rem rgba(42, 127, 0, 0.3);
    animation: buttonGlow 1.5s ease-in-out infinite alternate;
}

.btn-success:hover::before {
    left: 100%;
}

.btn-success:active {
    transform: translateY(-0.125rem) scale(0.98);
    transition: all 0.1s ease;
}

.btn-success:active::after {
    width: 18.75rem;
    height: 18.75rem;
}

/* Estado de carga */
.btn-success:disabled {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    cursor: not-allowed;
    transform: none;
    animation: none;
}

.btn-success:disabled::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.25rem;
    height: 1.25rem;
    margin: -0.625rem 0 0 -0.625rem;
    border: 0.125rem solid #ffffff;
    border-top: 0.125rem solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ========================================
   ANIMACIONES
======================================== */
@keyframes backgroundShift {
    0% { 
        background: linear-gradient(135deg, #1b5074 0%, #2a7f00 100%); 
    }
    100% { 
        background: linear-gradient(135deg, #2a7f00 0%, #1b5074 100%); 
    }
}

@keyframes floatingParticles {
    0%, 100% { 
        transform: translateY(0px) rotate(0deg); 
    }
    33% { 
        transform: translateY(-20px) rotate(120deg); 
    }
    66% { 
        transform: translateY(10px) rotate(240deg); 
    }
}

@keyframes sparkleMove {
    0% { 
        transform: rotate(0deg) translateY(0px); 
    }
    100% { 
        transform: rotate(360deg) translateY(-20px); 
    }
}

@keyframes containerEntrance {
    0% {
        opacity: 0;
        transform: translateY(50px) scale(0.8) rotateX(20deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotateX(0deg);
    }
}

@keyframes containerShine {
    0% { 
        transform: translateX(-100%) translateY(-100%) rotate(45deg); 
    }
    50% { 
        transform: translateX(100%) translateY(100%) rotate(45deg); 
    }
    100% { 
        transform: translateX(-100%) translateY(-100%) rotate(45deg); 
    }
}

@keyframes borderGlow {
    0%, 100% { 
        background-position: 0% 50%; 
    }
    50% { 
        background-position: 100% 50%; 
    }
}

@keyframes titleTypewriter {
    0% { 
        width: 0; 
        opacity: 0; 
    }
    1% { 
        opacity: 1; 
    }
    100% { 
        width: 100%; 
        opacity: 1; 
    }
}

@keyframes lineExpand {
    0% { 
        width: 0; 
    }
    100% { 
        width: 80px; 
    }
}

@keyframes errorPulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); 
    }
    50% { 
        box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); 
    }
}

@keyframes fadeInError {
    0% { 
        opacity: 0; 
        transform: translateY(-20px); 
    }
    100% { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

@keyframes iconBounce {
    0%, 100% { 
        transform: translateY(0); 
    }
    50% { 
        transform: translateY(-5px); 
    }
}

@keyframes formSlideIn {
    0% { 
        opacity: 0; 
        transform: translateY(30px); 
    }
    100% { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

@keyframes fieldFadeIn {
    0% { 
        opacity: 0; 
        transform: translateY(20px) translateX(-10px); 
    }
    100% { 
        opacity: 1; 
        transform: translateY(0) translateX(0); 
    }
}

@keyframes inputFocusPulse {
    0% { 
        box-shadow: 0 0 0 0 rgba(27, 80, 116, 0.4); 
    }
    70% { 
        box-shadow: 0 0 0 10px rgba(27, 80, 116, 0); 
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(27, 80, 116, 0); 
    }
}

@keyframes successGlow {
    0% { 
        box-shadow: 0 0 0 0 rgba(42, 127, 0, 0.4); 
    }
    70% { 
        box-shadow: 0 0 0 10px rgba(42, 127, 0, 0); 
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(42, 127, 0, 0); 
    }
}

@keyframes errorShake {
    0%, 100% { 
        transform: translateX(0); 
    }
    25% { 
        transform: translateX(-8px); 
    }
    75% { 
        transform: translateX(8px); 
    }
}

@keyframes buttonEntrance {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translateY(-5px) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes buttonGlow {
    from { 
        box-shadow: 
            0 15px 35px rgba(27, 80, 116, 0.4),
            0 8px 15px rgba(42, 127, 0, 0.3),
            0 0 20px rgba(27, 80, 116, 0.2); 
    }
    to { 
        box-shadow: 
            0 15px 35px rgba(27, 80, 116, 0.6),
            0 8px 15px rgba(42, 127, 0, 0.5),
            0 0 30px rgba(27, 80, 116, 0.4); 
    }
}

@keyframes spin {
    0% { 
        transform: rotate(0deg); 
    }
    100% { 
        transform: rotate(360deg); 
    }
}

/* ========================================
   ANIMACIONES SECUENCIALES
======================================== */
.form-group:nth-child(1) {
    animation-delay: 0.1s;
}

.form-group:nth-child(2) {
    animation-delay: 0.3s;
}

.form-group:nth-child(3) {
    animation-delay: 0.5s;
}

/* ========================================
   RESPONSIVE DESIGN
======================================== */
@media (max-width: 30rem) {
    .container {
        padding: 2.5rem 1.5625rem;
        margin: 0.9375rem;
        border-radius: 1.25rem;
    }
    
    h2 {
        font-size: 2rem;
        margin-bottom: 1.875rem;
    }
    
    .form-control {
        padding: 0.875rem 1.125rem;
        font-size: 0.9375rem;
    }
    
    .btn {
        padding: 0.875rem 2.1875rem;
        font-size: 0.9375rem;
    }
}

/* ========================================
   MEJORAS DE ACCESIBILIDAD
======================================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible para navegación por teclado */
.btn:focus-visible,
.form-control:focus-visible {
    outline: 0.125rem solid #1b5074;
    outline-offset: 0.125rem;
}
