/* ============================================
   VARIABLES DE DISEÑO - Paleta azul elegante
   ============================================ */
:root {
    --azul-900: #0A1628;
    --azul-800: #0D1F3C;
    --azul-700: #0F2847;
    --azul-600: #133564;
    --azul-500: #1A4480;
    --azul-400: #2563A0;
    --azul-300: #3B82B8;
    --azul-200: #6BA3D6;
    --azul-100: #A8C8E8;
    --azul-50:  #D6E6F5;
    --accent:    #00D4AA;
    --accent-hover: #00B894;
    --danger:    #E74C3C;
    --warning:   #F39C12;
    --success:   #27AE60;
    --blanco:    #FFFFFF;
    --gris-50:   #F8FAFC;
    --gris-100:  #F1F5F9;
    --gris-200:  #E2E8F0;
    --gris-300:  #CBD5E1;
    --gris-400:  #94A3B8;
    --gris-500:  #64748B;
    --gris-600:  #475569;
    --gris-700:  #334155;
    --gris-800:  #1E293B;
    --sombra-sm:  0 1px 3px rgba(10,22,40,0.12);
    --sombra-md:  0 4px 16px rgba(10,22,40,0.15);
    --sombra-lg:  0 8px 32px rgba(10,22,40,0.2);
    --sombra-xl:  0 16px 48px rgba(10,22,40,0.25);
    --sombra-glow: 0 0 40px rgba(0,212,170,0.15);
    --radio-sm: 8px;
    --radio-md: 12px;
    --radio-lg: 16px;
    --radio-xl: 20px;
    --transicion: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   RESET Y BASE
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    min-height: 100vh;
    background: var(--azul-900);
    overflow: hidden;
    color: var(--blanco);
}

/* ============================================
   FONDO ANIMADO - Particulas y gradientes
   ============================================ */
.bg-layer {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    overflow: hidden;
}

.bg-layer::before {
    content: '';
    position: absolute;
    top: -30%; right: -20%;
    width: 70vw; height: 70vw;
    background: radial-gradient(circle, rgba(19,53,100,0.6) 0%, transparent 70%);
    animation: floatBlob 20s ease-in-out infinite;
}

.bg-layer::after {
    content: '';
    position: absolute;
    bottom: -20%; left: -15%;
    width: 60vw; height: 60vw;
    background: radial-gradient(circle, rgba(0,212,170,0.08) 0%, transparent 65%);
    animation: floatBlob 25s ease-in-out infinite reverse;
}

@keyframes floatBlob {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -40px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

.grid-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    background-image:
        linear-gradient(rgba(37,99,160,0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(37,99,160,0.06) 1px, transparent 1px);
    background-size: 60px 60px;
}

#particles-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* ============================================
   LAYOUT PRINCIPAL - Flexbox
   ============================================ */
.login-container {
    position: relative;
    z-index: 10;
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ---- PANEL IZQUIERDO: Branding ---- */
.brand-panel {
    flex: 0 0 55%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    position: relative;
}

.brand-content {
    max-width: 480px;
    text-align: center;
}

.brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 2.5rem;
}

.brand-logo .logo-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--accent), var(--azul-300));
    border-radius: var(--radio-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--azul-900);
    font-weight: 800;
    box-shadow: 0 4px 20px rgba(0,212,170,0.3);
}

.brand-logo .logo-text {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--blanco), var(--azul-100));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-tagline {
    font-size: 1.1rem;
    color: var(--azul-200);
    line-height: 1.7;
    margin-bottom: 3rem;
    font-weight: 300;
}

.brand-features {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    text-align: left;
}

.brand-feature {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0.75rem 1rem;
    border-radius: var(--radio-sm);
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    transition: var(--transicion);
}

.brand-feature:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(0,212,170,0.2);
    transform: translateX(4px);
}

.brand-feature .feat-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radio-sm);
    background: rgba(0,212,170,0.1);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.brand-feature .feat-text {
    font-size: 0.88rem;
    color: var(--gris-300);
    font-weight: 400;
}

.brand-feature .feat-text strong {
    color: var(--blanco);
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
}

/* ---- PANEL DERECHO: Formulario ---- */

.form-panel {
    width: 480px;
    min-width: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 3rem;
    position: relative;
}

/*
.form-panel {
    width: 520px;
    min-width: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
}
*/
.form-panel::before {
    content: '';
    position: absolute;
    left: 0; top: 10%;
    width: 1px;
    height: 80%;
    background: linear-gradient(to bottom, transparent, var(--azul-500), transparent);
}

