/* ============================================================================
   MÓDULO: auth.css
   PROYECTO: Sistema Académico U.E. Kantuta
   DESCRIPCIÓN: Estilos del login con layout split de dos paneles
   ============================================================================ */

/* ── Variables de diseño ──────────────────────────────────────────────────── */
:root {
    --auth-navy:       #0d2340;
    --auth-navy-mid:   #13344f;
    --auth-blue:       #1a4f72;
    --auth-accent:     #2980b9;
    --auth-accent-lt:  #3fa7d6;
    --auth-gold:       #f0a500;
    --auth-white:      #ffffff;
    --auth-off-white:  #f5f7fa;
    --auth-text-dark:  #1a2e44;
    --auth-text-mid:   #4a6279;
    --auth-text-light: #8da4b7;
    --auth-border:     #d8e4ed;
    --auth-success:    #27ae60;
    --auth-danger:     #e74c3c;
    --auth-shadow-lg:  0 25px 60px rgba(13, 35, 64, 0.35);
    --auth-shadow-sm:  0 4px 15px rgba(13, 35, 64, 0.12);
    --auth-radius:     16px;
    --auth-radius-sm:  10px;
    --auth-transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset de la pantalla de auth ─────────────────────────────────────────── */
body.authentication-bg {
    background: linear-gradient(135deg, #0a1929 0%, #0d2f4f 50%, #0f3d5c 100%) !important;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: "Barlow", sans-serif !important;
    overflow: hidden;
}

/* ── Partículas decorativas (CSS puro) ───────────────────────────────────── */
body.authentication-bg::before,
body.authentication-bg::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    opacity: 0.06;
    animation: floatOrb 12s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}
body.authentication-bg::before {
    width: 600px; height: 600px;
    background: radial-gradient(circle, var(--auth-accent-lt), transparent);
    top: -200px; left: -150px;
}
body.authentication-bg::after {
    width: 500px; height: 500px;
    background: radial-gradient(circle, var(--auth-gold), transparent);
    bottom: -200px; right: -150px;
    animation-delay: -6s;
}

@keyframes floatOrb {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(40px, 30px) scale(1.08); }
}

/* ── Contenedor principal ─────────────────────────────────────────────────── */
.auth-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 980px;
    background: var(--auth-white);
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-shadow-lg);
    display: grid;
    grid-template-columns: 42% 58%;
    overflow: hidden;
    min-height: 580px;
}

/* ══════════════════════════════════════════════════════════════════════════
   PANEL IZQUIERDO — Identidad institucional y roles
   ══════════════════════════════════════════════════════════════════════════ */
.auth-brand-panel {
    background: linear-gradient(160deg, var(--auth-navy) 0%, var(--auth-navy-mid) 55%, var(--auth-blue) 100%);
    padding: 40px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Efecto de malla sutil en el panel */
.auth-brand-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(255,255,255,0.04) 1px, transparent 0);
    background-size: 28px 28px;
    pointer-events: none;
}

/* ── Logo ──────────────────────────────────────────────────────────────────── */
.auth-logo-wrap {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 14px;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(8px);
    border: 1.5px solid rgba(255,255,255,0.15);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    animation: logoFloat 4s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0px); }
    50%       { transform: translateY(-6px); }
}

.auth-logo-icon svg {
    width: 46px;
    height: 46px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.auth-school-name {
    font-family: "Barlow", sans-serif;
    font-weight: 700;
    font-size: 1.35rem;
    color: var(--auth-white);
    letter-spacing: 0.5px;
    margin: 0 0 4px;
    line-height: 1.2;
}

.auth-school-rm {
    font-family: "Barlow", sans-serif;
    font-weight: 400;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.55);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin: 0;
}

/* ── Sección de roles ──────────────────────────────────────────────────────── */
.auth-roles-section {
    position: relative;
    z-index: 1;
    width: 100%;
}

.auth-roles-label {
    font-family: "Barlow", sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
    margin-bottom: 14px;
}

.auth-roles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Tarjeta de rol */
.auth-role-card {
    background: rgba(255,255,255,0.07);
    border: 1.5px solid rgba(255,255,255,0.1);
    border-radius: var(--auth-radius-sm);
    padding: 14px 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    transition: var(--auth-transition);
    user-select: none;
    position: relative;
    overflow: hidden;
}

