/* ============================================================
   New Login SyB - Basado en S_y_B.html (referencia de diseño)
   Paso 1: Variables CSS + Reset Base
   ============================================================ */

:root {
    --udla-orange: #E35205;
    --udla-orange-dark: #C44404;
    --udla-orange-light: #FF6B35;
    --udla-blue: #1D252D;
    --udla-blue-light: #2A3540;
    --udla-blue-dark: #141A20;
    --pregrado-color: #E35205;
    --postgrado-color: #5E35B1;
    --dual-color: #2E7D32;
    --inactivo-color: #757575;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.2);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

/* ============================================================
   LAYOUT PRINCIPAL - Estructura simple como referencia S_y_B.html
   ============================================================ */

/* Body full-screen para login */
body.syb-login-body {
    margin: 0;
    height: 100vh;
    min-height: 100vh;
    background: #f5f5f5;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.syb-login-view {
    display: flex;
    min-height: 100vh;
    height: 100vh;
    width: 100%;
}

/* ============================================================
   PANEL IZQUIERDO
   ============================================================ */
.login-left {
    flex: 1;
    background: linear-gradient(135deg, var(--udla-blue) 0%, var(--udla-blue-dark) 100%);
    color: white;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    gap: 0;
}

    .login-left::before {
        content: '';
        position: absolute;
        inset: 0;
        background: url('images/nuevofondologin.jpg') center/cover;
        opacity: 0.15;
        z-index: 0;
    }

.login-left > * { position: relative; z-index: 1; }

.login-branding {
    width: 100%;
    text-align: center;
}

.login-logo {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: white;
}

.login-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    color: white;
}

/* ============================================================
   PANEL DERECHO
   ============================================================ */
.login-right {
    flex: 1;
    background: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

/* Ocultar header duplicado (logo va en panel izquierdo) */
.login-right-header { display: none !important; }

/* Contenido interno del panel derecho - max-width 400px como referencia */
.login-right .login-box,
.login-right .needs-validation {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    text-align: left;
}

/* Título y subtítulo panel derecho (referencia) */
.nlsyb-text-display {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--udla-blue);
    margin-bottom: 8px;
    text-align: left;
}

.nlsyb-login-welcome {
    font-size: 1rem;
    color: #666;
    margin-bottom: 32px;
    text-align: left;
}

/* Hint tipo usuario */
.login-type-hint {
    font-size: 0.8rem;
    color: #888;
    margin-top: -16px;
    margin-bottom: 20px;
    text-align: left;
}

/* Selector tipo usuario - botones pill */
.user-type-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 400px;
}

.user-type-card {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-type-card:hover { 
    border-color: var(--udla-orange);
    transform: translateY(-2px); 
}

.user-type-card.active {
    border-color: var(--udla-orange);
    background: #FFF3E0;
    color: var(--udla-orange);
}

.user-type-card:focus {
    outline: none;
    border-color: var(--udla-orange);
}

.user-type-icon { display: none !important; }

.user-type-title {
    font-size: 0.95rem;
    font-weight: 700;
}

.user-type-desc {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Formulario */
.form-group { margin-bottom: 20px; width: 100%; }

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #555;
}

.form-group input,
.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
}

.form-group input:focus,
.form-input:focus {
    outline: none;
    border-color: var(--udla-orange);
    box-shadow: 0 0 0 3px rgba(227, 82, 5, 0.1);
}

/* Password wrapper + toggle */
.password-wrapper { position: relative; }

.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    z-index: 2;
}

.password-toggle:hover { color: var(--udla-orange); }

/* Botón principal */
.btn-primary#btnIngresar,
.btn-primary[type="submit"] {
    width: 100%;
    padding: 16px;
    background: var(--udla-orange);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary#btnIngresar:hover,
.btn-primary[type="submit"]:hover {
    background: var(--udla-orange-dark);
}

.btn-primary#btnIngresar:focus,
.btn-primary[type="submit"]:focus,
.btn-primary:focus {
   outline: none;
   box-shadow: 0 0 0 3px rgba(227, 82, 5, 0.3);
}

.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Botón esperando respuesta del servidor: spinner junto al texto */
.btn-primary.is-loading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* #btnIngresar define cursor por id: se repite el selector para que gane el de espera. */
.btn-primary.is-loading:disabled,
.btn-primary#btnIngresar.is-loading:disabled { opacity: 0.85; cursor: progress; }

.btn-spinner {
    display: none;
    flex: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: syb-spin 0.7s linear infinite;
}

.btn-primary.is-loading .btn-spinner { display: inline-block; }

/* Errores */
.login-error,
#mensaje-error,
#ValidationSummaryLogin {
    color: #d32f2f;
    font-size: 0.875rem;
    margin-top: 8px;
    text-align: center;
    text-transform: none;
    font-weight: 500;
}

