/* =========================================
   1. CONFIGURACIÓN DE COLORES
   ========================================= */
.udemy-user-actions {
    --h-bg-card: #120922;
    --h-text-main: #ffffff;
    --h-text-muted: #94a3b8;
    --h-accent: #7c3aed;
    --h-border: #1e1329;
    
    display: flex;
    align-items: center;
    gap: 15px;
    font-family: 'Inter', sans-serif; 
}

.udemy-user-actions a { text-decoration: none !important; border: none; }

/* =========================================
   2. PERFIL (FIX AVATAR OVALADO)
   ========================================= */
.u-user-profile-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
    cursor: pointer;
    padding-bottom: 10px; /* Pequeña ayuda para el área sensible */
    margin-bottom: -10px; /* Compensación */
}

/* EL CÍRCULO CONTENEDOR */
.u-avatar-circle {
    /* Forzamos dimensiones fijas */
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important; 
    min-height: 36px !important;
    
    border: 2px solid var(--h-accent);
    padding: 2px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
    
    /* Evita que flexbox lo aplaste */
    flex-shrink: 0; 
}

/* LA IMAGEN DENTRO (FIX DEFINITIVO) */
.u-avatar-circle img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* Recorta la imagen para llenar el circulo */
    aspect-ratio: 1 / 1 !important; /* Fuerza relación cuadrada 1:1 */
    border-radius: 50% !important;
    display: block;
    margin: 0;
}

.u-user-profile-wrapper:hover .u-avatar-circle {
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.6);
}

/* =========================================
   3. MENÚ DESPLEGABLE (FIX "DESAPARECE RÁPIDO")
   ========================================= */
.u-dropdown-menu {
    /* Estado inicial: Oculto pero animable */
    visibility: hidden;
    opacity: 0;
    transform: translateY(10px);
    
    position: absolute;
    top: 100%; 
    right: 0;
    width: 260px;
    background: var(--h-bg-card);
    border: 1px solid var(--h-border);
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    border-radius: 12px;
    z-index: 99999;
    padding: 0;
    overflow: hidden;
    
    /* Transición al SALIR (Delay para que no desaparezca rápido) */
    transition: all 0.2s ease-in-out 0.1s;
}

/* PUENTE INVISIBLE (EL SECRETO) */
/* Esto crea un área invisible entre el avatar y el menú para que el mouse no "se caiga" */
.u-dropdown-menu::before {
    content: "";
    position: absolute;
    top: -30px; /* Área de puente hacia arriba */
    left: 0;
    width: 100%;
    height: 30px;
    background: transparent; /* Invisible */
    display: block;
        z-index: 99999;

}

/* ESTADO HOVER (MOSTRAR) */
.u-user-profile-wrapper:hover .u-dropdown-menu { 
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    /* Al entrar, que sea instantáneo */
    transition-delay: 0s;
    z-index: 99999;
}

/* --- Resto de estilos del menú (Igual que antes) --- */
.u-menu-header {
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    background-color: rgba(255,255,255,0.03); 
    border-bottom: 1px solid var(--h-border);
}

.u-avatar-large {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    flex-shrink: 0;
    position: relative;
    display: block;
}
.u-avatar-large img {
    border-radius: 50%;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    aspect-ratio: 1/1 !important;
    border: 2px solid var(--h-border);
}

.u-edit-icon {
    position: absolute;
    bottom: -2px; right: -2px;
    font-size: 10px;
    background: var(--h-accent);
    border-radius: 50%;
    padding: 2px;
    line-height: 1;
}

.u-user-info strong { 
    display: block; font-size: 14px; color: var(--h-text-main); margin-bottom: 2px;
    white-space: nowrap; text-overflow: ellipsis; overflow: hidden;
}
.u-user-info span { 
    display: block; font-size: 12px; color: var(--h-text-muted); 
    white-space: nowrap; text-overflow: ellipsis; overflow: hidden;
}

.u-menu-links a {
    display: block;
    padding: 10px 16px;
    color: var(--h-text-muted); 
    font-size: 13px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.u-menu-links a:hover {
    background-color: rgba(255,255,255,0.05);
    color: var(--h-text-main);
    border-left-color: var(--h-accent); 
}
.u-divider { border: 0; border-top: 1px solid var(--h-border); margin: 0; }

/* =========================================
   4. BOTONES (LOGGED OUT)
   ========================================= */
.u-auth-buttons { display: flex; gap: 10px; }

.u-btn {
    padding: 8px 18px;
    font-weight: 600;
    font-size: 13px;
    border-radius: 50px;
    display: inline-block;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.u-btn-ghost {
    background-color: transparent;
    border: 1px solid var(--h-text-muted);
    color: var(--h-text-main);
}
.u-btn-ghost:hover { border-color: var(--h-accent); color: var(--h-accent); }

.u-btn-solid {
    background-color: var(--h-accent);
    border: 1px solid var(--h-accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}
.u-btn-solid:hover { background-color: #6d28d9; transform: translateY(-1px); }

/* =========================================
   5. MÓVIL (Drawer)
   ========================================= */
.popup-drawer .udemy-user-actions, 
.mobile-drawer .udemy-user-actions {
    flex-direction: column; width: 100%; align-items: flex-start; padding: 0;
}
.popup-drawer .u-user-profile-wrapper,
.mobile-drawer .u-user-profile-wrapper {
    width: 100%; flex-direction: column; align-items: flex-start; cursor: default; margin-bottom: 0; padding-bottom: 0;
}
.popup-drawer .u-avatar-circle,
.mobile-drawer .u-avatar-circle { display: none !important; }

.popup-drawer .u-dropdown-menu,
.mobile-drawer .u-dropdown-menu {
    position: relative; display: block; width: 100%; background: transparent; border: none; box-shadow: none; margin: 0; top: 0;
    visibility: visible; opacity: 1; transform: none; animation: none;
}
.popup-drawer .u-dropdown-menu::before,
.mobile-drawer .u-dropdown-menu::before { display: none; }

.popup-drawer .u-menu-links a,
.mobile-drawer .u-menu-links a {
    padding: 12px 0; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,0.05); border-left: none;
}
.popup-drawer .u-auth-buttons,
.mobile-drawer .u-auth-buttons { flex-direction: column; width: 100%; margin-top: 10px; }
.popup-drawer .u-btn, .mobile-drawer .u-btn { width: 100%; text-align: center; }