.form-wrapper {
    width: 100%;
    max-width: 400px;
}

.form-header {
    margin-bottom: 2rem;
}

.form-header h1 {
    font-size: 1.65rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--blanco);
    letter-spacing: -0.3px;
}

.form-header p {
    font-size: 0.9rem;
    color: var(--gris-400);
    font-weight: 400;
}

/* ============================================
   FORMULARIO - Campos y estilos
   ============================================ */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gris-300);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper .input-icon {
    position: absolute;
    left: 14px;
    color: var(--gris-500);
    font-size: 0.95rem;
    transition: var(--transicion);
    pointer-events: none;
    z-index: 2;
}

.input-wrapper input,
.input-wrapper select {
    width: 100%;
    padding: 13px 14px 13px 44px;
    background: rgba(255,255,255,0.04);
    border: 1.5px solid rgba(255,255,255,0.08);
    border-radius: var(--radio-sm);
    color: var(--blanco);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.92rem;
    font-weight: 400;
    transition: var(--transicion);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.input-wrapper select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394A3B8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.input-wrapper select option {
    background: var(--azul-800);
    color: var(--blanco);
    padding: 8px;
}

.input-wrapper input::placeholder {
    color: var(--gris-600);
}

/* Estados del input */
.input-wrapper input:focus,
.input-wrapper select:focus {
    border-color: var(--accent);
    background: rgba(0,212,170,0.03);
    box-shadow: 0 0 0 3px rgba(0,212,170,0.1);
}

.input-wrapper input:focus ~ .input-icon,
.input-wrapper select:focus ~ .input-icon {
    color: var(--accent);
}

.input-wrapper.error input,
.input-wrapper.error select {
    border-color: var(--danger);
    background: rgba(231,76,60,0.03);
    box-shadow: 0 0 0 3px rgba(231,76,60,0.1);
}

.input-wrapper.error .input-icon {
    color: var(--danger);
}

.input-error-msg {
    font-size: 0.78rem;
    color: var(--danger);
    display: none;
    align-items: center;
    gap: 4px;
    padding-left: 2px;
}

.input-error-msg.visible {
    display: flex;
}

/* Toggle de contrasena */
.toggle-password {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    color: var(--gris-500);
    cursor: pointer;
    font-size: 0.95rem;
    padding: 4px;
    transition: var(--transicion);
    z-index: 2;
}

.toggle-password:hover {
    color: var(--gris-300);
}

/* ---- Recordar y recuperar ---- */
.form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.25rem;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-wrapper input[type="checkbox"] {
    display: none;
}

.custom-checkbox {
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--gris-500);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transicion);
    flex-shrink: 0;
}

.custom-checkbox i {
    font-size: 0.6rem;
    color: var(--azul-900);
    opacity: 0;
    transform: scale(0);
    transition: var(--transicion);
}

.checkbox-wrapper input:checked + .custom-checkbox {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-wrapper input:checked + .custom-checkbox i {
    opacity: 1;
    transform: scale(1);
}

.checkbox-wrapper span {
    font-size: 0.85rem;
    color: var(--gris-400);
}

.forgot-link {
    font-size: 0.85rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transicion);
}

.forgot-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ---- Boton principal ---- */
.btn-login {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--accent), #00B894);
    border: none;
    border-radius: var(--radio-sm);
    color: var(--azul-900);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transicion);
    position: relative;
    overflow: hidden;
    margin-top: 0.5rem;
    letter-spacing: 0.3px;
}

.btn-login::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(0,212,170,0.35);
}

.btn-login:hover::before {
    left: 100%;
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login.loading {
    pointer-events: none;
    opacity: 0.85;
}

.btn-login .btn-text {
    transition: var(--transicion);
}

.btn-login.loading .btn-text {
    opacity: 0;
}

.btn-login .spinner {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 22px; height: 22px;
    border: 2.5px solid rgba(10,22,40,0.2);
    border-top-color: var(--azul-900);
    border-radius: 50%;
    opacity: 0;
    transition: var(--transicion);
}

.btn-login.loading .spinner {
    opacity: 1;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ---- Separador ---- */
.divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 0.5rem 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.08);
}

.divider span {
    font-size: 0.78rem;
    color: var(--gris-500);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

/* ---- Footer del formulario ---- */
.form-footer {
    text-align: center;
    margin-top: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.form-footer p {
    font-size: 0.83rem;
    color: var(--gris-500);
}

.form-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transicion);
}

