/* ============================================================================
   SICOAS Grupo — Login Styles
   ============================================================================ */
:root {
    --primary: #519BE9;
    --primary-dark: #2563EB;
    --primary-light: #7BB5F0;
    --secondary: #D44A59;
    --accent: #F0C6A3;
    --accent-dark: #D4A882;
    
    /* Superficie sólida estandarizada SICOAS (sin liquid glass) */
    --card-bg: #FFFFFF;
    --card-border: #E2E8F0;
    --card-shadow: 0 20px 50px -12px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(226, 232, 240, 0.6);
    
    --input-bg: #FFFFFF;
    --input-border: #CBD5E1;
    
    --text-title: #0F172A;
    --text-primary: #0F172A;
    --text-body: #1E293B;
    --text-muted: #475569;
    --text-dim: #64748B;
    --dark-soft: #1E293B;
    
    --font-body: 'Outfit', sans-serif;
    --font-heading: 'Plus Jakarta Sans', sans-serif;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    height: 100%;
    scroll-behavior: smooth;
}

body, body.grupo-login-body {
    font-family: var(--font-body);
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    padding: 1.5rem;
    margin: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

/* Neutralización defensiva de clases de dashboard heredadas/cacheadas */
body.sicoas-main, .sicoas-main {
    margin-left: 0 !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
    width: 100% !important;
}

/* Accesibilidad por teclado */
button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary-dark);
    outline-offset: 2px;
}

.login-container {
    display: flex;
    width: 100%;
    max-width: 1060px;
    min-height: 560px;
    background: var(--card-bg);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    margin: auto !important;
    position: relative;
    z-index: 10;
    border: 1px solid var(--card-border);
}

/* Menisco superior iridiscente SICOAS */
.login-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3.5px;
    background: linear-gradient(90deg, #519BE9 0%, #F0C6A3 50%, #D44A59 100%);
    z-index: 15;
}

/* Visual Panel */
.login-visual {
    flex: 1.1;
    background: linear-gradient(145deg, #f8fafc 0%, #edf4fc 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2.75rem;
    position: relative;
    overflow: hidden;
    color: var(--text-body);
    border-right: 1px solid var(--card-border);
}

.visual-gradient {
    position: absolute;
    top: -50%;
    right: -30%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(81,155,233,0.18) 0%, transparent 70%);
    pointer-events: none;
}

.visual-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(81, 155, 233, 0.16);
    border: 1px solid rgba(81, 155, 233, 0.35);
    padding: 0.45rem 1rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #1D4ED8;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(8px);
}

.visual-content h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 0.75rem;
    color: var(--text-title);
}

.visual-content .gradient-text {
    background: linear-gradient(135deg, #2563EB 0%, #D44A59 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.visual-content p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-muted);
    max-width: 380px;
    margin-bottom: 1.75rem;
    font-weight: 500;
}

.visual-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.visual-stats .stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-body);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.70);
    border: 1px solid rgba(148, 163, 184, 0.35);
    padding: 7px 12px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.visual-stats .stat i {
    color: #2563EB;
    font-size: 1rem;
}

/* Form Section */
.login-form-section {
    flex: 0.9;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    background: #FFFFFF;
}

.login-form-wrapper {
    width: 100%;
    max-width: 390px;
}

/* Encabezado y Logo Oficial Transparente */
.brand-header {
    text-align: center;
    margin-bottom: 20px;
}

.logo-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    padding: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    transition: var(--transition);
}

.logo-wrapper:hover {
    transform: scale(1.04);
}

.logo-principal-img {
    max-width: 165px;
    height: auto;
    display: block;
    filter: drop-shadow(0 4px 14px rgba(81, 155, 233, 0.35)) drop-shadow(0 2px 5px rgba(15, 23, 42, 0.15));
    transition: filter 0.3s ease;
}

.logo-wrapper:hover .logo-principal-img {
    filter: drop-shadow(0 6px 20px rgba(81, 155, 233, 0.5)) drop-shadow(0 3px 8px rgba(15, 23, 42, 0.22));
}

.portal-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(81, 155, 233, 0.14);
    border: 1px solid rgba(81, 155, 233, 0.35);
    color: #1D4ED8;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.login-form-wrapper h1,