.auth-role-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.06), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}

.auth-role-card:hover {
    background: rgba(255,255,255,0.13);
    border-color: rgba(255,255,255,0.25);
    transform: translateY(-2px);
}
.auth-role-card:hover::after { opacity: 1; }

.auth-role-card.active {
    background: rgba(42, 128, 185, 0.35);
    border-color: var(--auth-accent-lt);
    box-shadow: 0 0 0 2px rgba(63,167,214,0.3), 0 6px 20px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}

.auth-role-card.active .auth-role-icon {
    color: var(--auth-accent-lt);
}
.auth-role-card.active .auth-role-name {
    color: var(--auth-white);
}

/* Rol que ocupa toda la fila (cuando es número impar) */
.auth-role-card.full-row {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: center;
    gap: 10px;
    padding: 12px 10px;
}

.auth-role-icon {
    font-size: 1.5rem;
    color: rgba(255,255,255,0.7);
    transition: var(--auth-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.auth-role-icon svg {
    width: 24px;
    height: 24px;
}

.auth-role-name {
    font-family: "Barlow", sans-serif;
    font-weight: 600;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.75);
    text-align: center;
    line-height: 1.3;
    letter-spacing: 0.2px;
    transition: var(--auth-transition);
}

.auth-role-card.full-row .auth-role-name {
    font-size: 0.82rem;
}

/* ── Decoración inferior del panel izquierdo ──────────────────────────────── */
.auth-brand-footer {
    position: relative;
    z-index: 1;
    margin-top: 24px;
    text-align: center;
}

.auth-brand-footer p {
    font-family: "Barlow", sans-serif;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.3);
    margin: 0;
    letter-spacing: 0.5px;
}

/* ══════════════════════════════════════════════════════════════════════════
   PANEL DERECHO — Formulario de inicio de sesión
   ══════════════════════════════════════════════════════════════════════════ */
.auth-form-panel {
    background: var(--auth-off-white);
    padding: 50px 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ── Cabecera del formulario ───────────────────────────────────────────────── */
.auth-mobile-logo {
    display: none;
}
.auth-form-panel {
    background: var(--auth-off-white);
}

.auth-form-greeting {
    font-family: "Barlow", sans-serif;
    font-weight: 300;
    font-size: 0.9rem;
    color: var(--auth-text-light);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 0 0 6px;
}

.auth-form-title {
    font-family: "Barlow", sans-serif;
    font-weight: 700;
    font-size: 1.8rem;
    color: var(--auth-text-dark);
    margin: 0 0 10px;
    line-height: 1.15;
}

/* Badge del rol activo */
.auth-active-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(26, 79, 114, 0.1);
    border: 1px solid rgba(26, 79, 114, 0.2);
    border-radius: 20px;
    padding: 4px 12px;
    transition: var(--auth-transition);
    min-height: 28px;
}

.auth-active-role-badge span {
    font-family: "Barlow", sans-serif;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--auth-navy-mid);
    letter-spacing: 0.3px;
}

.auth-active-role-badge .badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--auth-accent);
    flex-shrink: 0;
    animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.4); opacity: 0.6; }
}

.auth-active-role-badge.no-role .badge-dot { background: var(--auth-border); animation: none; }
.auth-active-role-badge.no-role span { color: var(--auth-text-light); font-weight: 400; }

/* ── Formulario ────────────────────────────────────────────────────────────── */
.auth-login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Grupo de campo */
.auth-field-group {
    position: relative;
}

.auth-field-label {
    display: block;
    font-family: "Barlow", sans-serif;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--auth-text-mid);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 8px;
}

.auth-field-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-field-icon {
    position: absolute;
    left: 15px;
    color: var(--auth-text-light);
    display: flex;
    align-items: center;
    pointer-events: none;
    transition: color 0.2s;
    z-index: 1;
}

.auth-field-icon svg { width: 18px; height: 18px; }

.auth-field-input {
    width: 100%;
    background: var(--auth-white);
    border: 2px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    padding: 13px 44px 13px 44px;
    font-family: "Barlow", sans-serif;
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--auth-text-dark);
    transition: var(--auth-transition);
    outline: none;
    box-shadow: var(--auth-shadow-sm);
}