.form-footer a:hover {
    text-decoration: underline;
}

/* ---- Version ---- */
.version-badge {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    font-size: 0.72rem;
    color: var(--gris-600);
    letter-spacing: 0.5px;
}

/* ============================================
   TOAST NOTIFICACIONES
   ============================================ */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radio-sm);
    background: var(--azul-800);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: var(--sombra-lg);
    min-width: 320px;
    max-width: 440px;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.hide {
    transform: translateX(120%);
    opacity: 0;
}

.toast .toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast.error .toast-icon { color: var(--danger); }
.toast.success .toast-icon { color: var(--success); }
.toast.warning .toast-icon { color: var(--warning); }

.toast .toast-body {
    flex: 1;
}

.toast .toast-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--blanco);
    margin-bottom: 2px;
}

.toast .toast-msg {
    font-size: 0.8rem;
    color: var(--gris-400);
    line-height: 1.4;
}

.toast .toast-close {
    background: none;
    border: none;
    color: var(--gris-500);
    cursor: pointer;
    padding: 4px;
    font-size: 0.85rem;
    transition: var(--transicion);
}

.toast .toast-close:hover {
    color: var(--blanco);
}

.toast .toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 var(--radio-sm) var(--radio-sm);
    animation: toastProgress 4s linear forwards;
}

.toast.error .toast-progress { background: var(--danger); }
.toast.success .toast-progress { background: var(--success); }
.toast.warning .toast-progress { background: var(--warning); }

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* ============================================
   MODAL DE RECUPERACION
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(10,22,40,0.85);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transicion);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-box {
    background: var(--azul-800);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radio-lg);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--sombra-xl);
    transform: scale(0.9) translateY(20px);
    transition: var(--transicion);
}

.modal-overlay.active .modal-box {
    transform: scale(1) translateY(0);
}

.modal-box h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.modal-box p {
    font-size: 0.88rem;
    color: var(--gris-400);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.modal-box .input-wrapper {
    margin-bottom: 1.25rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 0.5rem;
}

.btn-secondary {
    flex: 1;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radio-sm);
    color: var(--gris-300);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transicion);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.1);
    color: var(--blanco);
}

.btn-primary-sm {
    flex: 1;
    padding: 12px;
    background: var(--accent);
    border: none;
    border-radius: var(--radio-sm);
    color: var(--azul-900);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transicion);
}

.btn-primary-sm:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 16px rgba(0,212,170,0.3);
}

/* ============================================
   ANIMACIONES DE ENTRADA
   ============================================ */
.animate-in {
    opacity: 0;
    transform: translateY(24px);
    animation: slideIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.animate-in:nth-child(1) { animation-delay: 0.1s; }
.animate-in:nth-child(2) { animation-delay: 0.2s; }
.animate-in:nth-child(3) { animation-delay: 0.3s; }
.animate-in:nth-child(4) { animation-delay: 0.4s; }
.animate-in:nth-child(5) { animation-delay: 0.5s; }
.animate-in:nth-child(6) { animation-delay: 0.6s; }
.animate-in:nth-child(7) { animation-delay: 0.7s; }
.animate-in:nth-child(8) { animation-delay: 0.8s; }

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.brand-panel .animate-in {
    opacity: 0;
    transform: translateX(-30px);
    animation: slideFromLeft 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideFromLeft {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Animacion shake para errores */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    15%, 45%, 75% { transform: translateX(-6px); }
    30%, 60%, 90% { transform: translateX(6px); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 960px) {
    .brand-panel {
        display: none;
    }

    .form-panel {
        width: 100%;
        min-width: unset;
    }

    .form-panel::before {
        display: none;
    }

    .login-container {
        justify-content: center;
    }

    .mobile-brand {
        display: flex !important;
    }
}

.mobile-brand {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 2rem;
}

.mobile-brand .logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent), var(--azul-300));
    border-radius: var(--radio-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--azul-900);
    font-weight: 800;
}

.mobile-brand .logo-text {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--blanco);
}

@media (max-width: 480px) {
    .form-panel {
        padding: 1.25rem;
    }

    .form-wrapper {
        max-width: 100%;
    }

    .form-options {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .modal-actions {
        flex-direction: column;
    }

    .toast {
        min-width: unset;
        max-width: calc(100vw - 48px);
    }
}

/* Respeto por prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}