/* Avisos flotantes. Prefijo syb- a propósito: Bootstrap define .toast con opacity:0 y
   sus propias reglas de color, y ganaría sobre estas. */
.syb-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    /* Sobre el modal (1100) y el resto de la pantalla. */
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(420px, calc(100vw - 48px));
}

.syb-toast {
    padding: 14px 20px;
    border-radius: var(--radius);
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
    opacity: 1;
    box-shadow: var(--shadow-lg);
    animation: syb-slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

    .syb-toast.is-closing {
        animation: syb-slideOut 2s ease forwards;
    }

    .syb-toast i { flex: none; }

.syb-toast-error { background: #d32f2f; }
.syb-toast-success { background: #2e7d32; }
.syb-toast-info { background: var(--udla-blue); }

@keyframes syb-slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes syb-slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Enlaces - estilo referencia */
.login-links {
    text-align: center;
    margin-top: 16px;
    font-size: 0.875rem;
}

.login-links a {
    color: var(--udla-orange);
    text-decoration: none;
    font-weight: 600;
}

.login-links a:hover { text-decoration: underline; }

.login-links #activationLinkWrapper {
    display: none;
}

.login-links #activationLinkWrapper.show {
    display: inline;
}

.login-links #inactiveLinks {
    display: none;
}
.login-links #inactiveLinks.show {
    display: inline;
}

/* ============================================================
   PANELES DE ACTIVACIÓN - estilo referencia
   ============================================================ */
.activation-view {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #f5f5f5;
    z-index: 1001;
    overflow-y: auto;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.activation-view.show { display: flex; animation: syb-fadeIn 0.3s; }

.activation-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 48px;
    max-width: 500px;
    width: 100%;
    margin: 1rem auto;
}

/* Stepper */
.activation-steps {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
    align-items: center;
}

.step-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #999;
    font-size: 1rem;
}

.step-dot.active { background: var(--udla-orange); color: white; }
.step-dot.completed { background: var(--udla-blue); color: white; }

.step-line {
    width: 40px;
    height: 2px;
    background: #e0e0e0;
}
.step-line.completed { background: var(--udla-blue); }

