/* === AUTH LOGIN STYLES - DEMS === */

:root {
    --primary: #1e40af;
    --primary-dark: #1d4ed8;
    --secondary: #1f2937;
    --accent: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-light: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: rgb(149, 163, 184);
    --text-muted: #475569;
    --border: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e40af 0%, #1f2937 40%, #3b82f6 70%, #111827 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    /* Prevenir flasheo - body siempre visible */
    opacity: 1 !important;
    visibility: visible !important;
}

/* Prevenir flash entre vistas móvil/desktop */
body, 
.login-card {
    -webkit-perspective: 1000;
    perspective: 1000;
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
}

/* Suavizar transiciones entre media queries */
* {
    -webkit-transition: all 0.1s ease-out;
    transition: all 0.1s ease-out;
}

/* Animaciones universales - Sin media queries que causen flash */

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes float {
    /* Animación base no utilizada */
    0%, 100% { transform: translateY(0); }
}

/* Login Container */
.login-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 1.5rem;
    z-index: 10;
}

.login-card {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 2rem;
    box-shadow: 
        0 25px 45px -5px rgba(0, 0, 0, 0.15),
        0 10px 15px -5px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    overflow: hidden;
    position: relative;
    /* Animación de entrada suave SIN flasheo */
    animation: slideUpSmooth 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform-style: preserve-3d;
    /* Visible desde el inicio para prevenir flasheo */
    opacity: 1;
    visibility: visible;
}

/* Optimización móvil */
.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, 
        var(--primary) 0%, 
        var(--secondary) 33%, 
        var(--accent) 66%, 
        var(--primary) 100%);
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: 200% 0; }
    50% { background-position: -200% 0; }
}

/* Animación original que causaba flasheo (obsoleta) */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(60px) scale(0.95);
        filter: blur(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* Nueva animación SIN flasheo - comienza desde estado visible */
@keyframes slideUpSmooth {
    from {
        opacity: 0.7;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-header {
    text-align: center;
    padding: 2rem 2rem 1.5rem;
    background: linear-gradient(135deg, 
        rgba(99, 102, 241, 0.08), 
        rgba(139, 92, 246, 0.04));
    position: relative;
}

.login-header::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 1px;
}

.login-logo {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    box-shadow: 
        0 15px 35px rgba(99, 102, 241, 0.3),
        0 5px 15px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    animation: logoFloat 3s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

.login-logo::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: logoShine 4s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-5px) rotate(5deg); }
}

@keyframes logoShine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    50% { transform: translateX(100%) translateY(100%) rotate(45deg); }
    100% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
}

.login-logo i {
    font-size: 3rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 
            0 15px 35px rgba(99, 102, 241, 0.3),
            0 5px 15px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 
            0 20px 45px rgba(99, 102, 241, 0.4),
            0 8px 25px rgba(0, 0, 0, 0.15);
    }
}

.login-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, var(--text-primary), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.login-subtitle {
    color: rgb(160, 180, 210);
    font-size: 0.9rem;
    font-weight: 400;
    opacity: 1;
    line-height: 1.4;
}

.login-body {
    padding: 0 2.5rem 2.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
    position: relative;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.input-wrapper {
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-wrapper:hover {
    transform: translateY(-1px);
}

.input-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    z-index: 2;
    transition: all 0.3s ease;
}

.form-control {
    width: 100%;
    padding: 0.875rem 1.25rem 0.875rem 3rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    border-radius: 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Optimización móvil - reducir efectos de blur */
@media (max-width: 768px) {
    .form-control {
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        transition: all 0.2s ease;
    }
}

.form-control.has-toggle {
    padding-right: 3rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 
        0 0 0 3px rgba(99, 102, 241, 0.15),
        0 8px 25px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.form-control:focus ~ .input-icon {
    color: var(--primary);
    transform: translateY(-50%) scale(1.1);
}

.form-control::placeholder {
    color: #475569;
}

.form-hint {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
    opacity: 0.8;
}

.password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #475569;
    font-size: 1.1rem;
    cursor: pointer;
    z-index: 2;
    transition: color 0.3s ease;
}

.password-toggle:hover {
    color: var(--primary);
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.remember-me:hover {
    background: rgba(255, 255, 255, 0.05);
}

.remember-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border);
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.remember-checkbox:hover {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.remember-checkbox:checked {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.remember-checkbox:checked::after {
    content: '\2713';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.85rem;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.remember-label {
    color: rgb(160, 180, 210);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: color 0.3s ease;
}

.remember-label:hover {
    color: var(--text-primary);
}

.btn-login {
    width: 100%;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 1rem;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.025em;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    margin-top: 0.5rem;
    box-shadow: 
        0 8px 25px rgba(99, 102, 241, 0.3),
        0 4px 15px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    text-transform: uppercase;
    cursor: pointer;
}

.btn-login::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.25), 
        transparent);
    transition: left 0.6s ease;
}

.btn-login::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transition: all 0.4s ease;
    transform: translate(-50%, -50%);
}

/* Optimización móvil - simplificar efectos del botón */
@media (max-width: 768px) {
    .btn-login {
        transition: all 0.2s ease;
    }
    
    .btn-login::before,
    .btn-login::after {
        display: none;
    }
}

.btn-login:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 
        0 15px 35px rgba(99, 102, 241, 0.4),
        0 8px 25px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-login:hover::before {
    left: 100%;
}

.btn-login:hover::after {
    width: 300px;
    height: 300px;
}

.btn-login:active {
    transform: translateY(-1px) scale(0.98);
    transition: all 0.1s ease;
}

.alert {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: 0.75rem;
    border: none;
    font-weight: 500;
    position: relative;
    animation: alertSlide 0.5s ease-out;
}

@keyframes alertSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-security {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3);
    position: relative;
}