.auth-field-input::placeholder {
    color: var(--auth-text-light);
    font-weight: 300;
}

.auth-field-input:focus {
    border-color: var(--auth-accent);
    box-shadow: 0 0 0 4px rgba(41, 128, 185, 0.12), var(--auth-shadow-sm);
}

.auth-field-input:focus + .auth-field-underline,
.auth-field-group:focus-within .auth-field-icon {
    color: var(--auth-accent);
}

/* Botón toggle de contraseña */
.auth-toggle-pass {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--auth-text-light);
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.2s;
    z-index: 2;
}
.auth-toggle-pass:hover { color: var(--auth-accent); }
.auth-toggle-pass svg { width: 18px; height: 18px; }

/* ── Campo de error ────────────────────────────────────────────────────────── */
.auth-field-error {
    font-size: 0.76rem;
    color: var(--auth-danger);
    font-family: "Barlow", sans-serif;
    margin-top: 5px;
    padding-left: 4px;
    display: none;
}
.auth-field-group.has-error .auth-field-input {
    border-color: var(--auth-danger);
}
.auth-field-group.has-error .auth-field-error {
    display: block;
}

/* ── Botón de ingreso ──────────────────────────────────────────────────────── */
.auth-submit-btn {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--auth-navy-mid) 0%, var(--auth-accent) 100%);
    border: none;
    border-radius: var(--auth-radius-sm);
    font-family: "Barlow", sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--auth-white);
    cursor: pointer;
    transition: var(--auth-transition);
    position: relative;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(26, 79, 114, 0.4);
    margin-top: 4px;
}

.auth-submit-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}

.auth-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(26, 79, 114, 0.5);
}
.auth-submit-btn:hover::before { opacity: 1; }
.auth-submit-btn:active { transform: translateY(0); }

/* Estado cargando */
.auth-submit-btn.loading {
    pointer-events: none;
    opacity: 0.85;
}

.auth-submit-btn .btn-text { transition: opacity 0.2s; }
.auth-submit-btn .btn-spinner {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
}
.auth-submit-btn.loading .btn-text { opacity: 0; }
.auth-submit-btn.loading .btn-spinner { display: flex; }

/* Spinner SVG animation */
@keyframes spinnerRotate { to { transform: rotate(360deg); } }
.auth-spinner { animation: spinnerRotate 0.8s linear infinite; }

/* ── Campo oculto de rol ──────────────────────────────────────────────────── */
#auth_rol_seleccionado { display: none; }

/* ── Alerta de error general ──────────────────────────────────────────────── */
.auth-alert {
    display: none;
    background: rgba(231, 76, 60, 0.08);
    border: 1.5px solid rgba(231, 76, 60, 0.3);
    border-radius: var(--auth-radius-sm);
    padding: 11px 14px;
    font-family: "Barlow", sans-serif;
    font-size: 0.88rem;
    color: var(--auth-danger);
    font-weight: 500;
    display: none;
    align-items: center;
    gap: 8px;
}
.auth-alert.show { display: flex; animation: fadeSlideIn 0.3s ease; }
.auth-alert svg { width: 18px; height: 18px; flex-shrink: 0; }

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

/* ── Pie del formulario ───────────────────────────────────────────────────── */
.auth-form-footer {
    margin-top: 6px;
    text-align: center;
}