.login-form-wrapper h2 {
    font-family: var(--font-heading);
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-title);
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    font-weight: 500;
}

.login-error {
    background: rgba(254, 242, 242, 0.92);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #991B1B;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.12);
    animation: shake 0.5s ease;
}

.login-success {
    background: rgba(240, 253, 244, 0.92);
    border: 1px solid rgba(34, 197, 94, 0.45);
    color: #166534;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.12);
}

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

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-body);
    margin-bottom: 0.5rem;
}

.form-group label i {
    color: #2563EB;
    margin-right: 0.25rem;
}

.form-group input {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-title);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    outline: none;
    background: var(--input-bg);
}

.form-group input::placeholder {
    color: var(--text-dim);
    font-weight: 400;
}

.form-group input:focus {
    border-color: #3B82F6;
    box-shadow: 0 0 0 4px rgba(81,155,233,0.20);
    background: #FFFFFF;
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-wrapper input {
    padding-right: 46px !important;
    width: 100%;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-dim);
    padding: 0.25rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color 0.3s, background-color 0.3s;
    z-index: 5;
}

.toggle-password:hover {
    color: #2563EB;
    background: rgba(81, 155, 233, 0.12);
}

.btn-login {
    width: 100%;
    padding: 0.9rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 55%, #1D4ED8 100%);
    color: #fff;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.32), 0 2px 6px rgba(37, 99, 235, 0.20);
    margin-top: 0.5rem;
    position: relative;
    overflow: hidden;
}

.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.5s ease;
}

.btn-login:hover::before { left: 100%; }
.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.42);
}

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

.login-footer {
    margin-top: 2.25rem;
    text-align: center;
}

.login-footer p {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* Tabs de Navegación */
.login-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(148, 163, 184, 0.35);
    padding: 4px;
    border-radius: 14px;
    margin-bottom: 1.5rem;
    gap: 4px;
}

.tab-btn {
    flex: 1;
    padding: 0.65rem 0.5rem;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.tab-btn:hover {
    color: #2563EB;
    background: rgba(81, 155, 233, 0.10);
}

.tab-btn.active {
    background: #2563EB;
    color: #FFFFFF;
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.3);
    font-weight: 700;
}

/* Filas de Etiquetas y Links */
.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.label-row label {
    margin-bottom: 0;
}