.alert-security::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #dc2626;
    border-radius: 0.75rem 0 0 0.75rem;
}

.alert-security .security-details {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    opacity: 0.9;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Estilos especiales para alertas CSRF */
.alert-csrf {
    background: rgba(245, 158, 11, 0.15) !important;
    border: 2px solid rgba(245, 158, 11, 0.4) !important;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
    animation: csrfPulse 2s ease-in-out;
}

.alert-csrf::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #f59e0b, #d97706, #f59e0b);
    background-size: 200% 100%;
    animation: shimmerCSRF 3s linear infinite;
}

@keyframes csrfPulse {
    0%, 100% { 
        border-color: rgba(245, 158, 11, 0.4);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.3);
    }
    50% { 
        border-color: rgba(245, 158, 11, 0.6);
        box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.1);
    }
}

@keyframes shimmerCSRF {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.csrf-alert-content {
    padding: 0.75rem;
    position: relative;
    z-index: 1;
}

.csrf-alert-header {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #b45309;
}

.csrf-alert-message {
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    color: #92400e;
}

.csrf-alert-action {
    padding: 0.5rem;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 0.5rem;
    font-size: 0.85rem;
    color: #78350f;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.csrf-alert-action i {
    opacity: 0.8;
}

/* Login Footer - Derechos Reservados */
.login-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.25rem 1.5rem;
    z-index: 5;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.footer-content .copyright {
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.9rem;
    font-weight: 500;
    margin: 0 0 0.35rem 0;
    letter-spacing: 0.3px;
}

.footer-content .version {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    margin: 0;
    font-weight: 400;
}

/* Responsive Design */
@media (max-width: 480px) {
    .login-container {
        padding: 1rem;
    }

    .login-header {
        padding: 1.5rem 1.5rem 1rem;
    }

    .login-body {
        padding: 0 1.5rem 2rem;
    }

    .login-title {
        font-size: 1.5rem;
    }
    
    /* Footer responsive */
    .login-footer {
        padding: 1rem;
    }
    
    .footer-content .copyright {
        font-size: 0.8rem;
    }
    
    .footer-content .version {
        font-size: 0.7rem;
    }


    .login-logo {
        width: 70px;
        height: 70px;
        margin-bottom: 1rem;
    }

    .login-logo i {
        font-size: 1.75rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .remember-me {
        margin-bottom: 1.25rem;
    }
}

/* Prevenir flasheo en carga inicial */
html.page-loading,
body.page-loading {
    opacity: 0;
    visibility: hidden;
}

html.page-loaded,
body.page-loaded {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Loading State */
.btn-login.loading {
    pointer-events: none;
    position: relative;
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.8), rgba(31, 41, 55, 0.8));
}

.btn-login.loading::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border: 2.5px solid transparent;
    border-top: 2.5px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Estilos para botón bloqueado */
.btn-login:disabled {
    background: linear-gradient(135deg, #6c757d, #495057) !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
    pointer-events: none !important;
    transform: none !important;
}

.btn-login:disabled::before,
.btn-login:disabled::after {
    display: none !important;
}

/* Estilos para campos bloqueados */
.form-control:disabled {
    background-color: rgba(248, 249, 250, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.6) !important;
    cursor: not-allowed !important;
}

.password-toggle:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

/* Estilos para checkbox bloqueado */
.remember-checkbox:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.remember-checkbox:disabled + .remember-label {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    color: rgb(160, 180, 210) !important;
}

/* Micro-interactions */
.login-card:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 30px 50px -5px rgba(0, 0, 0, 0.2),
        0 15px 20px -5px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.password-toggle {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #475569;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 2;
    transition: all 0.3s ease;
    padding: 0.25rem;
    border-radius: 0.25rem;
}

.password-toggle:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    transform: translateY(-50%) scale(1.1);
}

/* Enhanced focus states */
.form-control:focus ~ .password-toggle {
    color: var(--primary);
}

/* Smooth transitions for all interactive elements */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* @keyframes spin movido a layout.css para evitar duplicación */