.auth-form-footer p {
    font-family: "Barlow", sans-serif;
    font-size: 0.8rem;
    color: var(--auth-text-light);
    margin: 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVIDAD
   ══════════════════════════════════════════════════════════════════════════ */

/* Tablet (≤ 840px) → Diseño Unificado Blue **Ultra-Compacto** */
@media (max-width: 840px) {
    body.authentication-bg {
        padding: 0;
        align-items: center; 
        background: var(--auth-navy) !important;
    }

    .auth-wrapper {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto;
        max-width: 100%;
        width: 100vw;
        height: auto;
        min-height: 100vh;
        border-radius: 0;
        margin: 0;
        background: linear-gradient(160deg, var(--auth-navy) 0%, var(--auth-navy-mid) 55%, var(--auth-blue) 100%) !important;
        box-shadow: none;
        display: flex;
        flex-direction: column;
    }

    /* Panel superior (Branding + Roles) */
    .auth-brand-panel {
        padding: 20px 20px 10px !important; /* Más cerrado */
        background: transparent !important;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        flex-shrink: 0;
    }

    .auth-logo-wrap { display: block !important; margin-bottom: 15px; } 
    .auth-logo-icon { width: 54px; height: 54px; margin-bottom: 8px; }
    .auth-logo-icon svg { width: 34px; height: 34px; }
    .auth-school-name { font-size: 1rem; }
    .auth-school-rm { font-size: 0.65rem; }

    .auth-roles-label { display: block !important; margin-bottom: 10px; font-size: 0.65rem; color: rgba(255,255,255,0.4); }

    /* --- ROLES: Grilla 3-2 Centrada y Compacta --- */
    .auth-roles-grid {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 10px;
        max-width: 280px;
        margin: 0 auto;
    }

    .auth-role-card {
        flex: 0 0 calc(33.33% - 14px);
        min-width: 75px;
        padding: 10px 4px;
        aspect-ratio: 1/1; /* Tarjetas cuadradas */
        justify-content: center;
    }

    .auth-role-card.full-row {
        grid-column: unset;
        flex-direction: column;
    }

    .auth-role-icon { width: 24px; height: 24px; font-size: 1.1rem; }
    .auth-role-name { 
        font-size: 0.58rem !important; 
        white-space: normal;
        margin-top: 2px;
        line-height: 1;
    }

    /* --- PANEL DE FORMULARIO --- */
    .auth-form-panel {
        padding: 10px 22px 25px !important; /* Muy compacto */
        background: transparent !important;
        flex-grow: 1;
        justify-content: flex-start;
    }

    .auth-form-header { margin-bottom: 15px; text-align: center; }
    .auth-form-greeting { font-size: 0.75rem; color: rgba(255,255,255,0.5); display: block; margin-bottom: 2px; }
    .auth-form-title { font-size: 1.45rem; color: #fff; margin-bottom: 8px; margin-top: 0; }

    .auth-active-role-badge { padding: 3px 12px; min-height: 24px; background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
    .auth-active-role-badge span { font-size: 0.7rem; color: #fff; }

    /* Inputs sobre fondo oscuro */
    .auth-login-form { gap: 10px; display: flex !important; flex-direction: column !important; } 
    
    .auth-field-label { font-size: 0.65rem; color: rgba(255,255,255,0.7); margin-bottom: 4px; text-align: left; }
    .auth-field-input { 
        padding: 9px 12px 9px 38px; 
        font-size: 0.9rem;
        background: rgba(255,255,255,0.08) !important;
        border: 1px solid rgba(255,255,255,0.2) !important;
        color: #fff !important;
        backdrop-filter: blur(8px);
    }
    .auth-field-input::placeholder { color: rgba(255,255,255,0.3) !important; }
    .auth-field-input:focus { background: rgba(255,255,255,0.12) !important; border-color: var(--auth-accent-lt) !important; }
    .auth-field-icon { left: 12px; color: rgba(255,255,255,0.5); }
    .auth-field-icon svg { width: 14px; height: 14px; }
    .auth-toggle-pass { right: 8px; color: rgba(255,255,255,0.5); }
    .auth-toggle-pass svg { width: 16px; height: 16px; }

    .auth-submit-btn { 
        padding: 12px;
        font-size: 0.85rem;
        margin-top: 8px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    }
    
    .auth-form-footer { margin-top: 15px; }
    .auth-form-footer p { font-size: 0.75rem; color: rgba(255,255,255,0.3); }
}

/* Móvil extra pequeño (≤ 360px) */
@media (max-width: 360px) {
    .auth-wrapper { grid-template-columns: 75px 1fr !important; }
    .auth-form-panel { padding: 20px 12px !important; }
    .auth-role-name { font-size: 0.55rem !important; }
}

/* ── Animación shake (login fallido) ─────────────────────────────────────── */
@keyframes formShake {
    0%, 100% { transform: translateX(0); }
    15%       { transform: translateX(-8px); }
    30%       { transform: translateX(8px); }
    45%       { transform: translateX(-6px); }
    60%       { transform: translateX(6px); }
    75%       { transform: translateX(-3px); }
    90%       { transform: translateX(3px); }
}