/* Header activación */
.activation-header { text-align: center; margin-bottom: 24px; }
.activation-icon { font-size: 2rem; margin-bottom: 0.5rem; color: var(--udla-orange); }
.activation-header h2 { color: var(--udla-blue); font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.activation-header p { color: #666; font-size: 0.9rem; }

/* Info box */
.activation-info-box {
    background: #FFF3E0;
    border-left: 4px solid var(--udla-orange);
    padding: 1rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 24px;
}
.activation-info-box p { color: var(--udla-blue); font-size: 0.875rem; margin: 0; }

/* Botón volver */
.btn-back {
    background: var(--udla-blue);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-back:hover { background: var(--udla-blue-dark); }

/* Form grupos en activación */
.activation-card .form-group { margin-bottom: 20px; }
.activation-card .form-group label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 6px; color: #555; }
.activation-card .form-group input { width: 100%; padding: 14px 16px; border: 2px solid #e0e0e0; border-radius: var(--radius); font-size: 1rem; }
.activation-card .form-group input:focus { outline: none; border-color: var(--udla-orange); box-shadow: 0 0 0 3px rgba(227, 82, 5, 0.1); }

/* Password wrapper en activación */
.password-wrapper { position: relative; }
.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 1rem;
}
.password-toggle:hover { color: var(--udla-orange); }

/* Strength meter estilo referencia */
.strength-bar { height: 4px; background: #e0e0e0; border-radius: 2px; margin-top: 8px; overflow: hidden; }
.strength-fill { height: 100%; width: 0; transition: width 0.3s, background 0.3s; }
.strength-weak { background: #d32f2f; }
.strength-medium { background: #f9a825; }
.strength-strong { background: #2e7d32; }

/* Password requirements - estilo req-item */
.req-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: #999;
    margin-top: 4px;
}
.req-item.met { color: #2e7d32; }
.req-item i { font-size: 0.75rem; }

/* Password match */
.password-match { font-size: 0.85rem; margin-top: 0.5rem; font-weight: 500; }
.password-match.match { color: #2e7d32; }
.password-match.no-match { color: #d32f2f; }

/* User info mini */
.user-info-mini {
    background: #f5f5f5;
    padding: 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    text-align: center;
}
.user-name { font-weight: 700; color: #333; }
.user-rut { color: #888; margin-left: 0.5rem; font-size: 0.875rem; }

/* Botones en pasos activación */
.activation-card .btn-primary {
    width: 100%;
    padding: 16px;
    background: var(--udla-orange);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}
.activation-card .btn-primary:hover { background: var(--udla-orange-dark); }
.activation-card .btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(227, 82, 5, 0.4);
}
.activation-card .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
/* En espera de respuesta no es un botón inhabilitado: se mantiene legible. */
.activation-card .btn-primary.is-loading:disabled { opacity: 0.85; cursor: progress; }

/* Botón volver */
.btn-back {
    background: var(--udla-blue);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-back:hover { background: var(--udla-blue-dark); }
.btn-back:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(29, 37, 45, 0.4);
}

/* ============================================================
   PANTALLA DE ÉXITO
   ============================================================ */
.success-container { text-align: center; padding: 1.5rem; }
.success-icon {
    width: 80px; height: 80px;
    background: #E8F5E9;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 24px;
}
.success-icon i { font-size: 2rem; color: #2e7d32; }
.success-container h2 { color: var(--udla-blue); font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.success-container > p { color: #666; margin-bottom: 24px; }

.activation-summary {
    background: #f5f5f5;
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    text-align: left;
}
.activation-summary h3 { color: var(--udla-blue); margin-bottom: 1rem; font-size: 1.1rem; display: flex; align-items: center; gap: 0.5rem; }
.activation-summary ul { list-style: none; padding: 0; margin: 0; }
.activation-summary li { margin-bottom: 0.75rem; color: #555; font-size: 0.875rem; }
.activation-summary strong { color: #333; }

.security-reminder {
    background: #FFF8E1;
    border: 2px solid var(--warning);
    padding: 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    text-align: left;
}
.security-reminder h4 { color: #E65100; margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.security-reminder ul { list-style: none; padding: 0; margin: 0; }
.security-reminder li { margin-bottom: 0.5rem; color: #555; font-size: 0.875rem; }

.activation-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }
.activation-actions .btn-primary { flex: 1; min-width: 200px; }
.activation-actions .btn-secondary {
    flex: 1;
    min-width: 200px;
    padding: 16px;
    background: white;
    color: #555;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.activation-actions .btn-secondary:hover { border-color: var(--udla-orange); color: var(--udla-orange); }

/* ============================================================
   MODAL (SELECCIÓN NIVEL DUAL / CLAVE TEMPORAL) - estilo referencia
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    /* Sobre .activation-view (1001), que es un panel opaco a pantalla completa. */
    z-index: 1100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.modal-overlay.show { display: flex; animation: syb-fadeIn 0.3s; }

.modal-box {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    text-align: center;
}

.modal-box h2 { font-size: 1.25rem; font-weight: 700; color: var(--udla-blue); margin-bottom: 12px; }
.modal-box p { color: #666; margin-bottom: 20px; font-size: 0.875rem; }

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 1rem;
}
.modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    border: 2px solid #e0e0e0;
    background: white;
}
.modal-actions button:hover { border-color: var(--udla-orange); }
.modal-actions button:focus {
    outline: none;
    border-color: var(--udla-orange);
    box-shadow: 0 0 0 3px rgba(227, 82, 5, 0.3);
}

/* ============================================================
   ANIMACIONES
   ============================================================ */
@keyframes syb-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes syb-spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .login-left { display: none; }
    .text-display,
    .nlsyb-text-display { font-size: 2rem; }
    .login-right { padding: 2.5rem 1.5rem; }
    .user-type-selector { flex-direction: column; }
    .modal-actions { flex-direction: column; }
    .modal-actions button { width: 100%; }
    .activation-card { padding: 32px 24px; }
    .activation-actions { flex-direction: column; }
    .activation-actions .btn-primary,
    .activation-actions .btn-secondary { width: 100%; min-width: 0; }
    .step-line { width: 30px; }
    .step-dot { width: 32px; height: 32px; font-size: 0.9rem; }
    .step-line { width: 30px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