.forgot-link {
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

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

.form-actions-center {
    text-align: center;
    margin-top: 1.25rem;
}

/* Divisor y Botón Biométrico */
.biometric-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0 1rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

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

.biometric-divider span {
    padding: 0 0.75rem;
}

.btn-biometric {
    width: 100%;
    padding: 0.85rem;
    border: 2px solid rgba(81,155,233,0.3);
    border-radius: 50px;
    background: rgba(81,155,233,0.06);
    color: var(--primary-dark);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.btn-biometric i {
    font-size: 1.1rem;
    color: var(--primary);
}

.btn-biometric:hover {
    background: rgba(81,155,233,0.15);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(81,155,233,0.2);
}

/* Alertas de Éxito */
.login-success {
    background: rgba(16,185,129,0.08);
    border: 1px solid rgba(16,185,129,0.2);
    color: #10B981;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.resend-row {
    margin-top: 0.5rem;
    text-align: right;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
}

.btn-link:hover {
    text-decoration: underline;
}

/* Casilla de Términos y Condiciones */
.terms-group {
    margin-top: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 0.65rem 0.75rem;
    border-radius: 12px;
    border: 1.5px solid transparent;
    background: transparent;
    transition: all 0.25s ease;
}

.terms-group.has-error {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.06);
    animation: shakeTerms 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shakeTerms {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.terms-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.45;
}

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

.custom-checkbox {
    width: 19px;
    height: 19px;
    min-width: 19px;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
    transition: all 0.25s ease;
}

.terms-group.has-error .custom-checkbox {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
}

.custom-checkbox i {
    font-size: 0.65rem;
    color: #ffffff;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
}

.terms-checkbox-label input[type="checkbox"]:checked ~ .custom-checkbox {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(81, 155, 233, 0.35);
}

.terms-checkbox-label input[type="checkbox"]:checked ~ .custom-checkbox i {
    opacity: 1;
    transform: scale(1);
}

.terms-checkbox-label:hover .custom-checkbox {
    border-color: var(--primary);
}

.terms-text {
    font-size: 0.825rem;
    color: #475569;
    transition: color 0.2s ease;
}

.terms-group.has-error .terms-text {
    color: #b91c1c;
    font-weight: 500;
}

.terms-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

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

.terms-hint-msg {
    display: none;
    margin-top: 0.45rem;
    padding-left: 1.85rem;
    font-size: 0.78rem;
    color: #dc2626;
    font-weight: 600;
    align-items: center;
    gap: 0.4rem;
    animation: fadeInModal 0.25s ease;
}

.terms-group.has-error .terms-hint-msg {
    display: flex;
}

.login-footer-links {
    margin-top: 0.5rem;
}

.footer-legal-link {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.2s ease;
}

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

/* Modal Adopción Llave Biométrica Post-Login */
.webauthn-modal-overlay {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 15, 29, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
    animation: fadeInModal 0.3s ease;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.webauthn-modal-card {
    background: #FFFFFF;
    border-radius: 24px;
    padding: 2.5rem 2.25rem;
    max-width: 450px;
    width: 100%;
    text-align: center;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.25);
    border: 1px solid var(--card-border);
    animation: scaleUpModal 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    margin: auto !important;
    position: relative;
    overflow: hidden;
}

/* Menisco superior iridiscente SICOAS Liquid Glass */
.webauthn-modal-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3.5px;
    background: linear-gradient(90deg, #519BE9 0%, #F0C6A3 50%, #D44A59 100%);
    z-index: 5;
}

@keyframes scaleUpModal {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.webauthn-modal-icon {
    width: 76px;
    height: 76px;
    background: linear-gradient(135deg, rgba(81,155,233,0.12) 0%, rgba(81,155,233,0.24) 100%);
    border: 2px solid rgba(81,155,233,0.35);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem auto;
    font-size: 2.25rem;
    color: var(--primary);
    box-shadow: 0 8px 25px rgba(81,155,233,0.22);
}

.webauthn-modal-icon.pulse-icon {
    animation: bioPulseRing 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes bioPulseRing {
    0% {
        box-shadow: 0 0 0 0 rgba(81, 155, 233, 0.6);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 16px rgba(81, 155, 233, 0);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(81, 155, 233, 0);
        transform: scale(1);
    }
}

.webauthn-modal-title {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 800;
    color: #0F172A !important;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.webauthn-modal-desc {
    font-size: 0.925rem;
    color: #334155 !important;
    line-height: 1.6;
    margin-bottom: 1.75rem;
}

.webauthn-modal-desc strong {
    color: #0F172A !important;
    font-weight: 700;
}

.webauthn-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.btn-skip-key {
    text-align: center;
    padding: 0.65rem;
    color: #64748B !important;
    font-size: 0.85rem;
    font-weight: 600;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-skip-key:hover {
    color: #0F172A !important;
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .login-container {
        flex-direction: column;
        margin: 1rem auto !important;
        min-height: auto;
    }
    .login-visual { padding: 1.75rem; min-height: 180px; }
    .visual-content h1 { font-size: 1.85rem; }
    .visual-stats { flex-wrap: wrap; gap: 0.85rem; }
    .login-form-section { padding: 1.75rem 1.5rem; }
}

/* ==========================================================================
   BLINDAJE DE RENDIMIENTO Y HARDWARE ADAPTATIVO (ÁGUILA / ALCÓN)
   1. Soporte automático para Windows "Ajustar para obtener el mejor rendimiento"
      (prefers-reduced-motion: reduce)
   2. Soporte adaptativo para equipos de bajos recursos (.sicoas-lite-mode)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .login-container,
    .login-visual,
    .login-form-section,
    .webauthn-modal-card,
    .webauthn-modal-content {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
    }
    .sicoas-light-bg-canvas {
        display: none !important;
    }
}

body.sicoas-lite-mode *,
body.sicoas-lite-mode *::before,
body.sicoas-lite-mode *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
}

body.sicoas-lite-mode .login-container,
body.sicoas-lite-mode .login-visual,
body.sicoas-lite-mode .login-form-section,
body.sicoas-lite-mode .webauthn-modal-card,
body.sicoas-lite-mode .webauthn-modal-content {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
}


